blob: 9edefe8b63e014461173be828108e0e76c373c11 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor3b6afbb2009-09-09 00:23:06 +00002template<typename U, typename T>
3U f0(T t) {
4 return t.template get<U>();
5}
6
7template<typename U, typename T>
8int &f1(T t) {
9 // FIXME: When we pretty-print this, we lose the "template" keyword.
10 return t.U::template get<int&>();
11}
12
13struct X {
14 template<typename T> T get();
15};
16
17void test_f0(X x) {
18 int i = f0<int>(x);
19 int &ir = f0<int&>(x);
20}
21
22struct XDerived : public X {
23};
24
25void test_f1(XDerived xd) {
Douglas Gregor6cd21982009-10-20 05:58:46 +000026 int &ir = f1<X>(xd);
Douglas Gregor3b6afbb2009-09-09 00:23:06 +000027}
28
Douglas Gregordd62b152009-10-19 22:04:39 +000029// PR5213
30template <class T>
31struct A {};
32
33template<class T>
34class B
35{
36 A<T> a_;
37
38public:
39 void destroy();
40};
41
42template<class T>
43void
44B<T>::destroy()
45{
46 a_.~A<T>();
47}
48
49void do_destroy_B(B<int> b) {
50 b.destroy();
51}
Douglas Gregor3eefb1c2009-10-24 04:59:53 +000052
53struct X1 {
54 int* f1(int);
55 template<typename T> float* f1(T);
56
57 static int* f2(int);
58 template<typename T> static float* f2(T);
59};
60
61void test_X1(X1 x1) {
62 float *fp1 = x1.f1<>(17);
63 float *fp2 = x1.f1<int>(3.14);
64 int *ip1 = x1.f1(17);
65 float *ip2 = x1.f1(3.14);
66
67 float* (X1::*mf1)(int) = &X1::f1;
68 float* (X1::*mf2)(int) = &X1::f1<>;
69 float* (X1::*mf3)(float) = &X1::f1<float>;
70
71 float* (*fp3)(int) = &X1::f2;
72 float* (*fp4)(int) = &X1::f2<>;
73 float* (*fp5)(float) = &X1::f2<float>;
74 float* (*fp6)(int) = X1::f2;
75 float* (*fp7)(int) = X1::f2<>;
76 float* (*fp8)(float) = X1::f2<float>;
77}
Douglas Gregor550d9b22009-10-31 17:21:17 +000078
79template<int A> struct X2 {
80 int m;
81};
82
83template<typename T>
84struct X3 : T { };
85
86template<typename T>
87struct X4 {
88 template<typename U>
89 void f(X2<sizeof(X3<U>().U::m)>);
90};
91
92void f(X4<X3<int> > x4i) {
93 X2<sizeof(int)> x2;
94 x4i.f<X2<sizeof(int)> >(x2);
95}
Douglas Gregor43d88632009-11-04 22:49:18 +000096
97template<typename T>
98struct X5 {
99 template<typename U>
100 void f();
101
102 void g() {
103 this->f<T*>();
104 }
105};