[PATCH] D16331: [CUDA] Bail, rather than crash, on va_arg in device code.

Artem Belevich via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 19 15:55:13 PST 2016


tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Small nit. LGTM otherwise.


================
Comment at: lib/Sema/SemaExpr.cpp:11732
@@ +11731,3 @@
+  // CUDA device code does not support varargs.
+  if (getLangOpts().CUDAIsDevice) {
+    if (const FunctionDecl *F = dyn_cast<FunctionDecl>(CurContext)) {
----------------
tra wrote:
> Unneeded {}.
Currently CUDAIsDevice does not imply that .CUDA is set. You may end up taking 
this path if -fcuda-is-device is passed to C++ compilation.

For now add .CUDA check. We'll fix CUDA options processing separately.

================
Comment at: lib/Sema/SemaExpr.cpp:11732-11739
@@ +11731,10 @@
+  // CUDA device code does not support varargs.
+  if (getLangOpts().CUDAIsDevice) {
+    if (const FunctionDecl *F = dyn_cast<FunctionDecl>(CurContext)) {
+      CUDAFunctionTarget T = IdentifyCUDATarget(F);
+      if (T == CFT_Global || T == CFT_Device || T == CFT_HostDevice) {
+        return ExprError(Diag(E->getLocStart(), diag::err_va_arg_in_device));
+      }
+    }
+  }
+
----------------
Unneeded {}.


http://reviews.llvm.org/D16331





More information about the cfe-commits mailing list