1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc namespace N1 { 4*f4a2713aSLionel Sambuc struct X0 { }; 5*f4a2713aSLionel Sambuc 6*f4a2713aSLionel Sambuc int& f0(X0); 7*f4a2713aSLionel Sambuc } 8*f4a2713aSLionel Sambuc 9*f4a2713aSLionel Sambuc namespace N2 { 10*f4a2713aSLionel Sambuc char& f0(char); 11*f4a2713aSLionel Sambuc 12*f4a2713aSLionel Sambuc template<typename T, typename Result> 13*f4a2713aSLionel Sambuc struct call_f0 { test_f0N2::call_f014*f4a2713aSLionel Sambuc void test_f0(T t) { 15*f4a2713aSLionel Sambuc Result result = f0(t); 16*f4a2713aSLionel Sambuc } 17*f4a2713aSLionel Sambuc }; 18*f4a2713aSLionel Sambuc } 19*f4a2713aSLionel Sambuc 20*f4a2713aSLionel Sambuc template struct N2::call_f0<int, char&>; 21*f4a2713aSLionel Sambuc template struct N2::call_f0<N1::X0, int&>; 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc namespace N3 { 24*f4a2713aSLionel Sambuc template<typename T, typename Result> 25*f4a2713aSLionel Sambuc struct call_f0 { test_f0N3::call_f026*f4a2713aSLionel Sambuc void test_f0(T t) { 27*f4a2713aSLionel Sambuc Result &result = f0(t); // expected-error {{undeclared identifier}} \ 28*f4a2713aSLionel Sambuc expected-error {{neither visible in the template definition nor found by argument-dependent lookup}} 29*f4a2713aSLionel Sambuc } 30*f4a2713aSLionel Sambuc }; 31*f4a2713aSLionel Sambuc } 32*f4a2713aSLionel Sambuc 33*f4a2713aSLionel Sambuc template struct N3::call_f0<int, char&>; // expected-note{{instantiation}} 34*f4a2713aSLionel Sambuc template struct N3::call_f0<N1::X0, int&>; 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambuc short& f0(char); // expected-note {{should be declared prior to the call site}} 37*f4a2713aSLionel Sambuc namespace N4 { 38*f4a2713aSLionel Sambuc template<typename T, typename Result> 39*f4a2713aSLionel Sambuc struct call_f0 { test_f0N4::call_f040*f4a2713aSLionel Sambuc void test_f0(T t) { 41*f4a2713aSLionel Sambuc Result &result = f0(t); 42*f4a2713aSLionel Sambuc } 43*f4a2713aSLionel Sambuc }; 44*f4a2713aSLionel Sambuc } 45*f4a2713aSLionel Sambuc 46*f4a2713aSLionel Sambuc template struct N4::call_f0<int, short&>; 47*f4a2713aSLionel Sambuc template struct N4::call_f0<N1::X0, int&>; 48*f4a2713aSLionel Sambuc template struct N3::call_f0<int, short&>; // expected-note{{instantiation}} 49*f4a2713aSLionel Sambuc 50*f4a2713aSLionel Sambuc // FIXME: test overloaded function call operators, calls to member 51*f4a2713aSLionel Sambuc // functions, etc. 52