| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: split-file %s %t |
| 3 |
// RUN: cd %t |
| 4 |
// |
| 5 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/a.cppm -o %t/a.pcm |
| 6 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/b.cppm -o %t/b.pcm |
| 7 |
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %t/c.cpp \ |
| 8 |
// RUN: -fprebuilt-module-path=%t |
| 9 |
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %t/d.cpp \ |
| 10 |
// RUN: -fprebuilt-module-path=%t |
| 11 |
// |
| 12 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/h.cppm \ |
| 13 |
// RUN: -fprebuilt-module-path=%t -o %t/h.pcm |
| 14 |
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %t/j.cpp \ |
| 15 |
// RUN: -fprebuilt-module-path=%t |
| 16 |
|
| 17 |
//--- a.cppm |
| 18 |
export module a; |
| 19 |
export void foo() { |
| 20 |
|
| 21 |
} |
| 22 |
|
| 23 |
//--- b.cppm |
| 24 |
export module b; |
| 25 |
void bar(); |
| 26 |
export void foo() { |
| 27 |
bar(); |
| 28 |
} |
| 29 |
|
| 30 |
//--- c.cpp |
| 31 |
// expected-no-diagnostics |
| 32 |
// Since we will load all the declaration lazily, we won't be able to find |
| 33 |
// the ODR violation here. |
| 34 |
import a; |
| 35 |
import b; |
| 36 |
|
| 37 |
//--- d.cpp |
| 38 |
import a; |
| 39 |
import b; |
| 40 |
// Test that we can still check the odr violation if we call the function |
| 41 |
// actually. |
| 42 |
void use() { |
| 43 |
foo(); // expected-error@* {{'foo' has different definitions in different modules;}} |
| 44 |
// expected-note@* {{but in 'a' found a different body}} |
| 45 |
} |
| 46 |
|
| 47 |
// [email protected]:* {{declaration 'foo' attached to named module 'a' cannot be attached to other modules}} |
| 48 |
// [email protected]:* {{}} |
| 49 |
|
| 50 |
//--- h.cppm |
| 51 |
export module h; |
| 52 |
export import a; |
| 53 |
export import b; |
| 54 |
|
| 55 |
//--- j.cpp |
| 56 |
import h; |
| 57 |
void use() { |
| 58 |
foo(); // expected-error@* {{'foo' has different definitions in different modules;}} |
| 59 |
// expected-note@* {{but in 'a' found a different body}} |
| 60 |
} |
| 61 |
|
| 62 |
// [email protected]:* {{declaration 'foo' attached to named module 'a' cannot be attached to other modules}} |
| 63 |
// [email protected]:* {{}} |