Debian Codegraph @

clang/test/Modules/skip-odr-check-in-gmf.cppm

raw
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 //--- b.cppm
39 module;
40 #include "func2.h"
41 export module b;
42 export using ::func;
43
44 //--- test.cc
45 import a;
46 import b;
47 bool test() {
48 return func(1, 2);
49 }
50
51 #ifdef IGNORE_ODR_VIOLATION
52 // expected-no-diagnostics
53 #else
54 // [email protected]:1 {{'func' has different definitions in different modules;}}
55 // [email protected]:1 {{but in 'a.<global>' found a different body}}
56 #endif