Clang Project

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