brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · c200aba Raw
67 lines · cpp
1// RUN: rm -rf %t2// RUN: mkdir -p %t3// RUN: split-file %s %t4// RUN: cd %t5//6// RUN: %clang_cc1 -std=c++20 M.cpp -emit-module-interface -o M.pcm7// RUN: %clang_cc1 -std=c++20 N.cpp -emit-module-interface -o N.pcm \8// RUN:   -fmodule-file=M=M.pcm9// RUN: %clang_cc1 -std=c++20 Q.cpp -emit-module-interface -o Q.pcm10// 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 -verify12 13//--- M.cpp14export module M;15namespace R {16export struct X {};17export void f(X);18} // namespace R19namespace S {20export void f(R::X, R::X);21}22 23//--- N.cpp24export module N;25import M;26export R::X make();27namespace R {28static int g(X);29}30export template <typename T, typename U>31void apply(T t, U u) {32  f(t, u);33  g(t);34}35 36//--- Q.cpp37export module Q;38 39//--- Q-impl.cpp40module Q;41import N;42 43namespace S {44struct Z {45  template <typename T> operator T();46};47} // namespace S48void test() {49  // OK, decltype(x) is R::X in module M50  auto x = make();51 52  // error: R and R::f are not visible here53  R::f(x); // expected-error {{no type named 'f' in namespace 'R'}}54 55  f(x); // Found by [basic.lookup.argdep] / p4.356 57  // error: S::f in module M not considered even though S is an associated58  // 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 internal63  // linkage and cannot be used outside N.cpp64  apply(x, S::Z()); // expected-error@N.cpp:10 {{use of undeclared identifier 'g'}}65                    // expected-note@-1 {{requested here}}66}67