blob: da11119e5b276a93ad639466d3ad22316f432108 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor6946baf2009-09-02 13:05:45 +00002template<typename T, typename U>
3struct is_same {
4 static const bool value = false;
5};
6
7template<typename T>
8struct is_same<T, T> {
9 static const bool value = true;
10};
11
12template<typename MetaFun, typename T1, typename T2>
13struct metafun_apply2 {
14 typedef typename MetaFun::template apply<T1, T2> inner;
15 typedef typename inner::type type;
16};
17
18template<typename T, typename U> struct pair;
19
20struct make_pair {
21 template<typename T1, typename T2>
22 struct apply {
23 typedef pair<T1, T2> type;
24 };
25};
26
27int a0[is_same<metafun_apply2<make_pair, int, float>::type,
28 pair<int, float> >::value? 1 : -1];
29int a1[is_same<
Douglas Gregor732281d2010-06-14 22:07:54 +000030 typename make_pair::template apply<int, float>, // expected-warning{{'template' refers to a non-dependent template name}}
Douglas Gregor6946baf2009-09-02 13:05:45 +000031 make_pair::apply<int, float>
32 >::value? 1 : -1];
33
34template<typename MetaFun>
35struct swap_and_apply2 {
36 template<typename T1, typename T2>
37 struct apply {
38 typedef typename MetaFun::template apply<T2, T1> new_metafun;
39 typedef typename new_metafun::type type;
40 };
41};
42
43int a2[is_same<swap_and_apply2<make_pair>::apply<int, float>::type,
44 pair<float, int> >::value? 1 : -1];
45
Douglas Gregorae440672009-09-02 13:07:20 +000046template<typename MetaFun>
47struct swap_and_apply2b {
48 template<typename T1, typename T2>
49 struct apply {
50 typedef typename MetaFun::template apply<T2, T1>::type type;
51 };
52};
53
54int a3[is_same<swap_and_apply2b<make_pair>::apply<int, float>::type,
55 pair<float, int> >::value? 1 : -1];
56
Douglas Gregor6946baf2009-09-02 13:05:45 +000057template<typename T>
58struct X0 {
59 template<typename U, typename V>
60 struct Inner;
61
62 void f0(X0<T>::Inner<T*, T&>); // expected-note{{here}}
63 void f0(typename X0<T>::Inner<T*, T&>); // expected-error{{redecl}}
64
65 void f1(X0<T>::Inner<T*, T&>); // expected-note{{here}}
66 void f1(typename X0<T>::template Inner<T*, T&>); // expected-error{{redecl}}
Douglas Gregorae440672009-09-02 13:07:20 +000067
68 void f2(typename X0<T>::Inner<T*, T&>::type); // expected-note{{here}}
69 void f2(typename X0<T>::template Inner<T*, T&>::type); // expected-error{{redecl}}
Douglas Gregor6946baf2009-09-02 13:05:45 +000070};
Douglas Gregora4e8c2a2010-02-05 04:39:02 +000071
72namespace PR6236 {
73 template<typename T, typename U> struct S { };
74
75 template<typename T> struct S<T, T> {
76 template<typename U> struct K { };
77
78 void f() {
79 typedef typename S<T, T>::template K<T> Foo;
80 }
81 };
82}
Douglas Gregorae628892010-02-13 06:05:33 +000083
84namespace PR6268 {
85 template <typename T>
86 struct Outer {
87 template <typename U>
88 struct Inner {};
89
90 template <typename U>
91 typename Outer<T>::template Inner<U>
92 foo(typename Outer<T>::template Inner<U>);
93 };
94
95 template <typename T>
96 template <typename U>
97 typename Outer<T>::template Inner<U>
98 Outer<T>::foo(typename Outer<T>::template Inner<U>) {
99 return Inner<U>();
100 }
101}
Douglas Gregora50ce322010-03-07 23:26:22 +0000102
103namespace PR6463 {
104 struct B { typedef int type; }; // expected-note 2{{member found by ambiguous name lookup}}
105 struct C { typedef int type; }; // expected-note 2{{member found by ambiguous name lookup}}
106
107 template<typename T>
108 struct A : B, C {
109 type& a(); // expected-error{{found in multiple base classes}}
110 int x;
111 };
112
113 // FIXME: Improve source location info here.
114 template<typename T>
115 typename A<T>::type& A<T>::a() { // expected-error{{found in multiple base classes}}
John McCall63b43852010-04-29 23:50:39 +0000116 return x;
Douglas Gregora50ce322010-03-07 23:26:22 +0000117 }
118}