[flang][cuda] Adapt ExternalNameConversion to work in gpu module (#117039)
[llvm-project.git] / clang / test / AST / ByteCode / enums.cpp
blob459cf3a0c83d5401ce89cb67bf389337b2c13603
1 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
2 // RUN: %clang_cc1 -verify=ref %s
4 enum class EC : short {
5 A, B, C
6 };
7 static_assert(static_cast<int>(EC::A) == 0, "");
8 static_assert(static_cast<int>(EC::B) == 1, "");
9 static_assert(static_cast<int>(EC::C) == 2, "");
10 static_assert(sizeof(EC) == sizeof(short), "");
12 constexpr EC ec = EC::C;
13 static_assert(static_cast<int>(ec) == 2, "");
15 constexpr int N = 12;
16 constexpr int M = 2;
18 enum CE {
19 ONE = -1,
20 TWO = 2,
21 THREE,
22 FOUR = 4,
23 FIVE = N + M,
24 SIX = FIVE + 2,
25 MAX = __INT_MAX__ * 2U + 1U
27 static_assert(ONE == -1, "");
28 static_assert(THREE == 3, "");
29 static_assert(FIVE == 14, "");
30 static_assert(SIX == 16, "");
32 constexpr EC testEnums() {
33 EC e = EC::C;
35 e = EC::B;
37 EC::B = e; // expected-error{{expression is not assignable}} \
38 // ref-error{{expression is not assignable}}
40 return e;
43 constexpr EC getB() {
44 EC e = EC::C;
45 e = EC::B;
46 return e;
50 static_assert(getB() == EC::B, "");
52 namespace B {
53 enum E : bool { Zero, One };
54 static_assert((int)(E)2 == 1, "");
55 } // namespace B