1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
3 // This test concerns the identity of dependent types within the
4 // canonical type system. This corresponds to C++ [temp.type], which
5 // specifies type equivalence within a template.
7 // FIXME: template template parameters
26 template<typename T
, typename U
>
31 void f0(T
); // expected-note{{previous}}
33 void f0(type
); // expected-error{{redeclar}}
35 void f1(T
*); // expected-note{{previous}}
37 void f1(type
*); // expected-error{{redeclar}}
39 void f2(X0
<T
>*); // expected-note{{previous}}
41 void f2(X0
<type
>*); // expected-error{{redeclar}}
43 void f3(X0
<T
>*); // expected-note{{previous}}
45 void f3(::X0
<type
>*); // expected-error{{redeclar}}
47 void f4(typename
T::template apply
<U
>*); // expected-note{{previous}}
48 void f4(typename
U::template apply
<U
>*);
49 void f4(typename
type::template apply
<T
>*);
50 void f4(typename
type::template apply
<U_type
>*); // expected-error{{redeclar}}
52 void f5(typename
T::template apply
<U
>::type
*); // expected-note{{previous}}
53 void f5(typename
U::template apply
<U
>::type
*);
54 void f5(typename
U::template apply
<T
>::type
*);
55 void f5(typename
type::template apply
<T
>::type
*);
56 void f5(typename
type::template apply
<U_type
>::type
*); // expected-error{{redeclar}}
58 void f6(typename
N::X2
<T
>::template apply
<U
> *); // expected-note{{previous}}
59 void f6(typename
N::X2
<U
>::template apply
<U
> *);
60 void f6(typename
N::X2
<U
>::template apply
<T
> *);
61 void f6(typename ::N::X2
<type
>::template apply
<U_type
> *); // expected-error{{redeclar}}
63 void f7(typename
N::X2
<T
>::template apply
<U
> *); // expected-note{{previous}}
64 void f7(typename
N::X2
<U
>::template apply
<U
> *);
65 void f7(typename
N::X2
<U
>::template apply
<T
> *);
66 void f7(typename X2
<type
>::template apply
<U_type
> *); // expected-error{{redeclar}}
68 void f8(typename
N::X2
<T
>::template apply
<U
> *); // expected-note{{previous}}
69 void f8(typename
N::X2
<U
>::template apply
<U
> *);
70 void f8(typename
N::X2
<U
>::template apply
<T
> *);
71 void f8(typename ::Nalias::X2
<type
>::template apply
<U_type
> *); // expected-error{{redeclar}}
80 S
< S
<w
>::cond
&& 1 > foo();
83 struct Arrow
{ Arrow
*operator->(); int n
; };
84 template<typename T
> struct M
{
86 auto f() -> M
<decltype(a
->n
)>;
90 bool operator&&(const Alien
&, const Alien
&);
93 S
< S
<w
>::cond
&& 1 > N::foo() { }
96 auto M
<T
>::f() -> M
<decltype(a
->n
)> {}
100 template <typename T
>
101 struct TemplateClass2
104 static T member
[SIZE
];
107 template <typename T
>
108 T TemplateClass2
<T
>::member
[TemplateClass2
<T
>::SIZE
];
112 template<typename T
> struct A
{
120 void A
<T
>::f(int x
) { x
= 0; }
123 void A
<T
>::g(const int x
) { // expected-note {{declared const here}}
124 x
= 0; // expected-error {{cannot assign to variable 'x'}}
128 void A
<T
>::h(T
) {} // FIXME: Should reject this. Type is different from prior decl if T is an array type.
131 void A
<T
>::i(const T
) {} // FIXME: Should reject this. Type is different from prior decl if T is an array type.
133 template struct A
<int>;
134 template struct A
<int[1]>;
138 template<typename T
> using X
= int;
139 template<typename T
, decltype(sizeof(0))> using Y
= int;
140 template<typename
...Ts
> struct S
{};
141 template<typename
...Ts
> void f() {
142 // This is a dependent type. It is *not* S<int>, even though it canonically
143 // contains no template parameters.
144 using Type
= S
<X
<Ts
>...>;
146 using Type
= S
<int, int, int>;
148 void g() { f
<void, void, void>(); }
150 template<typename
...Ts
> void h(S
<int>) {}
151 // Pending a core issue, it's not clear if these are redeclarations, but they
152 // are probably intended to be... even though substitution can succeed for one
153 // of them but fail for the other!
154 template<typename
...Ts
> void h(S
<X
<Ts
>...>) {} // expected-note {{previous}}
155 template<typename
...Ts
> void h(S
<Y
<Ts
, sizeof(Ts
)>...>) {} // expected-error {{redefinition}}