[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Modules / preprocess-build.cpp
blob36a0740a0a76ed6964119fb96fc33eace3179232
1 // RUN: %clang_cc1 -std=c++1z -fmodules %s -verify
3 #pragma clang module build baz
4 module baz {}
5 #pragma clang module endbuild // baz
7 #pragma clang module build foo
8 module foo { module bar {} }
9 #pragma clang module contents
10 #pragma clang module begin foo.bar
12 // Can import baz here even though it was created in an outer build.
13 #pragma clang module import baz
15 #pragma clang module build bar
16 module bar {}
17 #pragma clang module contents
18 #pragma clang module begin bar
19 extern int n;
20 #pragma clang module end
21 #pragma clang module endbuild // bar
23 #pragma clang module import bar
25 constexpr int *f() { return &n; }
27 #pragma clang module end
28 #pragma clang module endbuild // foo
30 #pragma clang module import bar
31 #pragma clang module import foo.bar
32 static_assert(f() == &n);
34 #pragma clang module build // expected-error {{expected module name}}
35 #pragma clang module build unterminated // expected-error {{no matching '#pragma clang module endbuild'}}