[clang] [CIR] Upstream enum support (PR #136807)
Morris Hafner via cfe-commits
cfe-commits at lists.llvm.org
Fri May 2 13:02:20 PDT 2025
================
@@ -247,9 +247,35 @@ size_type max_size(void) {
// CIR: %3 = cir.cast(integral, %2 : !s32i), !u64i
// CIR: %4 = cir.const #cir.int<8> : !u64i
// CIR: %5 = cir.binop(div, %3, %4) : !u64i
+// CIR: cir.store %5, %0 : !u64i, !cir.ptr<!u64i>
+// CIR: %6 = cir.load %0 : !cir.ptr<!u64i>, !u64i
+// CIR: cir.return %6 : !u64i
+// CIR: }
// LLVM: define i64 @max_size()
// LLVM: store i64 2305843009213693951, ptr
// OGCG: define{{.*}} i64 @max_size()
// OGCG: ret i64 2305843009213693951
+
+enum A {
+ A_one,
+ A_two
+};
+enum A a;
+
+// CIR: cir.global external @a = #cir.int<0> : !u32i
+
+enum B : int;
+enum B b;
+
+// CIR: cir.global external @b = #cir.int<0> : !s32i
+
+enum C : int {
+ C_one,
+ C_two
+};
+enum C c;
+
+// CIR: cir.global external @c = #cir.int<0> : !s32i
+
----------------
mmha wrote:
Can you add a test that doesn't specify a fixed underlying type but uses a value that's out of range? for example
```c++
enum D {
D_one = -1
};
```
https://github.com/llvm/llvm-project/pull/136807
More information about the cfe-commits
mailing list