xref: /aosp_15_r20/external/clang/test/SemaTemplate/instantiation-backtrace.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s
2*67e74705SXin Li template<typename T> struct A; // expected-note 4{{template is declared here}}
3*67e74705SXin Li 
4*67e74705SXin Li template<typename T> struct B : A<T*> { }; // expected-error{{implicit instantiation of undefined template}} \
5*67e74705SXin Li // expected-error{{implicit instantiation of undefined template 'A<X *>'}}
6*67e74705SXin Li 
7*67e74705SXin Li template<typename T> struct C : B<T> { } ; // expected-note{{instantiation of template class}}
8*67e74705SXin Li 
9*67e74705SXin Li template<typename T> struct D : C<T> { }; // expected-note{{instantiation of template class}}
10*67e74705SXin Li 
11*67e74705SXin Li template<typename T> struct E : D<T> { }; // expected-note{{instantiation of template class}}
12*67e74705SXin Li 
13*67e74705SXin Li template<typename T> struct F : E<T(T)> { }; // expected-note{{instantiation of template class}}
14*67e74705SXin Li 
f()15*67e74705SXin Li void f() {
16*67e74705SXin Li  (void)sizeof(F<int>); // expected-note{{instantiation of template class}}
17*67e74705SXin Li }
18*67e74705SXin Li 
19*67e74705SXin Li typedef struct { } X;
20*67e74705SXin Li 
g()21*67e74705SXin Li void g() {
22*67e74705SXin Li   (void)sizeof(B<X>); // expected-note{{in instantiation of template class 'B<X>' requested here}}
23*67e74705SXin Li }
24*67e74705SXin Li 
25*67e74705SXin Li template<typename T>
26*67e74705SXin Li struct G : A<T>, // expected-error{{implicit instantiation of undefined template 'A<int>'}}
27*67e74705SXin Li   A<T*> // expected-error{{implicit instantiation of undefined template 'A<int *>'}}
28*67e74705SXin Li   { };
29*67e74705SXin Li 
h()30*67e74705SXin Li void h() {
31*67e74705SXin Li   (void)sizeof(G<int>); // expected-note{{in instantiation of template class 'G<int>' requested here}}
32*67e74705SXin Li }
33*67e74705SXin Li 
34*67e74705SXin Li namespace PR13365 {
35*67e74705SXin Li   template <class T> class ResultTy { // expected-warning {{does not declare any constructor}}
36*67e74705SXin Li     T t; // expected-note {{reference member 't' will never be initialized}}
37*67e74705SXin Li   };
38*67e74705SXin Li 
39*67e74705SXin Li   template <class T1, class T2>
Deduce(void (T1::* member)(T2))40*67e74705SXin Li     typename ResultTy<T2>::error Deduce( void (T1::*member)(T2) ) {} // \
41*67e74705SXin Li     // expected-note {{instantiation of template class 'PR13365::ResultTy<int &>'}} \
42*67e74705SXin Li     // expected-note {{substitution failure [with T1 = PR13365::Cls, T2 = int &]}}
43*67e74705SXin Li 
44*67e74705SXin Li   struct Cls {
45*67e74705SXin Li     void method(int&);
46*67e74705SXin Li   };
test()47*67e74705SXin Li   void test() {
48*67e74705SXin Li     Deduce(&Cls::method); // expected-error {{no matching function}} \
49*67e74705SXin Li                           // expected-note {{substituting deduced template arguments into function template 'Deduce' [with T1 = PR13365::Cls, T2 = int &]}}
50*67e74705SXin Li   }
51*67e74705SXin Li }
52