| 
2 | 2 | // RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR  | 
3 | 3 | // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll  | 
4 | 4 | // RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM  | 
 | 5 | +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll  | 
 | 6 | +// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG  | 
5 | 7 | 
 
  | 
6 | 8 | void complex_functional_cast() {  | 
7 | 9 |   using IntComplex = int _Complex;  | 
@@ -184,3 +186,45 @@ void complex_comma_operator(int _Complex a, int _Complex b) {  | 
184 | 186 | // LLVM: %[[RESULT:.*]] = alloca { i32, i32 }, i64 1, align 4  | 
185 | 187 | // LLVM: %[[TMP_B:.*]] = load { i32, i32 }, ptr %[[COMPLEX_B]], align 4  | 
186 | 188 | // LLVM: store { i32, i32 } %[[TMP_B]], ptr %[[RESULT]], align 4  | 
 | 189 | + | 
 | 190 | +void complex_cxx_default_init_expr() {  | 
 | 191 | +  struct FPComplexWrapper {  | 
 | 192 | +    float _Complex c{};  | 
 | 193 | +  };  | 
 | 194 | + | 
 | 195 | +  FPComplexWrapper w{};  | 
 | 196 | +}  | 
 | 197 | + | 
 | 198 | +// CIR: %[[W_ADDR:.*]] = cir.alloca !rec_FPComplexWrapper, !cir.ptr<!rec_FPComplexWrapper>, ["w", init]  | 
 | 199 | +// CIR: %[[C_ADDR:.*]] = cir.get_member %[[W_ADDR]][0] {name = "c"} : !cir.ptr<!rec_FPComplexWrapper> -> !cir.ptr<!cir.complex<!cir.float>>  | 
 | 200 | +// CIR: %[[CONST_COMPLEX:.*]] = cir.const #cir.complex<#cir.fp<0.000000e+00> : !cir.float, #cir.fp<0.000000e+00> : !cir.float> : !cir.complex<!cir.float>  | 
 | 201 | +// CIR: cir.store{{.*}} %[[CONST_COMPLEX]], %[[C_ADDR]] : !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>  | 
 | 202 | + | 
 | 203 | +// LLVM: %[[W_ADDR:.*]] = alloca %struct.FPComplexWrapper, i64 1, align 4  | 
 | 204 | +// LLVM: %[[C_ADDR:.*]] = getelementptr %struct.FPComplexWrapper, ptr %[[W_ADDR]], i32 0, i32 0  | 
 | 205 | +// LLVM: store { float, float } zeroinitializer, ptr %[[C_ADDR]], align 4  | 
 | 206 | + | 
 | 207 | +// OGCG: %[[W_ADDR:.*]] = alloca %struct.Wrapper, align 4  | 
 | 208 | +// OGCG: %[[C_ADDR:.*]] = getelementptr inbounds nuw %struct.FPComplexWrapper, ptr %[[W_ADDR]], i32 0, i32 0  | 
 | 209 | +// OGCG: %[[C_REAL_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[C_ADDR]], i32 0, i32 0  | 
 | 210 | +// OGCG: %[[C_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[C_ADDR]], i32 0, i32 1  | 
 | 211 | +// OGCG: store float 0.000000e+00, ptr %[[C_REAL_PTR]], align 4  | 
 | 212 | +// OGCG: store float 0.000000e+00, ptr %[[C_IMAG_PTR]], align 4  | 
 | 213 | + | 
 | 214 | +void complex_init_atomic() {  | 
 | 215 | +  _Atomic(float _Complex) a;  | 
 | 216 | +  __c11_atomic_init(&a, {1.0f, 2.0f});  | 
 | 217 | +}  | 
 | 218 | + | 
 | 219 | +// CIR: %[[A_ADDR:.*]] = cir.alloca !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>, ["a"]  | 
 | 220 | +// CIR: %[[CONST_COMPLEX:.*]] = cir.const #cir.complex<#cir.fp<1.000000e+00> : !cir.float, #cir.fp<2.000000e+00> : !cir.float> : !cir.complex<!cir.float>  | 
 | 221 | +// CIR: cir.store{{.*}} %[[CONST_COMPLEX]], %[[A_ADDR]] : !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>  | 
 | 222 | + | 
 | 223 | +// LLVM: %[[A_ADDR:.*]] = alloca { float, float }, i64 1, align 8  | 
 | 224 | +// LLVM: store { float, float } { float 1.000000e+00, float 2.000000e+00 }, ptr %[[A_ADDR]], align 8  | 
 | 225 | + | 
 | 226 | +// OGCG: %[[A_ADDR:.*]] = alloca { float, float }, align 8  | 
 | 227 | +// OGCG: %[[A_REAL_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[A_ADDR]], i32 0, i32 0  | 
 | 228 | +// OGCG: %[[A_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[A_ADDR]], i32 0, i32 1  | 
 | 229 | +// OGCG: store float 1.000000e+00, ptr %[[A_REAL_PTR]], align 8  | 
 | 230 | +// OGCG: store float 2.000000e+00, ptr %[[A_IMAG_PTR]], align 4  | 
0 commit comments