aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-04-29 00:43:21 +0000
committerMike Stump <mrs@apple.com>2009-04-29 00:43:21 +0000
commitf7c41dab1a8de29b0991e853b8822bb0d1ddc01c (patch)
tree21fd9cfde5a4bf2b1bc509ffb0d228c12badcb0d /lib/Sema/SemaStmt.cpp
parentfcd7c6fc67570b906f06cd5ef606ca571ef5779a (diff)
Implement sema checking for noreturn.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70353 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r--lib/Sema/SemaStmt.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index cf240291c7..311496c720 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -788,9 +788,14 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, ExprArg rex) {
return ActOnBlockReturnStmt(ReturnLoc, RetValExp);
QualType FnRetType;
- if (FunctionDecl *FD = getCurFunctionDecl())
+ if (const FunctionDecl *FD = getCurFunctionDecl()) {
FnRetType = FD->getResultType();
- else if (ObjCMethodDecl *MD = getCurMethodDecl())
+ if (FD->hasAttr<NoReturnAttr>()) {
+ Diag(ReturnLoc, diag::err_noreturn_function_has_return_expr)
+ << getCurFunctionOrMethodDecl()->getDeclName();
+ return StmtError();
+ }
+ } else if (ObjCMethodDecl *MD = getCurMethodDecl())
FnRetType = MD->getResultType();
else // If we don't have a function/method context, bail.
return StmtError();