@@ -144,3 +144,52 @@ void throw_complex_expr() {
144144// OGCG: store float 0x3FF19999A0000000, ptr %[[EXCEPTION_REAL]], align 16
145145// OGCG: store float 0x40019999A0000000, ptr %[[EXCEPTION_IMAG]], align 4
146146// OGCG: call void @__cxa_throw(ptr %[[EXCEPTION_ADDR]], ptr @_ZTICf, ptr null)
147+
148+
149+ void throw_enum_expr () {
150+ enum Test {
151+ TestA,
152+ TestB
153+ };
154+ throw Test::TestA;
155+ }
156+
157+ // CIR: %[[EXCEPTION_ADDR:.*]] = cir.alloc.exception 4 -> !cir.ptr<!u32i>
158+ // CIR: %[[EXCEPTION_VALUE:.*]] = cir.const #cir.int<0> : !u32i
159+ // CIR: cir.store{{.*}} %[[EXCEPTION_VALUE]], %[[EXCEPTION_ADDR]] : !u32i, !cir.ptr<!u32i>
160+ // CIR: cir.throw %[[EXCEPTION_ADDR]] : !cir.ptr<!u32i>, @_ZTIZ15throw_enum_exprvE4Test
161+ // CIR: cir.unreachable
162+
163+ // LLVM: %[[EXCEPTION_ADDR:.*]] = call ptr @__cxa_allocate_exception(i64 4)
164+ // LLVM: store i32 0, ptr %[[EXCEPTION_ADDR]], align 16
165+ // LLVM: call void @__cxa_throw(ptr %[[EXCEPTION_ADDR]], ptr @_ZTIZ15throw_enum_exprvE4Test, ptr null)
166+ // LLVM: unreachable
167+
168+ // OGCG: %[[EXCEPTION_ADDR:.*]] = call ptr @__cxa_allocate_exception(i64 4)
169+ // OGCG: store i32 0, ptr %[[EXCEPTION_ADDR]], align 16
170+ // OGCG: call void @__cxa_throw(ptr %[[EXCEPTION_ADDR]], ptr @_ZTIZ15throw_enum_exprvE4Test, ptr null)
171+ // OGCG: unreachable
172+
173+ void throw_enum_class_expr () {
174+ enum class Test {
175+ TestA,
176+ TestB
177+ };
178+ throw Test::TestA;
179+ }
180+
181+ // CIR: %[[EXCEPTION_ADDR:.*]] = cir.alloc.exception 4 -> !cir.ptr<!s32i>
182+ // CIR: %[[EXCEPTION_VALUE:.*]] = cir.const #cir.int<0> : !s32i
183+ // CIR: cir.store{{.*}} %[[EXCEPTION_VALUE]], %[[EXCEPTION_ADDR]] : !s32i, !cir.ptr<!s32i>
184+ // CIR: cir.throw %[[EXCEPTION_ADDR]] : !cir.ptr<!s32i>, @_ZTIZ21throw_enum_class_exprvE4Test
185+ // CIR: cir.unreachable
186+
187+ // LLVM: %[[EXCEPTION_ADDR:.*]] = call ptr @__cxa_allocate_exception(i64 4)
188+ // LLVM: store i32 0, ptr %[[EXCEPTION_ADDR]], align 16
189+ // LLVM: call void @__cxa_throw(ptr %[[EXCEPTION_ADDR]], ptr @_ZTIZ21throw_enum_class_exprvE4Test, ptr null)
190+ // LLVM: unreachable
191+
192+ // OGCG: %[[EXCEPTION_ADDR:.*]] = call ptr @__cxa_allocate_exception(i64 4)
193+ // OGCG: store i32 0, ptr %[[EXCEPTION_ADDR]], align 16
194+ // OGCG: call void @__cxa_throw(ptr %[[EXCEPTION_ADDR]], ptr @_ZTIZ21throw_enum_class_exprvE4Test, ptr null)
195+ // OGCG: unreachable
0 commit comments