| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: split-file %s %t |
| 3 |
// RUN: cd %t |
| 4 |
// |
| 5 |
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm |
| 6 |
// RUN: %clang_cc1 -module-file-info %t/a.pcm | FileCheck %t/a.cppm |
| 7 |
// RUN: %clang_cc1 -std=c++20 %t/b.cpp -fmodule-file=a=%t/a.pcm -fsyntax-only -verify |
| 8 |
// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-module-interface -o %t/c.pcm |
| 9 |
// RUN: %clang_cc1 -std=c++20 %t/d.cpp -fsyntax-only -verify -fmodule-file=c=%t/c.pcm |
| 10 |
|
| 11 |
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm |
| 12 |
// RUN: %clang_cc1 -std=c++20 %t/b.cpp -fmodule-file=a=%t/a.pcm -fsyntax-only -verify |
| 13 |
// RUN: %clang_cc1 -std=c++20 %t/c.cppm -fsyntax-only -verify |
| 14 |
// RUN: %clang_cc1 -module-file-info %t/a.pcm | FileCheck %t/a.cppm |
| 15 |
|
| 16 |
//--- a.cppm |
| 17 |
export module a; |
| 18 |
export extern "C++" int foo() { return 43; } |
| 19 |
export extern "C++" { |
| 20 |
int a(); |
| 21 |
int b(); |
| 22 |
int c(); |
| 23 |
} |
| 24 |
|
| 25 |
export { |
| 26 |
extern "C++" void f1(); |
| 27 |
extern "C++" void f2(); |
| 28 |
extern "C++" void f3(); |
| 29 |
} |
| 30 |
|
| 31 |
extern "C++" void unexported(); |
| 32 |
|
| 33 |
// CHECK: Sub Modules: |
| 34 |
// CHECK-NEXT: Implicit Module Fragment '<implicit global>' |
| 35 |
|
| 36 |
//--- b.cpp |
| 37 |
import a; |
| 38 |
int use() { |
| 39 |
a(); |
| 40 |
b(); |
| 41 |
c(); |
| 42 |
f1(); |
| 43 |
f2(); |
| 44 |
f3(); |
| 45 |
unexported(); // expected-error {{declaration of 'unexported' must be imported from module 'a' before it is required}} |
| 46 |
// [email protected]:15 {{declaration here is not visible}} |
| 47 |
return foo(); |
| 48 |
} |
| 49 |
|
| 50 |
//--- c.cppm |
| 51 |
// expected-no-diagnostics |
| 52 |
export module c; |
| 53 |
extern "C++" { |
| 54 |
export int f(); |
| 55 |
int h(); |
| 56 |
} |
| 57 |
|
| 58 |
extern "C++" export int g(); |
| 59 |
|
| 60 |
//--- d.cpp |
| 61 |
import c; |
| 62 |
int use() { |
| 63 |
return f() + g(); |
| 64 |
} |
| 65 |
|
| 66 |
int use_of_nonexported() { |
| 67 |
return h(); // expected-error {{declaration of 'h' must be imported from module 'c' before it is required}} |
| 68 |
// [email protected]:5 {{declaration here is not visible}} |
| 69 |
} |