Mercurial > hg > CbC > CbC_llvm
comparison clang/test/Modules/explicit-build.cpp @ 150:1d019706d866
LLVM10
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 15:10:13 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
147:c2174574ed3a | 150:1d019706d866 |
---|---|
1 // RUN: rm -rf %t | |
2 | |
3 // ------------------------------- | |
4 // Build chained modules A, B, and C | |
5 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
6 // RUN: -fmodule-name=a -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/a.pcm \ | |
7 // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty | |
8 // | |
9 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
10 // RUN: -fmodule-file=%t/a.pcm \ | |
11 // RUN: -fmodule-name=b -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/b.pcm \ | |
12 // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty | |
13 // | |
14 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
15 // RUN: -fmodule-file=%t/b.pcm \ | |
16 // RUN: -fmodule-name=c -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/c.pcm \ | |
17 // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty | |
18 // | |
19 // CHECK-NO-IMPLICIT-BUILD-NOT: building module | |
20 | |
21 // ------------------------------- | |
22 // Build B with an implicit build of A | |
23 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
24 // RUN: -fmodule-name=b -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/b-not-a.pcm \ | |
25 // RUN: 2>&1 | FileCheck --check-prefix=CHECK-B-NO-A %s | |
26 // | |
27 // CHECK-B-NO-A: While building module 'b': | |
28 // CHECK-B-NO-A: building module 'a' as | |
29 | |
30 // ------------------------------- | |
31 // Check that we can use the explicitly-built A, B, and C modules. | |
32 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
33 // RUN: -I%S/Inputs/explicit-build \ | |
34 // RUN: -fmodule-file=%t/a.pcm \ | |
35 // RUN: -verify %s -DHAVE_A | |
36 // | |
37 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
38 // RUN: -I%S/Inputs/explicit-build \ | |
39 // RUN: -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \ | |
40 // RUN: -fmodule-file=%t/a.pcm \ | |
41 // RUN: -verify %s -DHAVE_A | |
42 // | |
43 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
44 // RUN: -I%S/Inputs/explicit-build \ | |
45 // RUN: -fmodule-file=%t/b.pcm \ | |
46 // RUN: -verify %s -DHAVE_A -DHAVE_B | |
47 // | |
48 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
49 // RUN: -I%S/Inputs/explicit-build \ | |
50 // RUN: -fmodule-file=%t/a.pcm \ | |
51 // RUN: -fmodule-file=%t/b.pcm \ | |
52 // RUN: -verify %s -DHAVE_A -DHAVE_B | |
53 // | |
54 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
55 // RUN: -I%S/Inputs/explicit-build \ | |
56 // RUN: -fmodule-file=%t/a.pcm \ | |
57 // RUN: -fmodule-file=%t/b.pcm \ | |
58 // RUN: -fmodule-file=%t/c.pcm \ | |
59 // RUN: -verify %s -DHAVE_A -DHAVE_B -DHAVE_C | |
60 // | |
61 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
62 // RUN: -I%S/Inputs/explicit-build \ | |
63 // RUN: -fmodule-file=%t/a.pcm \ | |
64 // RUN: -fmodule-file=%t/c.pcm \ | |
65 // RUN: -verify %s -DHAVE_A -DHAVE_B -DHAVE_C | |
66 | |
67 // ------------------------------- | |
68 // Check that -fmodule-file= in a module build makes the file transitively | |
69 // available even if it's not used. | |
70 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fno-implicit-modules -Rmodule-build -fno-modules-error-recovery \ | |
71 // RUN: -fmodule-file=%t/b.pcm \ | |
72 // RUN: -fmodule-name=d -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/d.pcm \ | |
73 // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty | |
74 // | |
75 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fno-implicit-modules -Rmodule-build -fno-modules-error-recovery \ | |
76 // RUN: -I%S/Inputs/explicit-build \ | |
77 // RUN: -fmodule-file=%t/d.pcm \ | |
78 // RUN: -verify %s -DHAVE_A -DHAVE_B | |
79 | |
80 #if HAVE_A | |
81 #include "a.h" | |
82 static_assert(a == 1, ""); | |
83 #else | |
84 const int use_a = a; // expected-error {{undeclared identifier}} | |
85 #endif | |
86 | |
87 #if HAVE_B | |
88 #include "b.h" | |
89 static_assert(b == 2, ""); | |
90 #else | |
91 const int use_b = b; // expected-error {{undeclared identifier}} | |
92 #endif | |
93 | |
94 #if HAVE_C | |
95 #include "c.h" | |
96 static_assert(c == 3, ""); | |
97 #else | |
98 const int use_c = c; // expected-error {{undeclared identifier}} | |
99 #endif | |
100 | |
101 #if HAVE_A && HAVE_B && HAVE_C | |
102 // expected-no-diagnostics | |
103 #endif | |
104 | |
105 // ------------------------------- | |
106 // Check that we can use a mixture of implicit and explicit modules. | |
107 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
108 // RUN: -I%S/Inputs/explicit-build \ | |
109 // RUN: -fmodule-file=%t/b-not-a.pcm \ | |
110 // RUN: -verify %s -DHAVE_A -DHAVE_B | |
111 | |
112 // ------------------------------- | |
113 // Try to use two different flavors of the 'a' module. | |
114 // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
115 // RUN: -fmodule-file=%t/a.pcm \ | |
116 // RUN: -fmodule-file=%t/b-not-a.pcm \ | |
117 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s | |
118 // | |
119 // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
120 // RUN: -fmodule-file=%t/a.pcm \ | |
121 // RUN: -fmodule-file=%t/b-not-a.pcm \ | |
122 // RUN: -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \ | |
123 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s | |
124 // | |
125 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
126 // RUN: -fmodule-name=a -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/a-alt.pcm \ | |
127 // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty | |
128 // | |
129 // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
130 // RUN: -fmodule-file=%t/a.pcm \ | |
131 // RUN: -fmodule-file=%t/a-alt.pcm \ | |
132 // RUN: -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \ | |
133 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s | |
134 // | |
135 // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
136 // RUN: -fmodule-file=%t/a-alt.pcm \ | |
137 // RUN: -fmodule-file=%t/a.pcm \ | |
138 // RUN: -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \ | |
139 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s | |
140 // | |
141 // CHECK-MULTIPLE-AS: error: module 'a' is defined in both '{{.*[/\\]}}a{{.*}}.pcm' and '{{.*[/\\]}}a{{.*}}.pcm' | |
142 | |
143 // ------------------------------- | |
144 // Try to import a PCH with -fmodule-file= | |
145 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
146 // RUN: -fmodule-name=a -emit-pch %S/Inputs/explicit-build/a.h -o %t/a.pch -DBUILDING_A_PCH \ | |
147 // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty | |
148 // | |
149 // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
150 // RUN: -fmodule-file=%t/a.pch \ | |
151 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-A-AS-PCH %s | |
152 // | |
153 // CHECK-A-AS-PCH: fatal error: AST file '{{.*}}a.pch' was not built as a module | |
154 | |
155 // ------------------------------- | |
156 // Try to import a non-AST file with -fmodule-file= | |
157 // | |
158 // RUN: touch %t/not.pcm | |
159 // | |
160 // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
161 // RUN: -fmodule-file=%t/not.pcm \ | |
162 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-BAD-FILE %s | |
163 // | |
164 // CHECK-BAD-FILE: fatal error: file '{{.*}}not.pcm' is not a valid precompiled module file | |
165 | |
166 // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
167 // RUN: -fmodule-file=%t/nonexistent.pcm \ | |
168 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-FILE %s | |
169 // | |
170 // CHECK-NO-FILE: fatal error: module file '{{.*}}nonexistent.pcm' not found: module file not found | |
171 | |
172 // RUN: mv %t/a.pcm %t/a-tmp.pcm | |
173 // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
174 // RUN: -I%S/Inputs/explicit-build \ | |
175 // RUN: -fmodule-file=%t/c.pcm \ | |
176 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-FILE-INDIRECT %s | |
177 // RUN: mv %t/a-tmp.pcm %t/a.pcm | |
178 // | |
179 // CHECK-NO-FILE-INDIRECT: error: module file '{{.*}}a.pcm' not found | |
180 // CHECK-NO-FILE-INDIRECT-NEXT: note: imported by module 'b' in '{{.*}}b.pcm' | |
181 // CHECK-NO-FILE-INDIRECT-NEXT: note: imported by module 'c' in '{{.*}}c.pcm' | |
182 // CHECK-NO-FILE-INDIRECT-NOT: note: | |
183 | |
184 // ------------------------------- | |
185 // Check that we don't get upset if B's timestamp is newer than C's. | |
186 // RUN: touch %t/b.pcm | |
187 // | |
188 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
189 // RUN: -I%S/Inputs/explicit-build \ | |
190 // RUN: -fmodule-file=%t/c.pcm \ | |
191 // RUN: -verify %s -DHAVE_A -DHAVE_B -DHAVE_C | |
192 // | |
193 // ... but that we do get upset if our B is different from the B that C expects. | |
194 // | |
195 // RUN: cp %t/b-not-a.pcm %t/b.pcm | |
196 // | |
197 // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ | |
198 // RUN: -I%S/Inputs/explicit-build \ | |
199 // RUN: -fmodule-file=%t/c.pcm \ | |
200 // RUN: %s -DHAVE_A -DHAVE_B -DHAVE_C 2>&1 | FileCheck --check-prefix=CHECK-MISMATCHED-B %s | |
201 // | |
202 // CHECK-MISMATCHED-B: fatal error: module file '{{.*}}b.pcm' is out of date and needs to be rebuilt: module file out of date | |
203 // CHECK-MISMATCHED-B-NEXT: note: imported by module 'c' | |
204 // CHECK-MISMATCHED-B-NOT: note: |