xref: /llvm-project/clang/test/Modules/cxx17-exception-spec.cpp (revision eaf11ad70904679593d3c7c100bcbcc395c91a89)
1*eaf11ad7SRichard Smith // RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fno-modules-error-recovery -fno-spell-checking -verify -std=c++17 %s
2*eaf11ad7SRichard Smith 
3*eaf11ad7SRichard Smith #pragma clang module build a
4*eaf11ad7SRichard Smith module a {}
5*eaf11ad7SRichard Smith #pragma clang module contents
6*eaf11ad7SRichard Smith #pragma clang module begin a
7*eaf11ad7SRichard Smith constexpr bool return_true() { return true; }
8*eaf11ad7SRichard Smith struct X {
9*eaf11ad7SRichard Smith   static void f() noexcept(return_true());
10*eaf11ad7SRichard Smith };
11*eaf11ad7SRichard Smith #pragma clang module end
12*eaf11ad7SRichard Smith #pragma clang module endbuild
13*eaf11ad7SRichard Smith 
14*eaf11ad7SRichard Smith #pragma clang module build b
15*eaf11ad7SRichard Smith module b {}
16*eaf11ad7SRichard Smith #pragma clang module contents
17*eaf11ad7SRichard Smith #pragma clang module begin b
18*eaf11ad7SRichard Smith #pragma clang module import a
19*eaf11ad7SRichard Smith using T = decltype(return_true() && noexcept(X::f()));
20*eaf11ad7SRichard Smith #pragma clang module end
21*eaf11ad7SRichard Smith #pragma clang module endbuild
22*eaf11ad7SRichard Smith 
23*eaf11ad7SRichard Smith #pragma clang module import a
24*eaf11ad7SRichard Smith #pragma clang module import b
25*eaf11ad7SRichard Smith 
26*eaf11ad7SRichard Smith // Trigger import of return_true and then X::f in the same pass. This causes
27*eaf11ad7SRichard Smith // the type of X::f to be loaded while we have a pending body for return_true,
28*eaf11ad7SRichard Smith // which means evaluation of its exception specification at that point would
29*eaf11ad7SRichard Smith // fail.
30*eaf11ad7SRichard Smith T t;
31*eaf11ad7SRichard Smith 
32*eaf11ad7SRichard Smith static_assert(noexcept(X().f()));
33*eaf11ad7SRichard Smith 
34*eaf11ad7SRichard Smith // expected-no-diagnostics
35