blob: 1efd2a5844e8877e38855afe3de0e6d2779b27f6 [file] [log] [blame]
Douglas Gregor15d6c2f2010-05-07 23:12:07 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Stephen Hines176edba2014-12-01 14:53:08 -08002// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
Douglas Gregor15d6c2f2010-05-07 23:12:07 +00003template<typename T>
4struct X1 {
5 static void member() { T* x = 1; } // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
6};
7
8template<void(*)()> struct instantiate { };
9
10template<typename T>
11struct X2 {
12 typedef instantiate<&X1<int>::member> i; // expected-note{{in instantiation of}}
13};
14
Stephen Hines176edba2014-12-01 14:53:08 -080015X2<int> x;
16
17template <class T, class A> class C {
18public:
19 int i;
20 void f(T &t) {
21 T *q = new T();
22 t.T::~T();
23 q->~T();
Stephen Hines0e2c34f2015-03-23 12:09:02 -070024 // expected-error@+2 {{'int' is not a class, namespace, or enumeration}}
Stephen Hines176edba2014-12-01 14:53:08 -080025 // expected-error@+1 {{no member named '~Colors' in 'Colors'}}
26 q->A::~A();
27 // expected-error@+2 {{no member named '~int' in 'Q'}}
28 // expected-error@+1 {{no member named '~Colors' in 'Q'}}
29 q->~A();
30
31 delete q;
32 }
33};
34
35class Q {
36public:
37 Q() {}
38 ~Q() {}
39};
40
41enum Colors {red, green, blue};
42
43C<Q, int> dummy;
44C<Q, Colors> dummyColors;
45int main() {
46 Q qinst;
47 // expected-note@+1 {{in instantiation of member function 'C<Q, int>::f' requested here}}
48 dummy.f(qinst);
49 // expected-note@+1 {{in instantiation of member function 'C<Q, Colors>::f' requested here}}
50 dummyColors.f(qinst);
51}
52