Debian Codegraph @

gcc/testsuite/g++.dg/cpp1y/var-templ11.C

raw
1 // PR c++/63201
2 // { dg-do compile { target c++14 } }
3
4 template <class T>
5 struct Y
6 {
7 template <class U> static U x;
8 };
9
10 template <class T>
11 template <class U>
12 U Y<T>::x = U();
13
14 template <>
15 template <class U>
16 U Y<int>::x = 42;
17
18 template <>
19 template <class U>
20 // odd diagnostic
21 U Y<float>::x<U> = 42; // { dg-error "partial specialization" }
22
23 template <>
24 template <>
25 int Y<float>::x<int> = 42; // { dg-bogus "non-member-template declaration" }
26
27 template <class T>
28 struct Z
29 {
30 template <class U> struct ZZ
31 {
32 template <class V> static V x;
33 };
34 };
35
36 template <class T>
37 template <class U>
38 template <class V>
39 V Z<T>::ZZ<U>::x = V();
40
41 template <>
42 template <>
43 template <class V>
44 V Z<int>::ZZ<int>::x = V();
45
46 template <>
47 template <class U>
48 struct Z<float>::ZZ
49 {
50 template <class V> static V x;
51 };
52
53 template <>
54 template <class U>
55 template <class V>
56 V Z<float>::ZZ<U>::x = V();
57
58 template <>
59 template <>
60 template <>
61 int Z<float>::ZZ<int>::x<int> = 42; // { dg-bogus "non-member-template declaration" }
62
63 int main()
64 {
65 int y = Y<int>::x<int>;
66 int z = Z<float>::ZZ<int>::x<int>;
67 }