diff options
Diffstat (limited to 'test/SemaCXX/warn-throw-out-noexcept-func.cpp')
-rw-r--r-- | test/SemaCXX/warn-throw-out-noexcept-func.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/test/SemaCXX/warn-throw-out-noexcept-func.cpp b/test/SemaCXX/warn-throw-out-noexcept-func.cpp index 67ffbd93940a..a6c23ddc6c8f 100644 --- a/test/SemaCXX/warn-throw-out-noexcept-func.cpp +++ b/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 @@ struct R_ShouldDiag : A_ShouldDiag { ~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 { @@ -230,13 +239,30 @@ void n_ShouldNotDiag() noexcept { } catch (const S &s) { } } -void o_ShouldDiag() noexcept { //expected-note {{function declared non-throwing here}} +// As seen in p34973, this should not throw the warning. If there is an active +// exception, catch(...) catches everything. +void o_ShouldNotDiag() noexcept { try { - throw; //expected-warning {{has a non-throwing exception specification but}} + throw; } catch (...) { } } +void p_ShouldDiag() noexcept { //expected-note {{function declared non-throwing here}} + try { + throw; //expected-warning {{has a non-throwing exception specification but}} + } catch (int){ + } +} + +void q_ShouldNotDiag() noexcept { + try { + throw; + } catch (int){ + } catch (...){ + } +} + #define NOEXCEPT noexcept void with_macro() NOEXCEPT { //expected-note {{function declared non-throwing here}} throw 1; // expected-warning {{has a non-throwing exception specification but}} |