| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: split-file %s %t |
| 3 |
// RUN: cd %t |
| 4 |
|
| 5 |
// Related to issue #132059 |
| 6 |
|
| 7 |
// Precompile the module dependencies correctly |
| 8 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface a.cppm -o a.pcm |
| 9 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface b.cppm -o b.pcm \ |
| 10 |
// RUN: -fmodule-file=A=a.pcm |
| 11 |
|
| 12 |
// Verify that providing incorrect mappings via |
| 13 |
// `-fmodule-file=<name>=<path/to/bmi>` does not crash the compiler when loading |
| 14 |
// a module that imports the incorrectly mapped module. |
| 15 |
// RUN: not %clang_cc1 -std=c++20 main1.cpp -fmodule-file=A=b.pcm |
| 16 |
|
| 17 |
//--- a.cppm |
| 18 |
export module A; |
| 19 |
|
| 20 |
export int a() { |
| 21 |
return 41; |
| 22 |
} |
| 23 |
|
| 24 |
//--- b.cppm |
| 25 |
export module B; |
| 26 |
import A; |
| 27 |
|
| 28 |
export int b() { |
| 29 |
return a() + 1; |
| 30 |
} |
| 31 |
|
| 32 |
//--- main1.cpp |
| 33 |
import A; |
| 34 |
|
| 35 |
int main() { |
| 36 |
return a(); |
| 37 |
} |
| 38 |
|
| 39 |
// Test again for the case where the BMI is first loaded correctly |
| 40 |
// RUN: not %clang_cc1 -std=c++20 main2.cpp-fmodule-file=B=b.pcm \ |
| 41 |
// RUN: -fmodule-file=A=b.pcm |
| 42 |
|
| 43 |
//--- main2.cpp |
| 44 |
import B; |
| 45 |
|
| 46 |
int main() { |
| 47 |
return b(); |
| 48 |
} |