]> granicus.if.org Git - clang/commitdiff
CUDA: diagnose unconfigured calls to global functions
authorPeter Collingbourne <peter@pcc.me.uk>
Sun, 2 Oct 2011 23:49:15 +0000 (23:49 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Sun, 2 Oct 2011 23:49:15 +0000 (23:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140975 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaExpr.cpp
test/SemaCUDA/kernel-call.cu

index 14b36e4598541782692853c653b89f0be8eae8a3..357f1af61149109d83f58c44a982282a6ec3793f 100644 (file)
@@ -3986,6 +3986,8 @@ def err_config_scalar_return : Error<
   "CUDA special function 'cudaConfigureCall' must have scalar return type">;
 def err_kern_call_not_global_function : Error<
   "kernel call to non-global function %0">;
+def err_global_call_not_config : Error<
+  "call to global function %0 not configured">;
 
 
 def err_cannot_pass_objc_interface_to_vararg : Error<
index d0a3f6b5ecc001e38a86f17344ee0440e0c99f4a..eb5678e7f002a20978ffb63ead26146d3101183b 100644 (file)
@@ -3655,6 +3655,11 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
       if (!FuncT->getResultType()->isVoidType())
         return ExprError(Diag(LParenLoc, diag::err_kern_type_not_void_return)
             << Fn->getType() << Fn->getSourceRange());
+    } else {
+      // CUDA: Calls to global functions must be configured
+      if (FDecl && FDecl->hasAttr<CUDAGlobalAttr>())
+        return ExprError(Diag(LParenLoc, diag::err_global_call_not_config)
+            << FDecl->getName() << Fn->getSourceRange());
     }
   }
 
index 7bc7ae1131596a845a0faa8e0ec38c03ac86bf87..9a22aa77ef41cc4dc7bd1d32928c8b29151f2166 100644 (file)
@@ -13,6 +13,7 @@ int h2(int x) { return 1; }
 
 int main(void) {
   g1<<<1, 1>>>(42);
+  g1(42); // expected-error {{call to global function g1 not configured}}
 
   t1(1);