@@ -9,8 +9,14 @@ namespace Undefined {
99 template <typename U>
1010 static const int x; // expected-note {{declared here}}
1111
12+ template <typename U>
13+ static const int x<U*>; // expected-note {{declared here}}
14+
1215 template <typename U>
1316 struct B ; // expected-note {{template is declared here}}
17+
18+ template <typename U>
19+ struct B <U*>; // expected-note {{template is declared here}}
1420 };
1521
1622 template <>
@@ -23,6 +29,16 @@ namespace Undefined {
2329 template <typename U>
2430 constexpr int A<short >::x = A<long >::x<U>;
2531
32+ template <>
33+ template <typename U>
34+ constexpr int A<short >::x<U*> = A<long >::x<U*>;
35+
36+ template <>
37+ template <typename U>
38+ struct A <short >::B<U*> {
39+ static constexpr int y = A<long >::B<U*>::y;
40+ };
41+
2642 template <>
2743 template <typename U>
2844 struct A <short >::B {
@@ -39,21 +55,36 @@ namespace Undefined {
3955 template <typename U>
4056 constexpr int A<long >::x = 1 ;
4157
58+ template <>
59+ template <typename U>
60+ constexpr int A<long >::x<U*> = 2 ;
61+
4262 template <>
4363 template <typename U>
4464 struct A <long >::B {
4565 static constexpr int y = 1 ;
4666 };
4767
68+ template <>
69+ template <typename U>
70+ struct A <long >::B<U*> {
71+ static constexpr int y = 2 ;
72+ };
73+
4874 static_assert (A<int >::f<int >() == 0 ); // expected-error {{static assertion expression is not an integral constant expression}}
4975 // expected-note@-1 {{undefined function 'f<int>' cannot be used in a constant expression}}
5076 static_assert (A<int >::x<int > == 0 ); // expected-error {{static assertion expression is not an integral constant expression}}
5177 // expected-note@-1 {{initializer of 'x<int>' is unknown}}
78+ static_assert (A<int >::x<int *> == 0 ); // expected-error {{static assertion expression is not an integral constant expression}}
79+ // expected-note@-1 {{initializer of 'x<int *>' is unknown}}
5280 static_assert (A<int >::B<int >::y == 0 ); // expected-error {{implicit instantiation of undefined template 'Undefined::A<int>::B<int>'}}
81+ static_assert (A<int >::B<int *>::y == 0 ); // expected-error {{implicit instantiation of undefined template 'Undefined::A<int>::B<int *>'}}
5382
5483 static_assert (A<short >::f<int >() == 1 );
5584 static_assert (A<short >::x<int > == 1 );
85+ static_assert (A<short >::x<int *> == 2 );
5686 static_assert (A<short >::B<int >::y == 1 );
87+ static_assert (A<short >::B<int *>::y == 2 );
5788} // namespace Undefined
5889
5990namespace Defined {
@@ -62,15 +93,23 @@ namespace Defined {
6293 template <typename U>
6394 static constexpr int f () {
6495 return 0 ;
65- }
96+ };
6697
6798 template <typename U>
68- static constexpr int x = 0 ;
99+ static const int x = 0 ;
100+
101+ template <typename U>
102+ static const int x<U*> = 0 ;
69103
70104 template <typename U>
71105 struct B {
72106 static constexpr int y = 0 ;
73107 };
108+
109+ template <typename U>
110+ struct B <U*> {
111+ static constexpr int y = 0 ;
112+ };
74113 };
75114
76115 template <>
@@ -83,6 +122,16 @@ namespace Defined {
83122 template <typename U>
84123 constexpr int A<short >::x = A<long >::x<U>;
85124
125+ template <>
126+ template <typename U>
127+ constexpr int A<short >::x<U*> = A<long >::x<U*>;
128+
129+ template <>
130+ template <typename U>
131+ struct A <short >::B<U*> {
132+ static constexpr int y = A<long >::B<U*>::y;
133+ };
134+
86135 template <>
87136 template <typename U>
88137 struct A <short >::B {
@@ -99,17 +148,31 @@ namespace Defined {
99148 template <typename U>
100149 constexpr int A<long >::x = 1 ;
101150
151+ template <>
152+ template <typename U>
153+ constexpr int A<long >::x<U*> = 2 ;
154+
102155 template <>
103156 template <typename U>
104157 struct A <long >::B {
105158 static constexpr int y = 1 ;
106159 };
107160
161+ template <>
162+ template <typename U>
163+ struct A <long >::B<U*> {
164+ static constexpr int y = 2 ;
165+ };
166+
108167 static_assert (A<int >::f<int >() == 0 );
109168 static_assert (A<int >::x<int > == 0 );
169+ static_assert (A<int >::x<int *> == 0 );
110170 static_assert (A<int >::B<int >::y == 0 );
171+ static_assert (A<int >::B<int *>::y == 0 );
111172
112173 static_assert (A<short >::f<int >() == 1 );
113174 static_assert (A<short >::x<int > == 1 );
175+ static_assert (A<short >::x<int *> == 2 );
114176 static_assert (A<short >::B<int >::y == 1 );
177+ static_assert (A<short >::B<int *>::y == 2 );
115178} // namespace Defined
0 commit comments