diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-09-05 22:30:37 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-09-05 22:30:37 +0000 |
commit | 5159bbad8b2b3abbdda768eef64015bdd59293c6 (patch) | |
tree | 5175c6f5fac9add0fbdfe931f7f6999eb0db1da4 /clang/test/SemaCXX/exception-spec.cpp | |
parent | 0b9234b915d37b186b7631ee77ad591793d1305c (diff) | |
download | bcm5719-llvm-5159bbad8b2b3abbdda768eef64015bdd59293c6.tar.gz bcm5719-llvm-5159bbad8b2b3abbdda768eef64015bdd59293c6.zip |
PR38627: Fix handling of exception specification adjustment for
destructors.
We previously tried to patch up the exception specification after
completing the class, which went wrong when the exception specification
was needed within the class body (in particular, by a friend
redeclaration of the destructor in a nested class). We now mark the
destructor as having a not-yet-computed exception specification
immediately after creating it.
This requires delaying various checks against the exception
specification (where we'd previously have just got the wrong exception
specification, and now find we have an exception specification that we
can't compute yet) when those checks fire while the class is being
defined.
This also exposed an issue that we were missing a CodeSynthesisContext
for computation of exception specifications (otherwise we'd fail to make
the module containing the definition of the class visible when computing
its members' exception specs). Adding that incidentally also gives us a
diagnostic quality improvement.
This has also exposed an pre-existing problem: making the exception
specification evaluation context a non-SFINAE context (as it should be)
results in a bootstrap failure; PR38850 filed for this.
llvm-svn: 341499
Diffstat (limited to 'clang/test/SemaCXX/exception-spec.cpp')
-rw-r--r-- | clang/test/SemaCXX/exception-spec.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/exception-spec.cpp b/clang/test/SemaCXX/exception-spec.cpp index f301a63503d..6ad19aab397 100644 --- a/clang/test/SemaCXX/exception-spec.cpp +++ b/clang/test/SemaCXX/exception-spec.cpp @@ -5,3 +5,50 @@ namespace MissingOnTemplate { template<typename T> void foo(T); // expected-error {{missing exception specification 'noexcept(true)'}} void test() { foo(0); } } + +struct UseBeforeComplete1 { + ~UseBeforeComplete1(); // expected-note {{previous}} + struct X { + friend UseBeforeComplete1::~UseBeforeComplete1() noexcept; // expected-warning {{previously declared with an implicit}} + }; +}; + +struct ThrowingDtor { ~ThrowingDtor() noexcept(false); }; +struct UseBeforeComplete2 { + ~UseBeforeComplete2(); // expected-note {{previous}} + struct X { + friend UseBeforeComplete2::~UseBeforeComplete2() noexcept; // expected-error {{does not match previous}} + }; + ThrowingDtor td; +}; + +struct UseBeforeComplete3 { + ~UseBeforeComplete3(); + struct X { + friend UseBeforeComplete3::~UseBeforeComplete3(); // ok, implicitly noexcept(true) + }; +}; +static_assert(noexcept(UseBeforeComplete3()), ""); + +struct UseBeforeComplete4 { + ~UseBeforeComplete4(); + struct X { + friend UseBeforeComplete4::~UseBeforeComplete4(); // ok, implicitly noexcept(false) + }; + ThrowingDtor td; +}; +static_assert(!noexcept(UseBeforeComplete4()), ""); + +namespace AssignmentOp { + struct D1; + struct D2; + struct B { + B &operator=(const B&); + virtual D1 &operator=(const D1&) noexcept; // expected-note {{overridden}} + virtual D2 &operator=(const D2&) noexcept; // expected-note {{overridden}} + }; + struct D1 : B {}; // expected-error {{more lax}} + struct D2 : B { + D2 &operator=(const D2&); // expected-error {{more lax}} + }; +} |