@@ -154,3 +154,32 @@ void choose_expr() {
154154//  OGCG:   %[[B_ADDR:.*]] = alloca %struct.CompleteS, align 4
155155//  OGCG:   %[[C_ADDR:.*]] = alloca %struct.CompleteS, align 4
156156//  OGCG:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[C_ADDR]], ptr align 4 %[[A_ADDR]], i64 8, i1 false)
157+ 
158+ void  generic_selection () {
159+   CompleteS a;
160+   CompleteS b;
161+   int  c;
162+   CompleteS d = _Generic (c, int  : a, default : b);
163+ }
164+ 
165+ //  CIR: cir.func{{.*}} @_Z17generic_selectionv()
166+ //  CIR:   %[[A_ADDR:.*]] = cir.alloca !rec_CompleteS, !cir.ptr<!rec_CompleteS>, ["a"]
167+ //  CIR:   %[[B_ADDR:.*]] = cir.alloca !rec_CompleteS, !cir.ptr<!rec_CompleteS>, ["b"]
168+ //  CIR:   %[[C_ADDR:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["c"]
169+ //  CIR:   %[[D_ADDR:.*]] = cir.alloca !rec_CompleteS, !cir.ptr<!rec_CompleteS>, ["d", init]
170+ //  TODO(cir): Call to default copy constructor should be replaced by `cir.copy` op
171+ //  CIR:   cir.call @_ZN9CompleteSC1ERKS_(%[[D_ADDR]], %[[A_ADDR]]) nothrow : (!cir.ptr<!rec_CompleteS>, !cir.ptr<!rec_CompleteS>) -> ()
172+ 
173+ //  LLVM: define{{.*}} void @_Z17generic_selectionv()
174+ //  LLVM:   %1 = alloca %struct.CompleteS, i64 1, align 4
175+ //  LLVM:   %2 = alloca %struct.CompleteS, i64 1, align 4
176+ //  LLVM:   %3 = alloca i32, i64 1, align 4
177+ //  LLVM:   %4 = alloca %struct.CompleteS, i64 1, align 4
178+ //  LLVM:   call void @_ZN9CompleteSC1ERKS_(ptr %4, ptr %1)
179+ 
180+ //  OGCG: define{{.*}} void @_Z17generic_selectionv()
181+ //  OGCG:   %[[A_ADDR:.*]] = alloca %struct.CompleteS, align 4
182+ //  OGCG:   %[[B_ADDR:.*]] = alloca %struct.CompleteS, align 4
183+ //  OGCG:   %[[C_ADDR:.*]] = alloca i32, align 4
184+ //  OGCG:   %[[D_ADDR:.*]] = alloca %struct.CompleteS, align 4
185+ //  OGCG:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[D_ADDR]], ptr align 4 %[[A_ADDR]], i64 8, i1 false)
0 commit comments