1 // RUN: rm -rf %t 2 // RUN: mkdir -p %t 3 // RUN: split-file %s %t 4 // RUN: cd %t 5 // 6 // RUN: %clang_cc1 -std=c++20 M.cpp -emit-module-interface -o M.pcm 7 // RUN: %clang_cc1 -std=c++20 N.cpp -emit-module-interface -o N.pcm \ 8 // RUN: -fmodule-file=M=M.pcm 9 // RUN: %clang_cc1 -std=c++20 Q.cpp -emit-module-interface -o Q.pcm 10 // RUN: %clang_cc1 -std=c++20 Q-impl.cpp -fsyntax-only -fmodule-file=Q=Q.pcm \ 11 // RUN: -fmodule-file=N=N.pcm -fmodule-file=M=M.pcm -verify 12 13 //--- M.cpp 14 export module M; 15 namespace R { 16 export struct X {}; 17 export void f(X); 18 } // namespace R 19 namespace S { 20 export void f(R::X, R::X); 21 } 22 23 //--- N.cpp 24 export module N; 25 import M; 26 export R::X make(); 27 namespace R { 28 static int g(X); 29 } 30 export template <typename T, typename U> 31 void apply(T t, U u) { 32 f(t, u); 33 g(t); 34 } 35 36 //--- Q.cpp 37 export module Q; 38 39 //--- Q-impl.cpp 40 module Q; 41 import N; 42 43 namespace S { 44 struct Z { 45 template <typename T> operator T(); 46 }; 47 } // namespace S 48 void test() { 49 // OK, decltype(x) is R::X in module M 50 auto x = make(); 51 52 // error: R and R::f are not visible here 53 R::f(x); // expected-error {{no type named 'f' in namespace 'R'}} 54 55 f(x); // Found by [basic.lookup.argdep] / p4.3 56 57 // error: S::f in module M not considered even though S is an associated 58 // namespace, since the entity Z is in a different module from f. 59 f(x, S::Z()); // expected-error {{no matching function for call to 'f'}} 60 // expected-note@M.cpp:4 {{candidate function not viable: requires 1 argument, but 2 were provided}} 61 62 // error: S::f is visible in instantiation context, but R::g has internal 63 // linkage and cannot be used outside N.cpp 64 apply(x, S::Z()); // expected-error@N.cpp:10 {{use of undeclared identifier 'g'}} 65 // expected-note@-1 {{requested here}} 66 } 67