Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Modules / template-function-specialization.cpp
blob3eac92e7edb94c917c00c32baf1f50ea8e514f55
1 // RUN: rm -fr %t
2 // RUN: mkdir %t
3 // RUN: split-file %s %t
4 //
5 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/foo.cppm -o %t/foo.pcm
6 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify -fsyntax-only
7 //
8 //--- foo.cppm
9 module;
10 # 3 __FILE__ 1 // use the next physical line number here (and below)
11 template <typename T>
12 void foo() {
15 template <>
16 void foo<int>() {
19 template <typename T>
20 void foo2() {
23 template <>
24 void foo2<int>() {
27 template <typename T>
28 void foo3() {
31 template <>
32 void foo3<int>();
34 export module foo;
35 export using ::foo;
36 export using ::foo3;
38 export template <typename T>
39 void foo4() {
42 export template <>
43 void foo4<int>() {
46 //--- Use.cpp
47 import foo;
48 void use() {
49 foo<short>();
50 foo<int>();
51 foo2<short>(); // expected-error {{missing '#include'; 'foo2' must be declared before it is used}}
52 // expected-note@* {{declaration here is not visible}}
53 foo2<int>(); // expected-error {{missing '#include'; 'foo2' must be declared before it is used}}
54 // expected-note@* {{declaration here is not visible}}
55 foo3<short>();
56 foo3<int>();
58 foo4<short>();
59 foo4<int>();