From: Stephan Bergmann Date: Fri, 30 Jun 2017 07:22:02 +0000 (+0000) Subject: Fold exception-warnings.cpp into warn-throw-out-noexcept-func.cpp X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=09c135e20c7c80b7c738ddcbb7898bbb8b8ef363;p=clang Fold exception-warnings.cpp into warn-throw-out-noexcept-func.cpp I had failed to notice the latter existed when I recently introduced the former. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306799 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/SemaCXX/exception-warnings.cpp b/test/SemaCXX/exception-warnings.cpp deleted file mode 100644 index f6c646e5a4..0000000000 --- a/test/SemaCXX/exception-warnings.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s - -struct B {}; -struct D: B {}; -void goodPlain() throw () { - try { - throw D(); - } catch (B) {} -} -void goodReference() throw () { - try { - throw D(); - } catch (B &) {} -} -void goodPointer() throw () { - D d; - try { - throw &d; - } catch (B *) {} -} -void badPlain() throw () { // expected-note {{non-throwing function declare here}} - try { - throw B(); // expected-warning {{'badPlain' has a non-throwing exception specification but can still throw, resulting in unexpected program termination}} - } catch (D) {} -} -void badReference() throw () { // expected-note {{non-throwing function declare here}} - try { - throw B(); // expected-warning {{'badReference' has a non-throwing exception specification but can still throw, resulting in unexpected program termination}} - } catch (D &) {} -} -void badPointer() throw () { // expected-note {{non-throwing function declare here}} - B b; - try { - throw &b; // expected-warning {{'badPointer' has a non-throwing exception specification but can still throw, resulting in unexpected program termination}} - } catch (D *) {} -} diff --git a/test/SemaCXX/warn-throw-out-noexcept-func.cpp b/test/SemaCXX/warn-throw-out-noexcept-func.cpp index dfd1ff9065..fc2919a1e3 100644 --- a/test/SemaCXX/warn-throw-out-noexcept-func.cpp +++ b/test/SemaCXX/warn-throw-out-noexcept-func.cpp @@ -253,6 +253,43 @@ void with_try_block1() noexcept try { //expected-note {{non-throwing function de } catch (char *) { } +namespace derived { +struct B {}; +struct D: B {}; +void goodPlain() noexcept { + try { + throw D(); + } catch (B) {} +} +void goodReference() noexcept { + try { + throw D(); + } catch (B &) {} +} +void goodPointer() noexcept { + D d; + try { + throw &d; + } catch (B *) {} +} +void badPlain() noexcept { // expected-note {{non-throwing function declare here}} + try { + throw B(); // expected-warning {{'badPlain' has a non-throwing exception specification but can still throw, resulting in unexpected program termination}} + } catch (D) {} +} +void badReference() noexcept { // expected-note {{non-throwing function declare here}} + try { + throw B(); // expected-warning {{'badReference' has a non-throwing exception specification but can still throw, resulting in unexpected program termination}} + } catch (D &) {} +} +void badPointer() noexcept { // expected-note {{non-throwing function declare here}} + B b; + try { + throw &b; // expected-warning {{'badPointer' has a non-throwing exception specification but can still throw, resulting in unexpected program termination}} + } catch (D *) {} +} +} + int main() { R1_ShouldDiag o; //expected-note {{in instantiation of member function}} S1_ShouldDiag b; //expected-note {{in instantiation of member function}}