Implement sema checking for noreturn.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70353 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index cf24029..311496c 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -788,9 +788,14 @@
     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();