Debian Codegraph @

clang/test/Modules/module-local-template-instantiation-in-namespace.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/p1.cppm -emit-module-interface -o %t/p1.pcm
6 // RUN: %clang_cc1 -std=c++20 %t/p2.cppm -emit-module-interface -fmodule-file=m:p1=%t/p1.pcm -o %t/p2.pcm
7 // RUN: %clang_cc1 -std=c++20 %t/m.cppm -emit-module-interface -fmodule-file=m:p1=%t/p1.pcm -fmodule-file=m:p2=%t/p2.pcm -o %t/m.pcm
8 // RUN: %clang_cc1 -std=c++20 %t/use.cpp -fmodule-file=m=%t/m.pcm -fmodule-file=m:p1=%t/p1.pcm -fmodule-file=m:p2=%t/p2.pcm -fsyntax-only -verify
9
10 // RUN: %clang_cc1 -std=c++20 %t/p1.cppm -emit-reduced-module-interface -o %t/p1.pcm
11 // RUN: %clang_cc1 -std=c++20 %t/p2.cppm -emit-reduced-module-interface -fmodule-file=m:p1=%t/p1.pcm -o %t/p2.pcm
12 // RUN: %clang_cc1 -std=c++20 %t/m.cppm -emit-reduced-module-interface -fmodule-file=m:p1=%t/p1.pcm -fmodule-file=m:p2=%t/p2.pcm -o %t/m.pcm
13 // RUN: %clang_cc1 -std=c++20 %t/use.cpp -fmodule-file=m=%t/m.pcm -fmodule-file=m:p1=%t/p1.pcm -fmodule-file=m:p2=%t/p2.pcm -fsyntax-only -verify
14
15 //--- p1.cppm
16 export module m:p1;
17
18 namespace nn {
19 template<typename>
20 class Incognita;
21
22 export template<typename T>
23 class Variable
24 {
25 public:
26 Incognita<T> foo() const { return {*this}; }
27 };
28 }
29
30 //--- p2.cppm
31 export module m:p2;
32
33 import :p1;
34
35 namespace nn {
36 template<typename T>
37 class Incognita
38 {
39 public:
40 Incognita(const Variable<T> &) {}
41 };
42 }
43
44 //--- m.cppm
45 export module m;
46
47 export import :p1;
48 export import :p2;
49
50 //--- use.cpp
51 // expected-no-diagnostics
52 import m;
53
54 auto foo()
55 {
56 nn::Variable<double> x;
57
58 return x.foo();
59 }