145
|
1 // P0634R3
|
|
2 // { dg-do compile { target c++2a } }
|
|
3
|
|
4 // (5.2.1) simple-declaration or a function-definition in namespace scope
|
|
5
|
|
6 template<typename T>
|
|
7 T::X fn1 (int);
|
|
8
|
|
9 template<typename T>
|
|
10 T::X fn1 (int)
|
|
11 {
|
|
12 return 42;
|
|
13 }
|
|
14
|
|
15 template<typename T>
|
|
16 T::X v1;
|
|
17
|
|
18 namespace N {
|
|
19 template<typename T>
|
|
20 T::X v2;
|
|
21 }
|
|
22
|
|
23 // (5.2.2) member-declaration
|
|
24
|
|
25 template<typename T>
|
|
26 struct S {
|
|
27 [[noreturn]] T::X fn2 ();
|
|
28 T::X fn3 ();
|
|
29 T::X fn4 () { return 5; }
|
|
30 T::X fn5 () final;
|
|
31 T::X fn6 () = 0;
|
|
32 T::X fn8 () override;
|
|
33 T::X v3;
|
|
34 T::X *v4;
|
|
35 T::X v5[5];
|
|
36 T::X v6 = 0;
|
|
37 T::X v7{0};
|
|
38 T::X v8 : 16;
|
|
39 static constexpr T::X v9 = 0;
|
|
40 typedef T::X T2;
|
|
41 friend T::X fn7<int> ();
|
|
42 static inline T::X v10;
|
|
43 };
|
|
44
|
|
45 // (5.2.3) parameter-declaration in a member-declaration,
|
|
46 // unless that parameter-declaration appears in a default argument
|
|
47
|
|
48 template<typename T>
|
|
49 struct S2 {
|
|
50 friend int fn1<T::X> ();
|
|
51 int fn2 (T::X p);
|
|
52 int fn5 (int = T::X);
|
|
53 };
|
|
54
|
|
55 // (5.2.4) parameter-declaration in a declarator of a function or function
|
|
56 // template declaration whose declarator-id is qualified,
|
|
57 // unless that parameter-declaration appears in a default argument
|
|
58
|
|
59 struct M {
|
|
60 template<typename T>
|
|
61 int fn (T::X);
|
|
62 };
|
|
63
|
|
64 template<typename T>
|
|
65 int M::fn (T::X p) { return p; }
|
|
66
|
|
67 // (5.2.5) parameter-declaration in a lambda-declarator,
|
|
68 // unless that parameter-declaration appears in a default argument
|
|
69
|
|
70 void
|
|
71 fn5 ()
|
|
72 {
|
|
73 auto j = []<typename T>(T::X t, int i) { return i; };
|
|
74 }
|
|
75
|
|
76 // (5.2.6) parameter-declaration of a (non-type) template-parameter
|
|
77
|
|
78 template<typename T, T::X N>
|
|
79 struct S3 { };
|
|
80
|
|
81 // default argument of a type-parameter of a template
|
|
82 template<typename T, typename U = T::X>
|
|
83 struct S4 { };
|
|
84
|
|
85 // type-id of a static_cast, const_cast, reinterpret_cast, or dynamic_cast
|
|
86 template<typename T>
|
|
87 struct S5 {
|
|
88 void fn6 (T::X p)
|
|
89 {
|
|
90 int i = static_cast<T::Y>(p);
|
|
91 i = dynamic_cast<T::Y>(p);
|
|
92 i = reinterpret_cast<T::Y>(p);
|
|
93 i = const_cast<T::Y>(p);
|
|
94 }
|
|
95 };
|
|
96
|
|
97 template<typename T>
|
|
98 void fn7 (typename T::X p)
|
|
99 {
|
|
100 int i = static_cast<T::Y>(p);
|
|
101 i = dynamic_cast<T::Y>(p);
|
|
102 i = reinterpret_cast<T::Y>(p);
|
|
103 i = const_cast<T::Y>(p);
|
|
104 }
|
|
105
|
|
106 // new-type-id
|
|
107 template<typename T>
|
|
108 void
|
|
109 fn8 ()
|
|
110 {
|
|
111 new T::X[10];
|
|
112 }
|
|
113
|
|
114 // defining-type-id
|
|
115
|
|
116 template<typename T>
|
|
117 struct W { typedef int M; };
|
|
118
|
|
119 template<typename T>
|
|
120 struct S6 {
|
|
121 using TT = T::X;
|
|
122 using TT2 = W<T>::M;
|
|
123 };
|
|
124
|
|
125 // trailing-return-type
|
|
126 template<typename T>
|
|
127 struct S7 {
|
|
128 auto fn9() -> W<T>::M;
|
|
129 };
|