blob: 39dfb0b32a2fbe9baa6b1bb9397d13eb414b822e [file] [log] [blame]
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor2a72edd2009-03-10 18:52:44 +00002template<typename T> struct A; // expected-note 4{{template is declared here}}
Douglas Gregor4ea568f2009-03-10 18:03:33 +00003
Douglas Gregor65b2c4c2009-03-10 18:33:27 +00004template<typename T> struct B : A<T*> { }; // expected-error{{implicit instantiation of undefined template}} \
John McCall85f90552010-03-10 11:27:22 +00005// expected-error{{implicit instantiation of undefined template 'A<X *>'}}
Douglas Gregor4ea568f2009-03-10 18:03:33 +00006
7template<typename T> struct C : B<T> { } ; // expected-note{{instantiation of template class}}
8
9template<typename T> struct D : C<T> { }; // expected-note{{instantiation of template class}}
10
11template<typename T> struct E : D<T> { }; // expected-note{{instantiation of template class}}
12
13template<typename T> struct F : E<T(T)> { }; // expected-note{{instantiation of template class}}
14
15void f() {
16 (void)sizeof(F<int>); // expected-note{{instantiation of template class}}
17}
Douglas Gregor65b2c4c2009-03-10 18:33:27 +000018
19typedef struct { } X;
20
21void g() {
John McCall85f90552010-03-10 11:27:22 +000022 (void)sizeof(B<X>); // expected-note{{in instantiation of template class 'B<X>' requested here}}
Douglas Gregor65b2c4c2009-03-10 18:33:27 +000023}
Douglas Gregor2a72edd2009-03-10 18:52:44 +000024
25template<typename T>
John McCall85f90552010-03-10 11:27:22 +000026struct G : A<T>, // expected-error{{implicit instantiation of undefined template 'A<int>'}}
27 A<T*> // expected-error{{implicit instantiation of undefined template 'A<int *>'}}
Douglas Gregor2a72edd2009-03-10 18:52:44 +000028 { };
29
30void h() {
John McCall85f90552010-03-10 11:27:22 +000031 (void)sizeof(G<int>); // expected-note{{in instantiation of template class 'G<int>' requested here}}
Douglas Gregor2a72edd2009-03-10 18:52:44 +000032}
Richard Smith80934652012-07-16 01:09:10 +000033
34namespace PR13365 {
35 template <class T> class ResultTy { // expected-warning {{does not declare any constructor}}
36 T t; // expected-note {{reference member 't' will never be initialized}}
37 };
38
39 template <class T1, class T2>
40 typename ResultTy<T2>::error Deduce( void (T1::*member)(T2) ) {} // \
41 // expected-note {{instantiation of template class 'PR13365::ResultTy<int &>'}} \
Richard Smith80934652012-07-16 01:09:10 +000042 // expected-note {{substitution failure [with T1 = PR13365::Cls, T2 = int &]}}
43
44 struct Cls {
45 void method(int&);
46 };
47 void test() {
Nick Lewycky56412332014-01-11 02:37:12 +000048 Deduce(&Cls::method); // expected-error {{no matching function}} \
49 // expected-note {{substituting deduced template arguments into function template 'Deduce' [with T1 = PR13365::Cls, T2 = int &]}}
Richard Smith80934652012-07-16 01:09:10 +000050 }
51}