comparison clang/test/Modules/merge-records.cppm @ 252:1f2b6ac9f198 llvm-original

LLVM16-1
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 18 Aug 2023 09:04:13 +0900
parents
children
comparison
equal deleted inserted replaced
237:c80f45b162ad 252:1f2b6ac9f198
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/A.cppm -emit-module-interface -o %t/A.pcm
6 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp \
7 // RUN: -fsyntax-only -verify
8 //
9 // RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-module-interface -o %t/B.pcm
10 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp \
11 // RUN: -fsyntax-only -verify -DIMPORT_MODULE_B
12
13 //--- records.h
14 struct A {
15 int a;
16 int b;
17 int c;
18 };
19
20 struct NoNameEntity {
21 struct {
22 int a;
23 int b;
24 int c;
25 };
26 };
27
28 union U {
29 int a;
30 int b;
31 int c;
32 };
33
34 //--- another_records.h
35 struct A {
36 int a;
37 double b;
38 float c;
39 };
40
41 struct NoNameEntity {
42 struct {
43 int a;
44 unsigned b;
45 long c;
46 };
47 };
48
49 union U {
50 int a;
51 double b;
52 short c;
53 };
54
55 //--- A.cppm
56 module;
57 #include "records.h"
58 export module A;
59 export using ::A;
60 export using ::NoNameEntity;
61 export using ::U;
62 export constexpr A a_a{};
63 export constexpr NoNameEntity NoName_a{};
64 export constexpr U u_a{};
65
66 //--- B.cppm
67 module;
68 #include "records.h"
69 export module B;
70 export using ::A;
71 export using ::NoNameEntity;
72 export using ::U;
73 export constexpr A a_b{};
74 export constexpr NoNameEntity NoName_b{};
75 export constexpr U u_b{};
76
77 //--- Use.cpp
78 // expected-no-diagnostics
79 import A;
80 #ifdef IMPORT_MODULE_B
81 import B;
82 static_assert(__is_same(decltype(a_a), decltype(a_b)));
83 static_assert(__is_same(decltype(NoName_a), decltype(NoName_b)));
84 static_assert(__is_same(decltype(u_a), decltype(u_b)));
85 #endif
86 void use1() {
87 A a; // Shouldn't be ambiguous after import B;
88 a.a = 43;
89 a.b = 44;
90 a.c = 45;
91 NoNameEntity Anonymous;
92 Anonymous.a = 46;
93 Anonymous.b = 47;
94 Anonymous.c = 48;
95 U u;
96 u.a = 43;
97 }