Ping. Updated for Rev 199220.

  Removed getDeclName.

http://llvm-reviews.chandlerc.com/D2508

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D2508?vs=6445&id=6664#toc

Files:
  lib/Sema/SemaStmt.cpp
  test/Sema/return-noreturn.c

Index: lib/Sema/SemaStmt.cpp
===================================================================
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -2810,12 +2810,9 @@
   bool isObjCMethod = false;
 
   if (const FunctionDecl *FD = getCurFunctionDecl()) {
-    FnRetType = FD->getReturnType();
+    FnRetType = FD->getResultType();
     if (FD->hasAttrs())
       Attrs = &FD->getAttrs();
-    if (FD->isNoReturn())
-      Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr)
-        << FD->getDeclName();
   } else if (ObjCMethodDecl *MD = getCurMethodDecl()) {
     FnRetType = MD->getReturnType();
     isObjCMethod = true;
@@ -2994,6 +2991,12 @@
       !CurContext->isDependentContext())
     FunctionScopes.back()->Returns.push_back(Result);
 
+  if (const FunctionDecl *FD = getCurFunctionDecl()) {
+    if (FD->isNoReturn()) 
+      DiagRuntimeBehavior(ReturnLoc, Result,
+        PDiag(diag::warn_noreturn_function_has_return_expr) << FD);
+  }
+
   return Owned(Result);
 }
 
Index: test/Sema/return-noreturn.c
===================================================================
--- test/Sema/return-noreturn.c
+++ test/Sema/return-noreturn.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks -Wmissing-noreturn 
-Wno-unreachable-code
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks -Wmissing-noreturn 
-Wno-unreachable-code -Winvalid-noreturn
 
 int j;
 void test1() { // expected-warning {{function 'test1' could be declared with 
attribute 'noreturn'}}
@@ -40,3 +40,11 @@
 _Noreturn void test5() {
   test2_positive();
 }
+
+// Should not warn about an invalid return even if the function is 
+// marked 'noreturn' and a return statement is present 
+// in the case that the return statement is unreachable.
+__attribute__((noreturn)) void test6() {
+  while (1) {}  
+  return;
+}
Index: lib/Sema/SemaStmt.cpp
===================================================================
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -2810,12 +2810,9 @@
   bool isObjCMethod = false;
 
   if (const FunctionDecl *FD = getCurFunctionDecl()) {
-    FnRetType = FD->getReturnType();
+    FnRetType = FD->getResultType();
     if (FD->hasAttrs())
       Attrs = &FD->getAttrs();
-    if (FD->isNoReturn())
-      Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr)
-        << FD->getDeclName();
   } else if (ObjCMethodDecl *MD = getCurMethodDecl()) {
     FnRetType = MD->getReturnType();
     isObjCMethod = true;
@@ -2994,6 +2991,12 @@
       !CurContext->isDependentContext())
     FunctionScopes.back()->Returns.push_back(Result);
 
+  if (const FunctionDecl *FD = getCurFunctionDecl()) {
+    if (FD->isNoReturn()) 
+      DiagRuntimeBehavior(ReturnLoc, Result,
+        PDiag(diag::warn_noreturn_function_has_return_expr) << FD);
+  }
+
   return Owned(Result);
 }
 
Index: test/Sema/return-noreturn.c
===================================================================
--- test/Sema/return-noreturn.c
+++ test/Sema/return-noreturn.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks -Wmissing-noreturn -Wno-unreachable-code
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks -Wmissing-noreturn -Wno-unreachable-code -Winvalid-noreturn
 
 int j;
 void test1() { // expected-warning {{function 'test1' could be declared with attribute 'noreturn'}}
@@ -40,3 +40,11 @@
 _Noreturn void test5() {
   test2_positive();
 }
+
+// Should not warn about an invalid return even if the function is 
+// marked 'noreturn' and a return statement is present 
+// in the case that the return statement is unreachable.
+__attribute__((noreturn)) void test6() {
+  while (1) {}  
+  return;
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to