[PATCH] D40275: [CUDA] Report "unsupported VLA" errors only on device side.

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 20 16:46:14 PST 2017


tra updated this revision to Diff 123690.
tra added a comment.

Folded OpenCL check under `if (T->isVariableArrayType())`


https://reviews.llvm.org/D40275

Files:
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===================================================================
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2175,19 +2175,21 @@
     T = Context.getConstantArrayType(T, ConstVal, ASM, Quals);
   }
 
-  // OpenCL v1.2 s6.9.d: variable length arrays are not supported.
-  if (getLangOpts().OpenCL && T->isVariableArrayType()) {
-    Diag(Loc, diag::err_opencl_vla);
-    return QualType();
-  }
-  // CUDA device code doesn't support VLAs.
-  if (getLangOpts().CUDA && T->isVariableArrayType())
-    CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget();
-  // Some targets don't support VLAs.
-  if (T->isVariableArrayType() && !Context.getTargetInfo().isVLASupported() &&
-      shouldDiagnoseTargetSupportFromOpenMP()) {
-    Diag(Loc, diag::err_vla_unsupported);
-    return QualType();
+  if (T->isVariableArrayType()) {
+    if (getLangOpts().OpenCL) {
+      // OpenCL v1.2 s6.9.d: variable length arrays are not supported.
+      Diag(Loc, diag::err_opencl_vla);
+      return QualType();
+    } else if (getLangOpts().CUDA) {
+      // CUDA device code doesn't support VLAs.
+      CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget();
+    } else if (getLangOpts().OpenMP &&
+               !Context.getTargetInfo().isVLASupported() &&
+               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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40275.123690.patch
Type: text/x-patch
Size: 1601 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171121/fb27ff62/attachment-0001.bin>


More information about the cfe-commits mailing list