brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · d5d7d7e Raw
70 lines · cpp
1// RUN: rm -fr %t2// RUN: mkdir %t3// RUN: split-file %s %t4//5// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/foo.cppm -o %t/foo.pcm6// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify -fsyntax-only7 8// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/foo.cppm -o %t/foo.pcm9// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify -fsyntax-only -DREDUCED10 11//--- foo.cppm12module;13# 3 __FILE__ 1 // use the next physical line number here (and below)14template <typename T>15void foo() {16}17 18template <>19void foo<int>() {20}21 22template <typename T>23void foo2() {24}25 26template <>27void foo2<int>() {28}29 30template <typename T>31void foo3() {32}33 34template <>35void foo3<int>();36 37export module foo;38export using ::foo;39export using ::foo3;40 41export template <typename T>42void foo4() {43}44 45export template <>46void foo4<int>() {47}48 49//--- Use.cpp50import foo;51void use() {52  foo<short>();53  foo<int>();54#ifdef REDUCED55  // 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#else59  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#endif64  foo3<short>();65  foo3<int>();66 67  foo4<short>();68  foo4<int>();69}70