| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: mkdir %t |
| 3 |
// RUN: split-file %s %t |
| 4 |
// |
| 5 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/x.cppm -o %t/x.pcm |
| 6 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fmodule-file=x=%t/x.pcm %t/x.y.cppm -o %t/x.y.pcm |
| 7 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/a.b.cppm -o %t/a.b.pcm |
| 8 |
// |
| 9 |
// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -fmodule-file=x=%t/x.pcm \ |
| 10 |
// RUN: -verify %t/test.interface.cpp |
| 11 |
// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -fmodule-file=x=%t/x.pcm \ |
| 12 |
// RUN: -fmodule-file=a.b=%t/a.b.pcm -verify %t/test.implementation.cpp |
| 13 |
// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -fmodule-file=x=%t/x.pcm -verify %t/test.x.cpp |
| 14 |
|
| 15 |
//--- x.cppm |
| 16 |
export module x; |
| 17 |
export int a, b; |
| 18 |
|
| 19 |
//--- x.y.cppm |
| 20 |
export module x.y; |
| 21 |
export int c; |
| 22 |
|
| 23 |
//--- a.b.cppm |
| 24 |
export module a.b; |
| 25 |
export int d; |
| 26 |
|
| 27 |
//--- test.x.cpp |
| 28 |
module x; |
| 29 |
int use_1 = a; // ok |
| 30 |
|
| 31 |
int use_2 = b; // ok |
| 32 |
|
| 33 |
// There is no relation between module x and module x.y. |
| 34 |
int use_3 = c; // expected-error {{use of undeclared identifier 'c'}} |
| 35 |
|
| 36 |
//--- test.interface.cpp |
| 37 |
export module z; |
| 38 |
|
| 39 |
import x; |
| 40 |
|
| 41 |
import x [[]]; |
| 42 |
import x [[foo]]; // expected-warning {{unknown attribute 'foo' ignored}} |
| 43 |
import x [[noreturn]]; // expected-error {{'noreturn' attribute cannot be applied to a module import}} |
| 44 |
import x [[blarg::noreturn]]; // expected-warning-re {{unknown attribute 'blarg::noreturn' ignored{{.*}}}} |
| 45 |
|
| 46 |
import x.y; |
| 47 |
import x.; // expected-error {{expected a module name after 'import'}} |
| 48 |
import .x; // expected-error {{expected a module name after 'import'}} |
| 49 |
|
| 50 |
import blarg; // expected-error {{module 'blarg' not found}} |
| 51 |
|
| 52 |
int use_4 = c; // ok |
| 53 |
|
| 54 |
//--- test.implementation.cpp |
| 55 |
module a.b; |
| 56 |
|
| 57 |
import x; |
| 58 |
|
| 59 |
import x [[]]; |
| 60 |
import x [[foo]]; // expected-warning {{unknown attribute 'foo' ignored}} |
| 61 |
import x [[noreturn]]; // expected-error {{'noreturn' attribute cannot be applied to a module import}} |
| 62 |
import x [[blarg::noreturn]]; // expected-warning-re {{unknown attribute 'blarg::noreturn' ignored{{.*}}}} |
| 63 |
|
| 64 |
import x.y; |
| 65 |
import x.; // expected-error {{expected a module name after 'import'}} |
| 66 |
import .x; // expected-error {{expected a module name after 'import'}} |
| 67 |
|
| 68 |
import blarg; // expected-error {{module 'blarg' not found}} |
| 69 |
|
| 70 |
int use_4 = c; // ok |