annotate clang/test/SemaTemplate/instantiation-backtrace.cpp @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
2 template<typename T> struct A; // expected-note 4{{template is declared here}}
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 template<typename T> struct B : A<T*> { }; // expected-error{{implicit instantiation of undefined template}} \
anatofuz
parents:
diff changeset
5 // expected-error{{implicit instantiation of undefined template 'A<X *>'}}
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 template<typename T> struct C : B<T> { } ; // expected-note{{instantiation of template class}}
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 template<typename T> struct D : C<T> { }; // expected-note{{instantiation of template class}}
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 template<typename T> struct E : D<T> { }; // expected-note{{instantiation of template class}}
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 template<typename T> struct F : E<T(T)> { }; // expected-note{{instantiation of template class}}
anatofuz
parents:
diff changeset
14
anatofuz
parents:
diff changeset
15 void f() {
anatofuz
parents:
diff changeset
16 (void)sizeof(F<int>); // expected-note{{instantiation of template class}}
anatofuz
parents:
diff changeset
17 }
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 typedef struct { } X;
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 void g() {
anatofuz
parents:
diff changeset
22 (void)sizeof(B<X>); // expected-note{{in instantiation of template class 'B<X>' requested here}}
anatofuz
parents:
diff changeset
23 }
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 template<typename T>
anatofuz
parents:
diff changeset
26 struct G : A<T>, // expected-error{{implicit instantiation of undefined template 'A<int>'}}
anatofuz
parents:
diff changeset
27 A<T*> // expected-error{{implicit instantiation of undefined template 'A<int *>'}}
anatofuz
parents:
diff changeset
28 { };
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 void h() {
anatofuz
parents:
diff changeset
31 (void)sizeof(G<int>); // expected-note{{in instantiation of template class 'G<int>' requested here}}
anatofuz
parents:
diff changeset
32 }
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 namespace PR13365 {
anatofuz
parents:
diff changeset
35 template <class T> class ResultTy { // expected-warning {{does not declare any constructor}}
anatofuz
parents:
diff changeset
36 T t; // expected-note {{reference member 't' will never be initialized}}
anatofuz
parents:
diff changeset
37 };
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 template <class T1, class T2>
anatofuz
parents:
diff changeset
40 typename ResultTy<T2>::error Deduce( void (T1::*member)(T2) ) {} // \
anatofuz
parents:
diff changeset
41 // expected-note {{instantiation of template class 'PR13365::ResultTy<int &>'}} \
anatofuz
parents:
diff changeset
42 // expected-note {{substitution failure [with T1 = PR13365::Cls, T2 = int &]}}
anatofuz
parents:
diff changeset
43
anatofuz
parents:
diff changeset
44 struct Cls {
anatofuz
parents:
diff changeset
45 void method(int&);
anatofuz
parents:
diff changeset
46 };
anatofuz
parents:
diff changeset
47 void test() {
anatofuz
parents:
diff changeset
48 Deduce(&Cls::method); // expected-error {{no matching function}} \
anatofuz
parents:
diff changeset
49 // expected-note {{substituting deduced template arguments into function template 'Deduce' [with T1 = PR13365::Cls, T2 = int &]}}
anatofuz
parents:
diff changeset
50 }
anatofuz
parents:
diff changeset
51 }