Debian Codegraph @

clang/test/Modules/merge-var-template-spec-cxx-modules.cppm

raw
1 // RUN: rm -rf %t
2 // RUN: mkdir %t
3 // RUN: split-file %s %t
4 //
5 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/var_def.cppm -o %t/var_def.pcm
6 // RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/reexport1.cppm -o %t/reexport1.pcm
7 // RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/reexport2.cppm -o %t/reexport2.pcm
8 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/use.cppm -fsyntax-only -verify
9
10 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/var_def.cppm -o %t/var_def.pcm
11 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface -fprebuilt-module-path=%t %t/reexport1.cppm -o %t/reexport1.pcm
12 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface -fprebuilt-module-path=%t %t/reexport2.cppm -o %t/reexport2.pcm
13 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/use.cppm -fsyntax-only -verify
14
15 //--- use.cppm
16 import reexport1;
17 import reexport2;
18
19 auto foo = zero<Int>;
20 auto bar = zero<int*>;
21 auto baz = zero<int>;
22
23 template <class T> constexpr T zero = 0; // expected-error-re {{declaration{{.*}}in the global module follows declaration in module var_def}}
24 // expected-note@* {{previous}}
25 template <> constexpr Int zero<Int> = {0}; // expected-error-re {{declaration{{.*}}in the global module follows declaration in module var_def}}
26 // expected-note@* {{previous}}
27 template <class T> constexpr T* zero<T*> = nullptr; // expected-error-re {{declaration{{.*}}in the global module follows declaration in module var_def}}
28 // expected-note@* {{previous}}
29
30 template <> constexpr int** zero<int**> = nullptr; // ok, new specialization.
31 template <class T> constexpr T** zero<T**> = nullptr; // ok, new partial specilization.
32
33 //--- var_def.cppm
34 export module var_def;
35
36 export template <class T> constexpr T zero = 0;
37 export struct Int {
38 int value;
39 };
40 export template <> constexpr Int zero<Int> = {0};
41 export template <class T> constexpr T* zero<T*> = nullptr;
42
43 //--- reexport1.cppm
44 export module reexport1;
45 export import var_def;
46
47 //--- reexport2.cppm
48 export module reexport2;
49 export import var_def;