51 lines · cpp
1// RUN: rm -rf %t2// RUN: mkdir -p %t3// RUN: split-file %s %t4//5// RUN: %clang_cc1 -std=c++20 %t/X.cppm -emit-module-interface -o %t/X.pcm6// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -fsyntax-only -verify7//8// RUN: %clang_cc1 -std=c++20 %t/X.cppm -emit-reduced-module-interface -o %t/X.pcm9// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -fsyntax-only -verify10//11//--- foo.h12#ifndef FOO_H13#define FOO_H14template <typename T>15struct base {};16 17template <typename T>18struct foo;19 20template <typename T>21struct foo {};22 23template <>24struct foo<int> : base<int> {25 int getInt();26};27#endif // FOO_H28 29//--- X.cppm30module;31#include "foo.h"32export module X;33export template <class T>34class X {35 foo<int> x;36 37public:38 int print() {39 return x.getInt();40 }41};42 43//--- Use.cpp44import X;45foo<int> f; // expected-error {{'foo' must be declared before it is used}}46 // expected-note@* {{declaration here is not visible}}47int bar() {48 X<int> x;49 return x.print();50}51