1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc // This is the function actually selected during overload resolution, and the 4*f4a2713aSLionel Sambuc // only one defined. f(T *,int)5*f4a2713aSLionel Sambuctemplate <typename T> void f(T*, int) {} 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc template <typename T> struct S; 8*f4a2713aSLionel Sambuc template <typename T> struct S_ : S<T> { typedef int type; }; // expected-note{{in instantiation}} 9*f4a2713aSLionel Sambuc template <typename T> struct S { 10*f4a2713aSLionel Sambuc // Force T to have a complete type here so we can observe instantiations with 11*f4a2713aSLionel Sambuc // incomplete types. 12*f4a2713aSLionel Sambuc T t; // expected-error{{field has incomplete type}} 13*f4a2713aSLionel Sambuc }; 14*f4a2713aSLionel Sambuc 15*f4a2713aSLionel Sambuc // Provide a bad class and an overload that instantiates templates with it. 16*f4a2713aSLionel Sambuc class NoDefinition; // expected-note{{forward declaration}} 17*f4a2713aSLionel Sambuc template <typename T> S_<NoDefinition>::type f(T*, NoDefinition*); // expected-note{{in instantiation}} 18*f4a2713aSLionel Sambuc test(int x)19*f4a2713aSLionel Sambucvoid test(int x) { 20*f4a2713aSLionel Sambuc f(&x, 0); 21*f4a2713aSLionel Sambuc } 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc // Ensure that we instantiate an overloaded function if it's selected by 24*f4a2713aSLionel Sambuc // overload resolution when initializing a function pointer. 25*f4a2713aSLionel Sambuc template<typename T> struct X { fX26*f4a2713aSLionel Sambuc static T f() { T::error; } // expected-error {{has no members}} 27*f4a2713aSLionel Sambuc static T f(bool); 28*f4a2713aSLionel Sambuc }; 29*f4a2713aSLionel Sambuc void (*p)() = &X<void>::f; // expected-note {{instantiation of}} 30*f4a2713aSLionel Sambuc 31*f4a2713aSLionel Sambuc namespace PR13098 { 32*f4a2713aSLionel Sambuc struct A { 33*f4a2713aSLionel Sambuc A(int); operator ++PR13098::A34*f4a2713aSLionel Sambuc void operator++() {} operator +PR13098::A35*f4a2713aSLionel Sambuc void operator+(int) {} operator +PR13098::A36*f4a2713aSLionel Sambuc void operator+(A) {} operator []PR13098::A37*f4a2713aSLionel Sambuc void operator[](int) {} operator []PR13098::A38*f4a2713aSLionel Sambuc void operator[](A) {} 39*f4a2713aSLionel Sambuc }; 40*f4a2713aSLionel Sambuc struct B : A { 41*f4a2713aSLionel Sambuc using A::operator++; 42*f4a2713aSLionel Sambuc using A::operator+; 43*f4a2713aSLionel Sambuc using A::operator[]; 44*f4a2713aSLionel Sambuc }; f(B b)45*f4a2713aSLionel Sambuc template<typename T> void f(B b) { 46*f4a2713aSLionel Sambuc ++b; 47*f4a2713aSLionel Sambuc b + 0; 48*f4a2713aSLionel Sambuc b[0]; 49*f4a2713aSLionel Sambuc } 50*f4a2713aSLionel Sambuc template void f<void>(B); 51*f4a2713aSLionel Sambuc } 52