[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Modules / explicitly-specialized-template.cpp
blob2450bbe31bd9b76e178869aa768a78d11c785770
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/X.cppm -emit-module-interface -o %t/X.pcm
6 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -fsyntax-only -verify
7 //
8 // RUN: %clang_cc1 -std=c++20 %t/X.cppm -emit-reduced-module-interface -o %t/X.pcm
9 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -fsyntax-only -verify
11 //--- foo.h
12 #ifndef FOO_H
13 #define FOO_H
14 template <typename T>
15 struct base {};
17 template <typename T>
18 struct foo;
20 template <typename T>
21 struct foo {};
23 template <>
24 struct foo<int> : base<int> {
25 int getInt();
27 #endif // FOO_H
29 //--- X.cppm
30 module;
31 #include "foo.h"
32 export module X;
33 export template <class T>
34 class X {
35 foo<int> x;
37 public:
38 int print() {
39 return x.getInt();
43 //--- Use.cpp
44 import X;
45 foo<int> f; // expected-error {{'foo' must be declared before it is used}}
46 // expected-note@* {{declaration here is not visible}}
47 int bar() {
48 X<int> x;
49 return x.print();