instantiation-backtrace.cpp 2.0 KB

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