teak-llvm/clang/test/Modules/exception-spec.cpp
Richard Smith 5159bbad8b 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
2018-09-05 22:30:37 +00:00

37 lines
737 B
C++

// RUN: %clang_cc1 -x c++ -std=c++17 -fmodules -fmodules-local-submodule-visibility -fmodules-cache-path=%t %s -verify
// expected-no-diagnostics
#pragma clang module build PR38627
module PR38627 {}
#pragma clang module contents
#pragma clang module begin PR38627
namespace PR38627 {
struct X {
virtual ~X() {}
struct C {
friend X::~X();
} c;
};
}
#pragma clang module end
#pragma clang module endbuild
#pragma clang module import PR38627
namespace PR38627 {
struct Y {
virtual ~Y() {}
struct C {
friend Y::~Y();
} c;
};
static_assert(noexcept(X().~X()));
static_assert(noexcept(Y().~Y()));
struct A { virtual ~A() = default; };
struct B : public A, public X {
virtual ~B() override = default;
};
} // PR38627