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 //--- foo.h 9 #ifndef FOO_H 10 #define FOO_H 11 template <typename T> 12 struct base {}; 13 14 template <typename T> 15 struct foo; 16 17 template <typename T> 18 struct foo {}; 19 20 template <> 21 struct foo<int> : base<int> { 22 int getInt(); 23 }; 24 #endif // FOO_H 25 26 //--- X.cppm 27 module; 28 #include "foo.h" 29 export module X; 30 export template <class T> 31 class X { 32 foo<int> x; 33 34 public: print()35 int print() { 36 return x.getInt(); 37 } 38 }; 39 40 //--- Use.cpp 41 import X; 42 foo<int> f; // expected-error {{'foo' must be declared before it is used}} 43 // expected-note@* {{declaration here is not visible}} bar()44int bar() { 45 X<int> x; 46 return x.print(); 47 } 48