enum class E1 {
Val1 = 1L
};
enum struct E2 {
Val1 = '\0'
};
E1 v1 = Val1; E1 v2 = E1::Val1;
static_assert(sizeof(E1) == sizeof(int), "bad size");
static_assert(sizeof(E1::Val1) == sizeof(int), "bad size");
static_assert(sizeof(E2) == sizeof(int), "bad size");
static_assert(sizeof(E2::Val1) == sizeof(int), "bad size");
E1 v3 = E2::Val1; int x1 = E1::Val1;
enum E3 : char {
Val2 = 1
};
E3 v4 = Val2;
E1 v5 = Val2;
static_assert(sizeof(E3) == 1, "bad size");
int x2 = Val2;
int a1[Val2];
int a2[E1::Val1];
#if __cplusplus >= 201703L
#else
#endif
int* p1 = new int[Val2];
int* p2 = new int[E1::Val1];
#if __cplusplus >= 201703L
#else
#endif
enum class E4 {
e1 = -2147483648, e2 = 2147483647, e3 = 2147483648 };
enum class E5 {
e1 = 2147483647, e2 };
enum class E6 : bool {
e1 = false, e2 = true,
e3 };
enum E7 : bool {
e1 = false, e2 = true,
e3 };
template <class T>
struct X {
enum E : T {
e1, e2,
e3 };
};
X<bool> X2;
enum Incomplete1;
enum Complete1 : int;
Complete1 complete1;
enum class Complete2;
Complete2 complete2;
enum class Redeclare2; enum Redeclare2; enum Redeclare2;
enum Redeclare3 : int; enum Redeclare3; enum Redeclare3;
enum class Redeclare5;
enum class Redeclare5 : int;
enum Redeclare6 : int; enum Redeclare6 : short; enum Redeclare6 : short;
enum class Redeclare7; enum class Redeclare7 : short; enum class Redeclare7 : short;
enum : long {
long_enum_val = 10000
};
enum : long x;
void PR9333() {
enum class scoped_enum { yes, no, maybe };
scoped_enum e = scoped_enum::yes;
if (e == scoped_enum::no) { }
}
namespace rdar9366066 {
enum class X : unsigned { value };
void f(X x) {
x % X::value; x % 8; }
}
namespace test5 {
namespace ns {
typedef unsigned Atype;
enum A : Atype;
}
enum ns::A : ns::Atype {
x, y, z
};
}
namespace test6 {
enum A : unsigned;
struct A::a; enum A::b; int A::c; void A::d(); void test() {
(void) A::e; }
}
namespace PR11484 {
const int val = 104;
enum class test1 { owner_dead = val, };
}
namespace N2764 {
enum class E *x0a; enum E2 *x0b; enum class E { a, b };
enum E x1 = E::a; enum class E x2 = E::a;
enum F { a, b };
enum F y1 = a; enum class F y2 = a;
struct S {
friend enum class E; friend enum class F;
friend enum G {}; friend enum class H {}; friend enum I : int {};
enum A : int;
A a;
} s;
enum S::A : int {};
enum class B;
}
enum class N2764::B {};
namespace PR12106 {
template<typename E> struct Enum {
Enum() : m_e(E::Last) {}
E m_e;
};
enum eCOLORS { Last };
Enum<eCOLORS> e;
}
namespace test7 {
enum class E { e = (struct S*)0 == (struct S*)0 };
S *p;
}
namespace test8 {
template<typename T> struct S {
enum A : int; enum class B; enum class C : int; enum class D : int; };
template<typename T> enum S<T>::A { a }; template<typename T> enum class S<T>::B : char { b }; template<typename T> enum S<T>::C : int { c }; template<typename T> enum class S<T>::D : char { d }; }
namespace test9 {
template<typename T> struct S {
enum class ET : T; enum class Eint : int; };
template<> enum class S<int>::ET : int {};
template<> enum class S<char>::ET : short {}; template<> enum class S<int>::Eint : short {}; template<> enum class S<char>::Eint : int {};
template<typename T> enum class S<T>::ET : int {}; template<typename T> enum class S<T>::Eint : T {};
S<short> s; }
namespace test10 {
template<typename T> int f() {
enum E : int;
enum E : T; E x;
enum E : int { e }; x = e;
return x;
}
int k = f<int>();
int l = f<short>();
template<typename T> int g() {
enum class E : int;
enum class E : T; E x;
enum class E : int { e }; x = E::e;
return (int)x;
}
int m = g<int>();
int n = g<short>(); }
namespace pr13128 {
class C {
enum class E { C };
};
}
namespace PR15633 {
template<typename T> struct A {
struct B {
enum class E : T;
enum class E2 : T;
};
};
template<typename T> enum class A<T>::B::E { e };
template class A<int>;
struct B { enum class E; };
template<typename T> enum class B::E { e }; }
namespace PR16900 {
enum class A;
A f(A a) { return -a; } }
namespace PR18551 {
enum class A { A };
bool f() { return !A::A; } }
namespace rdar15124329 {
enum class B : bool { F, T };
const rdar15124329::B T1 = B::T;
typedef B C; const C T2 = B::T;
static_assert(T1 != B::F, "");
static_assert(T2 == B::T, "");
}
namespace PR18044 {
enum class E { a };
int E::e = 0; void E::f() {} struct E::S {}; struct T : E::S {}; enum E::E {}; int E::*p; using E::f;
using E::a; E b = a;
}
namespace test11 {
enum class E { a };
typedef E E2;
E2 f1() { return E::a; }
bool f() { return !f1(); } }
namespace PR35586 {
enum C { R, G, B };
enum B { F = (enum C) -1, T}; };
namespace test12 {
enum class A;
enum class B;
A a;
B b{a}; }