]> granicus.if.org Git - clang/commitdiff
Revert "[OPENMP] Delayed diagnostics for VLA support."
authorAlexey Bataev <a.bataev@hotmail.com>
Fri, 22 Feb 2019 17:16:50 +0000 (17:16 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Fri, 22 Feb 2019 17:16:50 +0000 (17:16 +0000)
This reverts commit r354679 to fix the problem with the Windows
buildbots

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354680 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaType.cpp
test/OpenMP/target_vla_messages.cpp
test/SemaCUDA/vla.cu

index f314cb0abeaffd1cf2cb6090d37c586dbb136322..090d9431be386ab81d69e43a4623d32a5abd7ab7 100644 (file)
@@ -2250,13 +2250,15 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
   }
 
   if (T->isVariableArrayType() && !Context.getTargetInfo().isVLASupported()) {
-    // CUDA device code and some other targets don't support VLAs.
-    targetDiag(Loc, (getLangOpts().CUDA && getLangOpts().CUDAIsDevice)
-                        ? diag::err_cuda_vla
-                        : diag::err_vla_unsupported)
-        << ((getLangOpts().CUDA && getLangOpts().CUDAIsDevice)
-                ? CurrentCUDATarget()
-                : CFT_InvalidTarget);
+    if (getLangOpts().CUDA) {
+      // CUDA device code doesn't support VLAs.
+      CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget();
+    } else if (!getLangOpts().OpenMP ||
+               shouldDiagnoseTargetSupportFromOpenMP()) {
+      // Some targets don't support VLAs.
+      Diag(Loc, diag::err_vla_unsupported);
+      return QualType();
+    }
   }
 
   // If this is not C99, extwarn about VLA's and C99 array size modifiers.
index 30a2751724264eca64c80471cb5b1b6450bf4cff..b744081e9837ab9e34eef12889ea0ccb23835120 100644 (file)
@@ -47,7 +47,7 @@ void target_template(int arg) {
 #pragma omp target
   {
 #ifdef NO_VLA
-    // expected-error@+2 {{variable length arrays are not supported for the current target}}
+    // expected-error@+2 {{variable length arrays are not supported for the current target}}
 #endif
     T vla[arg];
   }
@@ -73,9 +73,6 @@ void target(int arg) {
     }
   }
 
-#ifdef NO_VLA
-    // expected-note@+2 {{in instantiation of function template specialization 'target_template<long>' requested here}}
-#endif
   target_template<long>(arg);
 }
 
index cf3054cd8e95fe13a3bd9019d34f2bf93f6dd65e..b65ae5e5fe214e9f3811d3e4c37b4092fe6388c3 100644 (file)
@@ -1,9 +1,5 @@
 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -verify %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux -verify -DHOST %s
-
-#ifndef __CUDA_ARCH__
-// expected-no-diagnostics
-#endif
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -verify -DHOST %s
 
 #include "Inputs/cuda.h"
 
@@ -12,10 +8,7 @@ void host(int n) {
 }
 
 __device__ void device(int n) {
-  int x[n];
-#ifdef __CUDA_ARCH__
-  // expected-error@-2 {{cannot use variable-length arrays in __device__ functions}}
-#endif
+  int x[n];  // expected-error {{cannot use variable-length arrays in __device__ functions}}
 }
 
 __host__ __device__ void hd(int n) {