diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2011-02-23 01:53:29 +0000 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2011-02-23 01:53:29 +0000 |
| commit | 4b66c47a16ee727490d6a9a07d0936ef55c6690b (patch) | |
| tree | c919cc675714ecb011bb4c3f221d79e090fa874f /clang/lib/Sema | |
| parent | 477c8f5440f3bcacdc6548e7e41c5f2823ab6c87 (diff) | |
| download | bcm5719-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.cpp | 14 |
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, |

