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}}
11 class C
; // expected-note{{previous use}}
20 #if __cplusplus < 202002
21 // expected-warning@-2{{is a C++20 extension}}
23 using enum Bob::B
; // expected-error{{no enum named 'B'}}
24 #if __cplusplus < 202002
25 // expected-warning@-2{{is a C++20 extension}}
27 using enum Bob::C
; // expected-error{{tag type that does not match}}
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}}
51 #if __cplusplus < 202002
52 // expected-warning@-2{{is a C++20 extension}}
58 #if __cplusplus >= 202002
59 // Now only check c++20 onwards
63 enum class C
: int; // expected-note{{declared here}}
66 using enum Stuart::C
; // expected-error{{is incomplete}}
77 enum class E
{ d
, // expected-note{{declared private here}}
83 using enum Dave::E
; // expected-error{{is a private member}}
99 template <typename T
> class TPL
;
100 template <> class TPL
<int> {
105 template <typename T
> class USR
{
106 using enum TPL
<T
>::B
; // expected-error{{cannot name a dependent type}}
107 using enum TPL
<int>::A
;
111 // Now instantiate things
119 static_assert(!int(Stuart::A::a
));
120 constexpr int Bar() {
121 using enum Stuart::A
;
124 static_assert(Bar() == 1);
126 template <int I
> constexpr int Foo() {
127 using enum Stuart::A
;
131 static_assert(Foo
<10>() == 11);
133 template <int I
> struct C
{
134 using enum Stuart::A
;
135 static constexpr int V
= int(c
) + I
;
142 static constexpr int W
= int(f
) + I
;
145 static_assert(C
<2>::V
== 4);
146 static_assert(C
<20>::W
== 22);
151 enum class Bob
: int {};
156 template <int I
> struct C
{
157 enum class D
{ i
= I
};
158 enum class E
: int; // expected-note{{declared here}}
163 constexpr auto d
= i
;
164 static_assert(unsigned(d
) == 2);
166 using enum C
<2>::E
; // expected-error{{instantiation of undefined member}}
170 enum class Bob
{ a
};
176 // We don't see the hidden extern a fn!
183 enum class Bob
{ a
}; // expected-note{{conflicting declaration}}
186 enum { a
}; // expected-note{{target of using}}
189 template <typename B
>
192 using B::a
; // expected-error{{target of using declaration}}
195 TPLa
<Base
> a
; // expected-note{{in instantiation}}
197 } // namespace Eleven
200 enum class Bob
{ a
}; // expected-note{{target of using}}
206 template <typename B
>
208 using B::a
; // expected-note{{conflicting declaration}}
209 using enum Bob
; // expected-error{{target of using declaration}}
214 } // namespace Twelve
217 enum class Bob
{ a
};
219 using enum Bob
; // expected-note{{previous using-enum}}
220 using enum Bob
; // expected-error{{redeclaration of using-enum}}
223 template <typename B
>
225 using enum Bob
; // expected-note{{previous using-enum}}
226 using enum Bob
; // expected-error{{redeclaration of using-enum}}
231 } // namespace Thirteen