1// RUN: rm -rf %t 2// RUN: mkdir %t 3// RUN: split-file %s %t 4 5// RUN: %clang_cc1 -std=c++20 %t/std-10-4-ex2-interface.cppm -emit-reduced-module-interface \ 6// RUN: -o %t/M.pcm -Wno-unused-value 7// RUN: %clang_cc1 -std=c++20 %t/std-10-4-ex2-implementation.cpp -fmodule-file=M=%t/M.pcm \ 8// RUN: -fsyntax-only -verify -Wno-unused-value 9 10//--- std-10-4-ex2.h 11 12namespace N { 13struct X {}; 14int d(); 15int e(); 16inline int f(X, int = d()) { return e(); } 17int g(X); 18int h(X); 19} // namespace N 20 21//--- std-10-4-ex2-interface.cppm 22module; 23#include "std-10-4-ex2.h" 24export module M; 25 26template <typename T> int use_f() { 27 N::X x; // N::X, N, and :: are decl-reachable from use_f 28 return f(x, 123); // N::f is decl-reachable from use_f, 29 // N::e is indirectly decl-reachable from use_f 30 // because it is decl-reachable from N::f, and 31 // N::d is decl-reachable from use_f 32 // because it is decl-reachable from N::f 33 // even though it is not used in this call 34} 35 36template <typename T> int use_g() { 37 N::X x; // N::X, N, and :: are decl-reachable from use_g 38 return g((T(), x)); // N::g is not decl-reachable from use_g 39} 40 41template <typename T> int use_h() { 42 N::X x; // N::X, N, and :: are decl-reachable from use_h 43 return h((T(), x)); // N::h is not decl-reachable from use_h, but 44 // N::h is decl-reachable from use_h<int> 45} 46 47int k = use_h<int>(); 48// use_h<int> is decl-reachable from k, so 49// N::h is decl-reachable from k 50 51//--- std-10-4-ex2-implementation.cpp 52module M; 53 54int a = use_f<int>(); 55int b = use_g<int>(); 56// expected-error@std-10-4-ex2-interface.cppm:17 {{use of undeclared identifier 'g'}} 57// expected-note@-2 {{in instantiation of function template specialization 'use_g<int>' requested here}} 58int c = use_h<int>(); 59