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

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 28 10:52:11 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL319201: [CUDA] Report "unsupported VLA" errors only on device side. (authored by tra).

Changed prior to commit:
  https://reviews.llvm.org/D40275?vs=123831&id=124607#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40275

Files:
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/SemaCUDA/call-stack-for-deferred-err.cu
  cfe/trunk/test/SemaCUDA/no-call-stack-for-immediate-errs.cu
  cfe/trunk/test/SemaCUDA/vla.cu


Index: cfe/trunk/test/SemaCUDA/vla.cu
===================================================================
--- cfe/trunk/test/SemaCUDA/vla.cu
+++ cfe/trunk/test/SemaCUDA/vla.cu
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -verify -DHOST %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -verify %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -verify -DHOST %s
 
 #include "Inputs/cuda.h"
 
Index: cfe/trunk/test/SemaCUDA/no-call-stack-for-immediate-errs.cu
===================================================================
--- cfe/trunk/test/SemaCUDA/no-call-stack-for-immediate-errs.cu
+++ cfe/trunk/test/SemaCUDA/no-call-stack-for-immediate-errs.cu
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only -verify %s
 
 #include "Inputs/cuda.h"
 
Index: cfe/trunk/test/SemaCUDA/call-stack-for-deferred-err.cu
===================================================================
--- cfe/trunk/test/SemaCUDA/call-stack-for-deferred-err.cu
+++ cfe/trunk/test/SemaCUDA/call-stack-for-deferred-err.cu
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only -verify %s
 
 #include "Inputs/cuda.h"
 
Index: cfe/trunk/lib/Sema/SemaType.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -2180,14 +2180,17 @@
     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() && !Context.getTargetInfo().isVLASupported()) {
+    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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40275.124607.patch
Type: text/x-patch
Size: 2609 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171128/ea90d521/attachment.bin>


More information about the cfe-commits mailing list