| 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 |
// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/foo.cppm -o %t/foo.pcm |
| 9 |
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify -fsyntax-only -DREDUCED |
| 10 |
|
| 11 |
//--- foo.cppm |
| 12 |
module; |
| 13 |
# 3 __FILE__ 1 // use the next physical line number here (and below) |
| 14 |
template <typename T> |
| 15 |
void foo() { |
| 16 |
} |
| 17 |
|
| 18 |
template <> |
| 19 |
void foo<int>() { |
| 20 |
} |
| 21 |
|
| 22 |
template <typename T> |
| 23 |
void foo2() { |
| 24 |
} |
| 25 |
|
| 26 |
template <> |
| 27 |
void foo2<int>() { |
| 28 |
} |
| 29 |
|
| 30 |
template <typename T> |
| 31 |
void foo3() { |
| 32 |
} |
| 33 |
|
| 34 |
template <> |
| 35 |
void foo3<int>(); |
| 36 |
|
| 37 |
export module foo; |
| 38 |
export using ::foo; |
| 39 |
export using ::foo3; |
| 40 |
|
| 41 |
export template <typename T> |
| 42 |
void foo4() { |
| 43 |
} |
| 44 |
|
| 45 |
export template <> |
| 46 |
void foo4<int>() { |
| 47 |
} |
| 48 |
|
| 49 |
//--- Use.cpp |
| 50 |
import foo; |
| 51 |
void use() { |
| 52 |
foo<short>(); |
| 53 |
foo<int>(); |
| 54 |
#ifdef REDUCED |
| 55 |
// In reduced BMI, the foo2 template function is optimized out. |
| 56 |
foo2<short>(); // expected-error {{use of undeclared identifier 'foo2'}} |
| 57 |
foo2<int>(); // expected-error {{use of undeclared identifier 'foo2'}} |
| 58 |
#else |
| 59 |
foo2<short>(); // expected-error {{missing '#include'; 'foo2' must be declared before it is used}} |
| 60 |
// expected-note@* {{declaration here is not visible}} |
| 61 |
foo2<int>(); // expected-error {{missing '#include'; 'foo2' must be declared before it is used}} |
| 62 |
// expected-note@* {{declaration here is not visible}} |
| 63 |
#endif |
| 64 |
foo3<short>(); |
| 65 |
foo3<int>(); |
| 66 |
|
| 67 |
foo4<short>(); |
| 68 |
foo4<int>(); |
| 69 |
} |