1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 // Test class template partial specializations of member templates.
6 template<typename U
> struct Inner0
{
7 static const unsigned value
= 0;
10 template<typename U
> struct Inner0
<U
*> {
11 static const unsigned value
= 1;
15 template<typename T
> template<typename U
>
16 struct X0
<T
>::Inner0
<const U
*> {
17 static const unsigned value
= 2;
20 int array0
[X0
<int>::Inner0
<int>::value
== 0? 1 : -1];
21 int array1
[X0
<int>::Inner0
<int*>::value
== 1? 1 : -1];
22 int array2
[X0
<int>::Inner0
<const int*>::value
== 2? 1 : -1];
24 // Make sure we can provide out-of-line class template partial specializations
25 // for member templates (and instantiate them).
26 template<class T
> struct A
{
28 template<class T2
> struct B
;
32 // partial specialization of A<T>::C::B<T2>
33 template<class T
> template<class T2
> struct A
<T
>::C::B
<T2
*> { };
35 A
<short>::C::B
<int*> absip
;
37 // Check for conflicts during template instantiation.
38 template<typename T
, typename U
>
40 template<typename X
, typename Y
> struct Inner
;
41 template<typename Y
> struct Inner
<T
, Y
> {}; // expected-note{{previous declaration of class template partial specialization 'Inner<int, type-parameter-0-0>' is here}}
42 template<typename Y
> struct Inner
<U
, Y
> {}; // expected-error{{cannot be redeclared}}
45 Outer
<int, int> outer
; // expected-note{{instantiation}}
47 // Test specialization of class template partial specialization members.
48 template<> template<typename Z
>
49 struct X0
<float>::Inner0
<Z
*> {
50 static const unsigned value
= 3;
53 int array3
[X0
<float>::Inner0
<int>::value
== 0? 1 : -1];
54 int array4
[X0
<float>::Inner0
<int*>::value
== 3? 1 : -1];
55 int array5
[X0
<float>::Inner0
<const int*>::value
== 2? 1 : -1];
57 namespace rdar8651930
{
58 template<typename OuterT
>
60 template<typename T
, typename U
>
65 static const bool value
= true;
68 template<typename T
, typename U
>
70 static const bool value
= false;
74 int array0
[Outer
<int>::Inner
<int, int>::value
? 1 : -1];
75 int array1
[Outer
<int>::Inner
<int, float>::value
? -1 : 1];
78 namespace print_dependent_TemplateSpecializationType
{
80 template <class T
, class U
> struct Foo
{
81 template <unsigned long, class X
, class Y
> struct Bar
;
82 template <class Y
> struct Bar
<0, T
, Y
> {};
83 // expected-note-re@-1 {{previous declaration {{.*}} 'Bar<0, int, type-parameter-0-0>' is here}}
84 template <class Y
> struct Bar
<0, U
, Y
> {};
85 // expected-error@-1 {{partial specialization 'Bar<0, int, Y>' cannot be redeclared}}
87 template struct Foo
<int, int>; // expected-note {{requested here}}
89 } // namespace print_dependent_TemplateSpecializationType