1 // RUN: %clang_cc1 -fsyntax-only -verify %s -pedantic
2 template<typename T>
3 struct S {
SS4  S() { }
5 };
6 
7 template<typename T>
8 struct vector {
push_backvector9   void push_back(const T&) { int a[sizeof(T) ? -1: -1]; } // expected-error {{array with a negative size}}
10 };
11 
12 class ExprEngine {
13 public:
14  typedef vector<S<void *> >CheckersOrdered;
15  CheckersOrdered Checkers;
16 
17  template <typename CHECKER>
registerCheck(CHECKER * check)18  void registerCheck(CHECKER *check) {
19    Checkers.push_back(S<void *>()); // expected-note {{in instantiation of member function 'vector<S<void *> >::push_back' requested here}}
20  }
21 };
22 
23 class RetainReleaseChecker { };
24 
f(ExprEngine & Eng)25 void f(ExprEngine& Eng) {
26    Eng.registerCheck(new RetainReleaseChecker); // expected-note {{in instantiation of function template specialization 'ExprEngine::registerCheck<RetainReleaseChecker>' requested here}}
27 }
28 
29 // PR 5838
30 namespace test1 {
31   template<typename T> struct A {
32     int a;
33   };
34 
35   template<typename T> struct B : A<float>, A<T> {
ftest1::B36     void f() {
37       a = 0; // should not be ambiguous
38     }
39   };
40   template struct B<int>;
41 
42   struct O {
43     int a;
44     template<typename T> struct B : A<T> {
ftest1::O::B45       void f() {
46         a = 0; // expected-error {{'test1::O::a' is not a member of class 'test1::O::B<int>'}}
47       }
48     };
49   };
50   template struct O::B<int>; // expected-note {{in instantiation}}
51 }
52 
53 // PR7248
54 namespace test2 {
55   template <class T> struct A {
footest2::A56     void foo() {
57       T::bar(); // expected-error {{type 'int' cannot}}
58     }
59   };
60 
61   template <class T> class B {
foo(A<T> a)62     void foo(A<T> a) {
63       a.test2::template A<T>::foo(); // expected-note {{in instantiation}}
64     }
65   };
66 
67   template class B<int>;
68 }
69 
70 namespace PR14124 {
71   template<typename T> struct S {
72     int value;
73   };
f()74   template<typename T> void f() { S<T>::value; } // expected-error {{invalid use of non-static data member 'value'}}
75   template void f<int>(); // expected-note {{in instantiation of}}
76 
77   struct List { List *next; };
78   template<typename T, T *(T::*p) = &T::next> struct A {};
79   A<List> a; // ok
80   void operator&(struct Whatever);
81   template<typename T, T *(T::*p) = &T::next> struct B {};
82   B<List> b; // still ok
83 }
84