1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 
3 namespace PR8640 {
4   template<class T1> struct C1 {
c1PR8640::C15     virtual void c1() {
6       T1 t1 = 3;  // expected-error {{cannot initialize a variable}}
7     }
8   };
9 
10   template<class T2> struct C2 {
c2PR8640::C211     void c2() {
12       new C1<T2>();  // expected-note {{in instantiation of member function}}
13     }
14   };
15 
f()16   void f() {
17     C2<int*> c2;
18     c2.c2();  // expected-note {{in instantiation of member function}}
19   }
20 }
21 
22 namespace PR9325 {
23   template<typename T>
24   class Target
25   {
26   public:
Value() const27     virtual T Value() const
28     {
29       return 1; // expected-error{{cannot initialize return object of type 'int *' with an rvalue of type 'int'}}
30     }
31   };
32 
33   template<typename T>
34   struct Provider
35   {
36     static Target<T> Instance;
37   };
38 
39   template<typename T>
40   Target<T> Provider<T>::Instance; // expected-note{{in instantiation of}}
41 
f()42   void f()
43   {
44     Target<int*>* traits = &Provider<int*>::Instance; // expected-note{{requested here}}
45   }
46 }
47 
48 namespace PR10020 {
49   struct MG {
50     virtual void Accept(int) = 0;
51   };
52 
53   template <typename Type>
54   struct GMG : MG {
AcceptPR10020::GMG55     void Accept(int i) {
56       static_cast<Type *>(0)->Accept(i); // expected-error{{member reference base}}
57     }
MethodPR10020::GMG58     static GMG* Method() { return &singleton; } // expected-note{{in instantiation of}}
59     static GMG singleton;
60   };
61 
62   template <typename Type>
63   GMG<Type> GMG<Type>::singleton; // expected-note{{requested here}}
64 
test(void)65   void test(void) {
66     GMG<int>::Method(); // expected-note{{in instantiation of}}
67   }
68 }
69