| 1 |
// RUN: echo 'export module foo; export int n;' > %t.cppm |
| 2 |
// RUN: %clang_cc1 -std=c++2a %t.cppm -emit-module-interface -o %t.pcm |
| 3 |
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=0 %s |
| 4 |
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=1 %s |
| 5 |
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=2 %s |
| 6 |
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=3 %s |
| 7 |
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=4 %s |
| 8 |
// RUN: %clang_cc1 -std=c++2a -fmodule-file=foo=%t.pcm -verify -DMODE=5 %s |
| 9 |
|
| 10 |
#if MODE == 0 |
| 11 |
// no module declaration |
| 12 |
|
| 13 |
#elif MODE == 1 |
| 14 |
// expected-no-diagnostics |
| 15 |
module foo; // Implementation, implicitly imports foo. |
| 16 |
#define IMPORTED |
| 17 |
|
| 18 |
#elif MODE == 2 |
| 19 |
export module foo; |
| 20 |
|
| 21 |
#elif MODE == 3 |
| 22 |
export module bar; // A different module |
| 23 |
|
| 24 |
#elif MODE == 4 |
| 25 |
module foo:bar; // Partition implementation |
| 26 |
//#define IMPORTED (we don't import foo here) |
| 27 |
|
| 28 |
#elif MODE == 5 |
| 29 |
export module foo:bar; // Partition interface |
| 30 |
//#define IMPORTED (we don't import foo here) |
| 31 |
|
| 32 |
#endif |
| 33 |
|
| 34 |
int k = n; |
| 35 |
#ifndef IMPORTED |
| 36 |
// expected-error@-2 {{use of undeclared identifier 'n'}} |
| 37 |
#endif |