3 // RUN: split-file %s %t
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
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
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
23 bool func(int x, int y) {
28 bool func(int x, int y) {
38 export extern "C++" bool func1() { return true; }
46 export extern "C++" bool func1() { return false; }
52 return func(1, 2) && func1();
55 #ifdef IGNORE_ODR_VIOLATION
56 // expected-no-diagnostics
58 // expected-error@func2.h:1 {{'func' has different definitions in different modules;}}
59 // expected-note@func1.h:1 {{but in 'a.<global>' found a different body}}
60 // expected-error@b.cppm:6 {{'func1' has different definitions in different modules; definition in module 'b.<implicit global>' first difference is function body}}
61 // expected-note@a.cppm:6 {{but in 'a.<implicit global>' found a different body}}