summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2010-12-12 23:02:57 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2010-12-12 23:02:57 +0000
commite8cfaf4258cad84d8a9c936a93b4dd7d73ab7f5e (patch)
tree05898db47e0c31ad7e3e8cad0e7a6acbb4b156b6 /clang/lib
parentb4f896ce906dac485c83c2cfad26c224d31692d1 (diff)
downloadbcm5719-llvm-e8cfaf4258cad84d8a9c936a93b4dd7d73ab7f5e.tar.gz
bcm5719-llvm-e8cfaf4258cad84d8a9c936a93b4dd7d73ab7f5e.zip
Sema: diagnose kernel functions with non-void return type
llvm-svn: 121653
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index e5f27fcfbb8..a2a7fdcdd53 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2168,6 +2168,21 @@ static void HandleGlobalAttr(Decl *d, const AttributeList &Attr, Sema &S) {
return;
}
+ FunctionDecl *FD = cast<FunctionDecl>(d);
+ if (!FD->getResultType()->isVoidType()) {
+ TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();
+ if (FunctionTypeLoc* FTL = dyn_cast<FunctionTypeLoc>(&TL)) {
+ S.Diag(FD->getTypeSpecStartLoc(), diag::err_kern_type_not_void_return)
+ << FD->getType()
+ << FixItHint::CreateReplacement(FTL->getResultLoc().getSourceRange(),
+ "void");
+ } else {
+ S.Diag(FD->getTypeSpecStartLoc(), diag::err_kern_type_not_void_return)
+ << FD->getType();
+ }
+ return;
+ }
+
d->addAttr(::new (S.Context) CUDAGlobalAttr(Attr.getLoc(), S.Context));
} else {
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << "global";
OpenPOWER on IntegriCloud