1 // RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
4 // p1099 'using SCOPEDENUM::MEMBER;'
11 #if __cplusplus >= 202002L
12 // expected-note@-3{{target of using declaration}}
13 // expected-note@-3{{target of using declaration}}
18 using Bob::Kevin::Stuart
;
19 #if __cplusplus < 202002L
20 // expected-warning@-2{{using declaration naming a scoped enumerator is a C++20 extension}}
22 using Bob::Kevin::Stuart
;
27 int Stuart
; // expected-note{{conflicting declaration}}
28 using Bob::Kevin::Stuart
; // expected-error{{target of using declaration conflicts}}
30 using Bob::Kevin::AlsoStuart
; // expected-note{{using declaration}}
31 int AlsoStuart
; // expected-error{{declaration conflicts with target}}
39 // derived from [namespace.udecl]/3
40 enum class button
{ up
,
44 #if __cplusplus < 202002L
45 // expected-warning@-2{{a C++20 extension}}
46 // expected-error@-3{{using declaration in class}}
52 #if __cplusplus >= 202002L
66 #if __cplusplus < 202002L
67 // expected-error@-2{{using declaration in class}}
81 using Three::e3
; // expected-error{{using declaration in class}}
89 #if __cplusplus < 202002L
90 // expected-error@-3{{using declaration cannot refer to class member}}
91 // expected-note@-4{{use a constexpr variable instead}}
92 // expected-warning@-4{{a C++20 extension}}
93 // expected-error@-5{{using declaration cannot refer to class member}}
94 // expected-note@-6{{use a constexpr variable instead}}
103 template <typename T
>
105 enum class E1
{ e1
};
107 enum class E2
{ e2
};
111 enum class E3
{ e3
}; // expected-note{{declared protected here}}
114 using TPL
<int>::E1::e1
;
115 #if __cplusplus < 202002L
116 // expected-warning@-2{{a C++20 extension}}
117 // expected-error@-3{{using declaration cannot refer to class member}}
118 // expected-note@-4{{use a constexpr variable instead}}
120 using TPL
<float>::IN::E2::e2
;
126 enum class E4
{ e4
};
127 template <typename T
>
128 struct DER
: TPL
<int> {
129 using TPL
<T
>::E1::e1
;
130 #if __cplusplus < 202002L
131 // expected-warning@-2{{a C++20 extension}}
132 // expected-warning@-3{{using declaration naming a scoped}}
133 // expected-error@-4{{which is not a base}}
135 using TPL
<T
>::E3::e3
; // expected-error{{is a protected member}}
136 #if __cplusplus < 202002L
137 // expected-warning@-2 2{{using declaration naming a scoped}}
138 // expected-error@-3{{which is not a base}}
142 #if __cplusplus < 202002L
143 // expected-warning@-2{{a C++20 extension}}
144 // expected-error@-3{{which is not a class}}
146 auto Foo() { return e1
; }
147 auto Bar() { return e2
; }
151 DER
<float> x
; // expected-note{{requested here}}
153 #if __cplusplus < 202002L
154 // expected-note@-2{{requested here}}
162 template <unsigned I
, unsigned K
>
164 enum class Q
: unsigned; // expected-note{{member is declared here}}
165 enum class R
: unsigned { i
= I
,
169 using Quux
<1, 2>::Q::nothing
; // expected-error{{implicit instantiation of undefined}}
170 using Quux
<1, 2>::R::i
;
171 #if __cplusplus < 202002L
172 // expected-warning@-2{{a C++20 extension}}
173 // expected-error@-3{{using declaration cannot refer to class member}}
174 // expected-note@-4{{use a constexpr variable instead}}
180 template <unsigned I
, unsigned K
>
182 enum class Q
: unsigned; // expected-note{{member is declared here}}
183 enum class R
: unsigned { i
= I
,
187 template <unsigned I
> struct Fido
{
188 using Quux
<I
, I
>::Q::nothing
; // expected-error{{implicit instantiation of undefined}}
191 Fido
<2> a
; // expected-note{{in instantiation}}
196 template <unsigned I
, unsigned K
>
198 enum class R
: unsigned { i
= I
,
202 template <unsigned I
> struct Toto
{
203 using Quux
<I
, I
>::R::i
;
204 #if __cplusplus < 202002L
205 // expected-warning@-2{{a C++20 extension}}
206 // expected-error@-3{{refers into}}
208 static_assert(unsigned(i
) == I
);
213 #if __cplusplus < 202002L
214 // expected-note@-2{{in instantiation}}
226 #if __cplusplus < 202002L
227 // expected-warning@-2{{a C++20 extension}}
228 // expected-error@-3{{using declaration cannot refer to class member}}
229 // expected-note@-4{{use a constexpr variable instead}}
232 #if __cplusplus < 202002L
233 // expected-warning@-2{{a C++20 extension}}
234 // expected-error@-3{{using declaration cannot refer to class member}}
235 // expected-note@-4{{use a constexpr variable instead}}
239 using Kevin::B::a
; // expected-note{{previous using declaration}}
240 #if __cplusplus < 202002L
241 // expected-warning@-2{{a C++20 extension}}
244 using Kevin::B::a
; // expected-error{{redeclaration of using declaration}}
251 enum class Bob
{ a
};
253 #if __cplusplus < 202002L
254 // expected-warning@-2{{a C++20 extension}}
260 #if __cplusplus < 202002L
261 // expected-warning@-2{{a C++20 extension}}
264 #if __cplusplus >= 202002L
266 using Q::a
; // expected-note{{previous using declaration}}
268 using Q::a
; // expected-error{{redeclaration of using declaration}}