@@ -205,3 +205,26 @@ void init_expr(int a, int b, int c) {
205205// OGCG: %[[C_PLUS_THREE:.*]] = add nsw i32 %[[C]], 3
206206// OGCG: store i32 %[[C_PLUS_THREE]], ptr %[[S_C]]
207207// OGCG: ret void
208+
209+ void cxx_default_init_with_struct_field () {
210+ struct Parent {
211+ int getA ();
212+ int a = getA();
213+ };
214+ Parent p = Parent{};
215+ }
216+
217+ // CIR: %[[P_ADDR:.*]] = cir.alloca !rec_Parent, !cir.ptr<!rec_Parent>, ["p", init]
218+ // CIR: %[[P_ELEM_0_PTR:.*]] = cir.get_member %[[P_ADDR]][0] {name = "a"} : !cir.ptr<!rec_Parent> -> !cir.ptr<!s32i>
219+ // CIR: %[[METHOD_CALL:.*]] = cir.call @_ZZ34cxx_default_init_with_struct_fieldvEN6Parent4getAEv(%[[P_ADDR]]) : (!cir.ptr<!rec_Parent>) -> !s32i
220+ // CIR: cir.store{{.*}} %[[METHOD_CALL]], %[[P_ELEM_0_PTR]] : !s32i, !cir.ptr<!s32i>
221+
222+ // LLVM: %[[P_ADDR:.*]] = alloca %struct.Parent, i64 1, align 4
223+ // LLVM: %[[P_ELEM_0_PTR:.*]] = getelementptr %struct.Parent, ptr %[[P_ADDR]], i32 0, i32 0
224+ // LLVM: %[[METHOD_CALL:.*]] = call i32 @_ZZ34cxx_default_init_with_struct_fieldvEN6Parent4getAEv(ptr %[[P_ADDR]])
225+ // LLVM: store i32 %[[METHOD_CALL]], ptr %[[P_ELEM_0_PTR]], align 4
226+
227+ // OGCG: %[[P_ADDR:.*]] = alloca %struct.Parent, align 4
228+ // OGCG: %[[P_ELEM_0_PTR:.*]] = getelementptr inbounds nuw %struct.Parent, ptr %[[P_ADDR]], i32 0, i32 0
229+ // OGCG: %[[METHOD_CALL:.*]] = call noundef i32 @_ZZ34cxx_default_init_with_struct_fieldvEN6Parent4getAEv(ptr {{.*}} %[[P_ADDR]])
230+ // OGCG: store i32 %[[METHOD_CALL]], ptr %[[P_ELEM_0_PTR]], align 4
0 commit comments