3 // RUN: split-file %s %t
5 // RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/A.cppm -o %t/A.pcm
6 // RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/B.cppm -o %t/B.pcm
7 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify -fsyntax-only
8 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use2.cpp -verify -fsyntax-only
9 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use3.cpp -verify -fsyntax-only
10 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use4.cpp -verify -fsyntax-only
11 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/C.cppm -verify -fsyntax-only
12 // RUN: %clang_cc1 -std=c++20 -I%t %t/D.cppm -verify -fsyntax-only
13 // RUN: %clang_cc1 -std=c++20 -I%t %t/E.cppm -verify -fsyntax-only
14 // RUN: %clang_cc1 -std=c++20 -I%t %t/F.cppm -verify -fsyntax-only
16 // Testing header units for coverity.
17 // RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/foo.h -o %t/foo.pcm
18 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -fmodule-file=%t/foo.pcm %t/Use5.cpp -verify -fsyntax-only
19 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -fmodule-file=%t/foo.pcm %t/Use6.cpp -verify -fsyntax-only
21 // Testing with module map modules. It is unclear about the relation ship between Clang modules and
22 // C++20 Named Modules. Will they coexist? Or will they be mutually exclusive?
23 // The test here is for primarily coverity.
25 // RUN: rm -f %t/foo.pcm
26 // RUN: %clang_cc1 -std=c++20 -fmodules -fmodules-cache-path=%t -fprebuilt-module-path=%t \
27 // RUN: -fmodule-map-file=%t/module.modulemap %t/Use7.cpp -verify -fsyntax-only
28 // RUN: %clang_cc1 -std=c++20 -fmodules -fmodules-cache-path=%t -fprebuilt-module-path=%t \
29 // RUN: -fmodule-map-file=%t/module.modulemap %t/Use7.cpp -verify -fsyntax-only
30 // Testing module map modules with named modules.
31 // RUN: %clang_cc1 -std=c++20 -fmodules -fmodules-cache-path=%t -fmodule-map-file=%t/module.modulemap \
32 // RUN: %t/A.cppm -o %t/A.pcm
33 // RUN: %clang_cc1 -std=c++20 -fmodules -fmodules-cache-path=%t -fprebuilt-module-path=%t \
34 // RUN: -fmodule-map-file=%t/module.modulemap %t/Use7.cpp -verify -fsyntax-only
35 // RUN: %clang_cc1 -std=c++20 -fmodules -fmodules-cache-path=%t -fprebuilt-module-path=%t \
36 // RUN: -fmodule-map-file=%t/module.modulemap %t/Use7.cpp -verify -fsyntax-only
42 template <class T, class U>
43 concept same_as = __is_same(T, U);
46 // The compiler would warn if we include foo_h twice without guard.
50 template <class T, class U>
51 concept same_as = __is_same(T, U);
58 export using ::same_as;
64 export using ::same_as;
67 // expected-no-diagnostics
71 template <class T> void foo()
72 requires same_as<T, int>
76 // expected-no-diagnostics
80 template <class T> void foo()
81 requires same_as<T, int>
85 // expected-no-diagnostics
89 template <class T> void foo()
90 requires same_as<T, int>
94 // expected-no-diagnostics
99 template <class T> void foo()
100 requires same_as<T, int>
104 // expected-no-diagnostics
111 template <class T> void foo()
112 requires same_as<T, int>
120 export using ::same_as;
122 // expected-error@* {{redefinition of 'same_as'}}
123 // expected-note@* 1+{{previous definition is here}}
129 export template <class T, class U>
130 concept same_as = __is_same(T, U);
132 // expected-error@* {{redefinition of 'same_as'}}
133 // expected-note@* 1+{{previous definition is here}}
137 template <class T, class U>
138 concept same_as = __is_same(T, U);
139 template <class T, class U>
140 concept same_as = __is_same(T, U);
142 // expected-error@* {{redefinition of 'same_as'}}
143 // expected-note@* 1+{{previous definition is here}}
146 import "foo.h"; // expected-warning {{the implementation of header units is in an experimental phase}}
149 template <class T> void foo()
150 requires same_as<T, int>
155 import "foo.h"; // expected-warning {{the implementation of header units is in an experimental phase}}
157 template <class T> void foo()
158 requires same_as<T, int>
161 //--- module.modulemap
168 // expected-no-diagnostics
172 template <class T> void foo()
173 requires same_as<T, int>
177 // expected-no-diagnostics
181 template <class T> void foo()
182 requires same_as<T, int>