| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: mkdir -p %t |
| 3 |
// RUN: split-file %s %t |
| 4 |
// |
| 5 |
// Baseline testing to make sure we can detect the ODR violation from the CC1 invocation. |
| 6 |
// RUNX: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm |
| 7 |
// RUNX: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -o %t/b.pcm |
| 8 |
// RUNX: %clang_cc1 -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only -verify |
| 9 |
// |
| 10 |
// Testing that we can ignore the ODR violation from the driver invocation. |
| 11 |
// RUN: %clang -std=c++20 %t/a.cppm --precompile -o %t/a.pcm |
| 12 |
// RUN: %clang -std=c++20 %t/b.cppm --precompile -o %t/b.pcm |
| 13 |
// RUN: %clang -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only -Xclang -verify \ |
| 14 |
// RUN: -DIGNORE_ODR_VIOLATION |
| 15 |
// |
| 16 |
// Testing that the driver can require to check the ODR violation. |
| 17 |
// RUN: %clang -std=c++20 -Xclang -fno-skip-odr-check-in-gmf %t/a.cppm --precompile -o %t/a.pcm |
| 18 |
// RUN: %clang -std=c++20 -Xclang -fno-skip-odr-check-in-gmf %t/b.cppm --precompile -o %t/b.pcm |
| 19 |
// RUN: %clang -std=c++20 -Xclang -fno-skip-odr-check-in-gmf %t/test.cc -fprebuilt-module-path=%t \ |
| 20 |
// RUN: -fsyntax-only -Xclang -verify |
| 21 |
|
| 22 |
//--- func1.h |
| 23 |
bool func(int x, int y) { |
| 24 |
return true; |
| 25 |
} |
| 26 |
|
| 27 |
//--- func2.h |
| 28 |
bool func(int x, int y) { |
| 29 |
return false; |
| 30 |
} |
| 31 |
|
| 32 |
//--- a.cppm |
| 33 |
module; |
| 34 |
#include "func1.h" |
| 35 |
export module a; |
| 36 |
export using ::func; |
| 37 |
|
| 38 |
export extern "C++" bool func1() { return true; } |
| 39 |
|
| 40 |
//--- b.cppm |
| 41 |
module; |
| 42 |
#include "func2.h" |
| 43 |
export module b; |
| 44 |
export using ::func; |
| 45 |
|
| 46 |
export extern "C++" bool func1() { return false; } |
| 47 |
|
| 48 |
//--- test.cc |
| 49 |
import a; |
| 50 |
import b; |
| 51 |
bool test() { |
| 52 |
return func(1, 2) && func1(); |
| 53 |
} |
| 54 |
|
| 55 |
#ifdef IGNORE_ODR_VIOLATION |
| 56 |
// expected-no-diagnostics |
| 57 |
#else |
| 58 |
// [email protected]:1 {{'func' has different definitions in different modules;}} |
| 59 |
// [email protected]:1 {{but in 'a.<global>' found a different body}} |
| 60 |
// [email protected]:6 {{'func1' has different definitions in different modules; definition in module 'b.<implicit global>' first difference is function body}} |
| 61 |
// [email protected]:6 {{but in 'a.<implicit global>' found a different body}} |
| 62 |
#endif |