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