Richard Smith | 1f2bd35 | 2017-07-06 21:05:56 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++1z -fmodules %s -verify |
Richard Smith | 5d2ed48 | 2017-06-09 19:22:32 +0000 | [diff] [blame] | 2 | |
| 3 | #pragma clang module build baz |
| 4 | module baz {} |
| 5 | #pragma clang module endbuild // baz |
| 6 | |
| 7 | #pragma clang module build foo |
| 8 | module foo { module bar {} } |
| 9 | #pragma clang module contents |
| 10 | #pragma clang module begin foo.bar |
| 11 | |
| 12 | // Can import baz here even though it was created in an outer build. |
| 13 | #pragma clang module import baz |
| 14 | |
| 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 |
| 22 | |
| 23 | #pragma clang module import bar |
| 24 | |
| 25 | constexpr int *f() { return &n; } |
| 26 | |
| 27 | #pragma clang module end |
| 28 | #pragma clang module endbuild // foo |
| 29 | |
| 30 | #pragma clang module import bar |
| 31 | #pragma clang module import foo.bar |
| 32 | static_assert(f() == &n); |
| 33 | |
| 34 | #pragma clang module build // expected-error {{expected module name}} |
| 35 | #pragma clang module build unterminated // expected-error {{no matching '#pragma clang module endbuild'}} |