This revision was automatically updated to reflect the committed changes.
Closed by commit rL314229: [Sema] Corrected the warn-on-throw-from-noexcept 
behavior to include nothrow (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D38203?vs=116426&id=116729#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38203

Files:
  cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
  cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp


Index: cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp
+++ cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions 
-fsyntax-only -Wexceptions -verify -std=c++11
+// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions 
-fsyntax-only -Wexceptions -verify -fdeclspec -std=c++11
 struct A_ShouldDiag {
   ~A_ShouldDiag(); // implicitly noexcept(true)
 };
@@ -14,6 +14,15 @@
   ~R_ShouldDiag() { // expected-note  {{destructor has a implicit non-throwing 
exception specification}}
     throw 1; // expected-warning {{has a non-throwing exception specification 
but}}
   }
+  __attribute__((nothrow)) R_ShouldDiag() {// expected-note {{function 
declared non-throwing here}}
+    throw 1;// expected-warning {{has a non-throwing exception specification 
but}}
+  }
+  void __attribute__((nothrow)) SomeThrow() {// expected-note {{function 
declared non-throwing here}}
+   throw 1; // expected-warning {{has a non-throwing exception specification 
but}}
+  }
+  void __declspec(nothrow) SomeDeclspecThrow() {// expected-note {{function 
declared non-throwing here}}
+   throw 1; // expected-warning {{has a non-throwing exception specification 
but}}
+  }
 };
 
 struct M_ShouldNotDiag {
Index: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
===================================================================
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
@@ -426,7 +426,7 @@
 
 static bool isNoexcept(const FunctionDecl *FD) {
   const auto *FPT = FD->getType()->castAs<FunctionProtoType>();
-  if (FPT->isNothrow(FD->getASTContext()))
+  if (FPT->isNothrow(FD->getASTContext()) || FD->hasAttr<NoThrowAttr>())
     return true;
   return false;
 }


Index: cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp
+++ cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions -fsyntax-only -Wexceptions -verify -std=c++11
+// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions -fsyntax-only -Wexceptions -verify -fdeclspec -std=c++11
 struct A_ShouldDiag {
   ~A_ShouldDiag(); // implicitly noexcept(true)
 };
@@ -14,6 +14,15 @@
   ~R_ShouldDiag() { // expected-note  {{destructor has a implicit non-throwing exception specification}}
     throw 1; // expected-warning {{has a non-throwing exception specification but}}
   }
+  __attribute__((nothrow)) R_ShouldDiag() {// expected-note {{function declared non-throwing here}}
+    throw 1;// expected-warning {{has a non-throwing exception specification but}}
+  }
+  void __attribute__((nothrow)) SomeThrow() {// expected-note {{function declared non-throwing here}}
+   throw 1; // expected-warning {{has a non-throwing exception specification but}}
+  }
+  void __declspec(nothrow) SomeDeclspecThrow() {// expected-note {{function declared non-throwing here}}
+   throw 1; // expected-warning {{has a non-throwing exception specification but}}
+  }
 };
 
 struct M_ShouldNotDiag {
Index: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
===================================================================
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
@@ -426,7 +426,7 @@
 
 static bool isNoexcept(const FunctionDecl *FD) {
   const auto *FPT = FD->getType()->castAs<FunctionProtoType>();
-  if (FPT->isNothrow(FD->getASTContext()))
+  if (FPT->isNothrow(FD->getASTContext()) || FD->hasAttr<NoThrowAttr>())
     return true;
   return false;
 }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to