Debian Codegraph @

clang/test/Modules/pr76638.cppm

raw
1 // RUN: rm -rf %t
2 // RUN: mkdir -p %t
3 // RUN: split-file %s %t
4 //
5 // RUN: %clang_cc1 -std=c++20 %t/mod1.cppm -emit-module-interface -o %t/mod1.pcm
6 // RUN: %clang_cc1 -std=c++20 %t/mod2.cppm -fmodule-file=mod1=%t/mod1.pcm \
7 // RUN: -fsyntax-only -verify
8 //
9 // RUN: %clang_cc1 -std=c++20 %t/mod3.cppm -emit-module-interface -o %t/mod3.pcm
10 // RUN: %clang_cc1 -std=c++20 %t/mod4.cppm -fmodule-file=mod3=%t/mod3.pcm \
11 // RUN: -fsyntax-only -verify
12
13 // Testing the behavior of `-fskip-odr-check-in-gmf`
14 // RUN: %clang_cc1 -std=c++20 %t/mod3.cppm -fskip-odr-check-in-gmf \
15 // RUN: -emit-module-interface -o %t/mod3.pcm
16 // RUN: %clang_cc1 -std=c++20 %t/mod4.cppm -fmodule-file=mod3=%t/mod3.pcm \
17 // RUN: -fskip-odr-check-in-gmf -DSKIP_ODR_CHECK_IN_GMF -fsyntax-only -verify
18
19 //--- size_t.h
20
21 extern "C" {
22 typedef unsigned int size_t;
23 }
24
25 //--- csize_t
26 namespace std {
27 using :: size_t;
28 }
29
30 //--- align.h
31 namespace std {
32 enum class align_val_t : size_t {};
33 }
34
35 //--- mod1.cppm
36 module;
37 #include "size_t.h"
38 #include "align.h"
39 export module mod1;
40 export using std::align_val_t;
41
42 //--- mod2.cppm
43 // expected-no-diagnostics
44 module;
45 #include "size_t.h"
46 #include "csize_t"
47 #include "align.h"
48 export module mod2;
49 import mod1;
50 export using std::align_val_t;
51
52 //--- signed_size_t.h
53 // Test that we can still find the case if the underlying type is different
54 extern "C" {
55 typedef signed int size_t;
56 }
57
58 //--- mod3.cppm
59 module;
60 #include "size_t.h"
61 #include "align.h"
62 export module mod3;
63 export using std::align_val_t;
64
65 //--- mod4.cppm
66 module;
67 #include "signed_size_t.h"
68 #include "csize_t"
69 #include "align.h"
70 export module mod4;
71 import mod3;
72 export using std::align_val_t;
73
74 #ifdef SKIP_ODR_CHECK_IN_GMF
75 // expected-no-diagnostics
76 #else
77 // [email protected]:* {{'std::align_val_t' has different definitions in different modules; defined here first difference is enum with specified type 'size_t' (aka 'int')}}
78 // [email protected]:* {{but in 'mod3.<global>' found enum with specified type 'size_t' (aka 'unsigned int')}}
79 #endif