diff options
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 9 |
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(); |