summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2011-02-23 01:53:29 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2011-02-23 01:53:29 +0000
commit4b66c47a16ee727490d6a9a07d0936ef55c6690b (patch)
treec919cc675714ecb011bb4c3f221d79e090fa874f /clang/lib/Sema
parent477c8f5440f3bcacdc6548e7e41c5f2823ab6c87 (diff)
downloadbcm5719-llvm-4b66c47a16ee727490d6a9a07d0936ef55c6690b.tar.gz
bcm5719-llvm-4b66c47a16ee727490d6a9a07d0936ef55c6690b.zip
Sema: diagnose kernel calls to non-global functions
llvm-svn: 126292
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 9e2b21aca21..1ba8ea62b41 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -4625,6 +4625,20 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
return ExprError(Diag(LParenLoc, diag::err_typecheck_call_not_function)
<< Fn->getType() << Fn->getSourceRange());
+ if (getLangOptions().CUDA) {
+ if (Config) {
+ // CUDA: Kernel calls must be to global functions
+ if (FDecl && !FDecl->hasAttr<CUDAGlobalAttr>())
+ return ExprError(Diag(LParenLoc,diag::err_kern_call_not_global_function)
+ << FDecl->getName() << Fn->getSourceRange());
+
+ // CUDA: Kernel function must have 'void' return type
+ if (!FuncT->getResultType()->isVoidType())
+ return ExprError(Diag(LParenLoc, diag::err_kern_type_not_void_return)
+ << Fn->getType() << Fn->getSourceRange());
+ }
+ }
+
// Check for a valid return type
if (CheckCallReturnType(FuncT->getResultType(),
Fn->getSourceRange().getBegin(), TheCall,
OpenPOWER on IntegriCloud