1 // RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s -fexperimental-new-constant-interpreter
3 // RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s -fexperimental-new-constant-interpreter
5 // p1099 'using enum ELABORATED-ENUM-SPECIFIER ;'
9 enum A
{ a
, // expected-note{{declared here}}
21 #if __cplusplus < 202002
22 // expected-warning@-2{{is a C++20 extension}}
24 using enum Bob::B
; // expected-error{{unknown type name B}}
25 #if __cplusplus < 202002
26 // expected-warning@-2{{is a C++20 extension}}
28 using enum Bob::C
; // expected-error{{'Bob::C' is not an enumerated type}}
29 #if __cplusplus < 202002
30 // expected-warning@-2{{is a C++20 extension}}
34 A g
; // expected-error{{unknown type name 'A'}}
39 #if __cplusplus < 202002
40 // expected-warning@-2{{is a C++20 extension}}
46 #if __cplusplus < 202002
47 // expected-warning@-2{{is a C++20 extension}}
62 #if __cplusplus < 202002
63 // expected-warning@-2{{is a C++20 extension}}
69 #if __cplusplus >= 202002
70 // Now only check c++20 onwards
74 enum class C
: int; // expected-note{{declared here}}
77 using enum Stuart::C
; // expected-error{{is incomplete}}
88 enum class E
{ d
, // expected-note{{declared private here}}
94 using enum Dave::E
; // expected-error{{is a private member}}
110 template <typename T
> class TPL
;
111 template <> class TPL
<int> {
116 template <typename T
> class USR
{
117 using enum TPL
<T
>::B
; // expected-error{{cannot name a dependent type}}
118 using enum TPL
<int>::A
;
122 // Now instantiate things
130 static_assert(!int(Stuart::A::a
));
131 constexpr int Bar() {
132 using enum Stuart::A
;
135 static_assert(Bar() == 1);
137 template <int I
> constexpr int Foo() {
138 using enum Stuart::A
;
142 static_assert(Foo
<10>() == 11);
144 template <int I
> struct C
{
145 using enum Stuart::A
;
146 static constexpr int V
= int(c
) + I
;
151 using enum D
; // expected-error {{using-enum cannot name a dependent type}}
154 static_assert(C
<2>::V
== 4);
159 enum class Bob
: int {};
164 template <int I
> struct C
{
165 enum class D
{ i
= I
};
166 enum class E
: int; // expected-note{{declared here}}
171 constexpr auto d
= i
;
172 static_assert(unsigned(d
) == 2);
174 using enum C
<2>::E
; // expected-error{{instantiation of undefined member}}
178 enum class Bob
{ a
};
184 // We don't see the hidden extern a fn!
191 enum class Bob
{ a
}; // expected-note{{conflicting declaration}}
194 enum { a
}; // expected-note{{target of using}}
197 template <typename B
>
200 using B::a
; // expected-error{{target of using declaration}}
203 TPLa
<Base
> a
; // expected-note{{in instantiation}}
205 } // namespace Eleven
208 enum class Bob
{ a
}; // expected-note{{target of using}}
214 template <typename B
>
216 using B::a
; // expected-note{{conflicting declaration}}
217 using enum Bob
; // expected-error{{target of using declaration}}
222 } // namespace Twelve
225 enum class Bob
{ a
};
227 using enum Bob
; // expected-note{{previous using-enum}}
228 using enum Bob
; // expected-error{{redeclaration of using-enum}}
231 template <typename B
>
233 using enum Bob
; // expected-note{{previous using-enum}}
234 using enum Bob
; // expected-error{{redeclaration of using-enum}}
239 } // namespace Thirteen
245 using enum A
<int>; // expected-error {{A is not an enumerated type}}
246 } // namespace Fourteen
256 using enum Wrap::Things
;
259 return (Value1
| Value2
);
265 enum Masks
{Mask
= 1,Shift
= 0};
272 auto v
= (Mask
<< Shift
);