1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify
2 // RUN: %clang_cc1 -std=c++14 -fsyntax-only %s -verify
3 // RUN: %clang_cc1 -std=c++20 -fsyntax-only %s -verify
6 namespace ScopedEnumerations
{
14 enum class S1
<T
>::E
: T
{
18 static_assert(static_cast<int>(S1
<int>::E::S1_X
) == 0x123, "");
22 static constexpr T
f(int) { return 0; };
24 static constexpr T
f(char) { return 1; };
25 enum class E
: T
{ X
= f(T
{}) };
28 static_assert(static_cast<int>(S2
<char>::E::X
) == 1, "");
33 enum class E
: T
{ X
= 0x7FFFFF00 }; // expected-error {{cannot be narrowed to type 'char'}} expected-warning {{implicit conversion from 'int' to 'char'}}
35 template struct S3
<char>; // expected-note {{in instantiation}}
40 enum class E
: T
{ S4_X
= 5 };
43 auto x4
= S4
<int>::E::S4_X
;
47 enum class E
: T
{ X_F1
, Y_F1
, Z_F1
};
48 return X_F1
; // expected-error {{use of undeclared identifier 'X_F1'}}
51 const int resf1
= f1
<int>();
56 namespace UnscopedEnumerations
{
68 static_assert(static_cast<int>(S1
<int>::S1_X
) == 0x123, "");
72 static constexpr T
f(int) { return 0; };
74 static constexpr T
f(char) { return 1; };
75 enum E
: T
{ S2_X
= f(T
{}) };
78 static_assert(static_cast<int>(S2
<char>::E::S2_X
) == 1, "");
83 enum E
: T
{ S3_X
= 0x7FFFFF00 }; // expected-error {{cannot be narrowed to type 'char'}} expected-warning {{implicit conversion from 'int' to 'char'}}
85 template struct S3
<char>; // expected-note {{in instantiation of template class}}
90 enum E
: T
{ S4_X
= 5 };
93 auto x4
= S4
<int>::S4_X
;
98 T S5_X
= 5; // expected-note {{previous definition is here}}
99 enum E
: T
{ S5_X
= 5 }; // expected-error {{redefinition of 'S5_X'}}
103 template <typename T
>
105 enum E
: T
{ X_F2
, Y_F2
, Z_F2
};
109 const int resf1
= f1
<int>();