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 enum ELABORATED-ENUM-SPECIFIER ;'
8 enum A
{ a
, // expected-note{{declared here}}
20 #if __cplusplus < 202002
21 // expected-warning@-2{{is a C++20 extension}}
23 using enum Bob::B
; // expected-error{{unknown type name B}}
24 #if __cplusplus < 202002
25 // expected-warning@-2{{is a C++20 extension}}
27 using enum Bob::C
; // expected-error{{'Bob::C' is not an enumerated type}}
28 #if __cplusplus < 202002
29 // expected-warning@-2{{is a C++20 extension}}
33 A g
; // expected-error{{unknown type name 'A'}}
38 #if __cplusplus < 202002
39 // expected-warning@-2{{is a C++20 extension}}
45 #if __cplusplus < 202002
46 // expected-warning@-2{{is a C++20 extension}}
61 #if __cplusplus < 202002
62 // expected-warning@-2{{is a C++20 extension}}
68 #if __cplusplus >= 202002
69 // Now only check c++20 onwards
73 enum class C
: int; // expected-note{{declared here}}
76 using enum Stuart::C
; // expected-error{{is incomplete}}
87 enum class E
{ d
, // expected-note{{declared private here}}
93 using enum Dave::E
; // expected-error{{is a private member}}
109 template <typename T
> class TPL
;
110 template <> class TPL
<int> {
115 template <typename T
> class USR
{
116 using enum TPL
<T
>::B
; // expected-error{{cannot name a dependent type}}
117 using enum TPL
<int>::A
;
121 // Now instantiate things
129 static_assert(!int(Stuart::A::a
));
130 constexpr int Bar() {
131 using enum Stuart::A
;
134 static_assert(Bar() == 1);
136 template <int I
> constexpr int Foo() {
137 using enum Stuart::A
;
141 static_assert(Foo
<10>() == 11);
143 template <int I
> struct C
{
144 using enum Stuart::A
;
145 static constexpr int V
= int(c
) + I
;
152 static constexpr int W
= int(f
) + I
;
155 static_assert(C
<2>::V
== 4);
156 static_assert(C
<20>::W
== 22);
161 enum class Bob
: int {};
166 template <int I
> struct C
{
167 enum class D
{ i
= I
};
168 enum class E
: int; // expected-note{{declared here}}
173 constexpr auto d
= i
;
174 static_assert(unsigned(d
) == 2);
176 using enum C
<2>::E
; // expected-error{{instantiation of undefined member}}
180 enum class Bob
{ a
};
186 // We don't see the hidden extern a fn!
193 enum class Bob
{ a
}; // expected-note{{conflicting declaration}}
196 enum { a
}; // expected-note{{target of using}}
199 template <typename B
>
202 using B::a
; // expected-error{{target of using declaration}}
205 TPLa
<Base
> a
; // expected-note{{in instantiation}}
207 } // namespace Eleven
210 enum class Bob
{ a
}; // expected-note{{target of using}}
216 template <typename B
>
218 using B::a
; // expected-note{{conflicting declaration}}
219 using enum Bob
; // expected-error{{target of using declaration}}
224 } // namespace Twelve
227 enum class Bob
{ a
};
229 using enum Bob
; // expected-note{{previous using-enum}}
230 using enum Bob
; // expected-error{{redeclaration of using-enum}}
233 template <typename B
>
235 using enum Bob
; // expected-note{{previous using-enum}}
236 using enum Bob
; // expected-error{{redeclaration of using-enum}}
241 } // namespace Thirteen
251 using enum Wrap::Things
;
254 return (Value1
| Value2
);
260 enum Masks
{Mask
= 1,Shift
= 0};
267 auto v
= (Mask
<< Shift
);