r319201 - [CUDA] Report "unsupported VLA" errors only on device side.

Artem Belevich via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 28 10:51:42 PST 2017


Author: tra
Date: Tue Nov 28 10:51:42 2017
New Revision: 319201

URL: http://llvm.org/viewvc/llvm-project?rev=319201&view=rev
Log:
[CUDA] Report "unsupported VLA" errors only on device side.

This fixes erroneously reported CUDA compilation errors
in host-side code during device-side compilation.

I've also restricted OpenMP-specific checks to trigger only
if we're compiling with OpenMP enabled.

Differential Revision: https://reviews.llvm.org/D40275

Modified:
    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

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=319201&r1=319200&r2=319201&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Nov 28 10:51:42 2017
@@ -2180,14 +2180,17 @@ QualType Sema::BuildArrayType(QualType T
     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.

Modified: cfe/trunk/test/SemaCUDA/call-stack-for-deferred-err.cu
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/call-stack-for-deferred-err.cu?rev=319201&r1=319200&r2=319201&view=diff
==============================================================================
--- cfe/trunk/test/SemaCUDA/call-stack-for-deferred-err.cu (original)
+++ cfe/trunk/test/SemaCUDA/call-stack-for-deferred-err.cu Tue Nov 28 10:51:42 2017
@@ -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"
 

Modified: cfe/trunk/test/SemaCUDA/no-call-stack-for-immediate-errs.cu
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/no-call-stack-for-immediate-errs.cu?rev=319201&r1=319200&r2=319201&view=diff
==============================================================================
--- cfe/trunk/test/SemaCUDA/no-call-stack-for-immediate-errs.cu (original)
+++ cfe/trunk/test/SemaCUDA/no-call-stack-for-immediate-errs.cu Tue Nov 28 10:51:42 2017
@@ -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"
 

Modified: cfe/trunk/test/SemaCUDA/vla.cu
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/vla.cu?rev=319201&r1=319200&r2=319201&view=diff
==============================================================================
--- cfe/trunk/test/SemaCUDA/vla.cu (original)
+++ cfe/trunk/test/SemaCUDA/vla.cu Tue Nov 28 10:51:42 2017
@@ -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"
 




More information about the cfe-commits mailing list