erichkeane created this revision. Discovered that 'nothrow' (which is supposed to be an alias for noexcept) was not warning with a throw inside of it. This patch corrects the behavior previously created to add 'nothrow' to this list.
https://reviews.llvm.org/D38203 Files: lib/Sema/AnalysisBasedWarnings.cpp test/SemaCXX/warn-throw-out-noexcept-func.cpp Index: test/SemaCXX/warn-throw-out-noexcept-func.cpp =================================================================== --- test/SemaCXX/warn-throw-out-noexcept-func.cpp +++ test/SemaCXX/warn-throw-out-noexcept-func.cpp @@ -14,6 +14,12 @@ ~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}} + } }; struct M_ShouldNotDiag { Index: lib/Sema/AnalysisBasedWarnings.cpp =================================================================== --- lib/Sema/AnalysisBasedWarnings.cpp +++ 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: test/SemaCXX/warn-throw-out-noexcept-func.cpp =================================================================== --- test/SemaCXX/warn-throw-out-noexcept-func.cpp +++ test/SemaCXX/warn-throw-out-noexcept-func.cpp @@ -14,6 +14,12 @@ ~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}} + } }; struct M_ShouldNotDiag { Index: lib/Sema/AnalysisBasedWarnings.cpp =================================================================== --- lib/Sema/AnalysisBasedWarnings.cpp +++ 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