diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp index 352c6feac2e8..4d86a3a36bf5 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp @@ -868,7 +868,8 @@ LValue CIRGenFunction::buildDeclRefLValue(const DeclRefExpr *E) { LValue CIRGenFunction::buildBinaryOperatorLValue(const BinaryOperator *E) { // Comma expressions just emit their LHS then their RHS as an l-value. if (E->getOpcode() == BO_Comma) { - assert(0 && "not implemented"); + buildIgnoredExpr(E->getLHS()); + return buildLValue(E->getRHS()); } if (E->getOpcode() == BO_PtrMemD || E->getOpcode() == BO_PtrMemI) diff --git a/clang/test/CIR/CodeGen/comma.cpp b/clang/test/CIR/CodeGen/comma.cpp index 0e10c8edec3f..4d2ce88b9d26 100644 --- a/clang/test/CIR/CodeGen/comma.cpp +++ b/clang/test/CIR/CodeGen/comma.cpp @@ -15,3 +15,16 @@ int c0() { // CHECK: %[[#]] = cir.binop(add, %[[#LOADED_B]], %[[#]]) : !s32i // CHECK: %[[#LOADED_A:]] = cir.load %[[#A]] : cir.ptr , !s32i // CHECK: cir.store %[[#LOADED_A]], %[[#RET]] : !s32i, cir.ptr + +int &foo1(); +int &foo2(); + +void c1() { + int &x = (foo1(), foo2()); +} + +// CHECK: cir.func @_Z2c1v() +// CHECK: %0 = cir.alloca !cir.ptr, cir.ptr > +// CHECK: %1 = cir.call @_Z4foo1v() : () -> !cir.ptr +// CHECK: %2 = cir.call @_Z4foo2v() : () -> !cir.ptr +// CHECK: cir.store %2, %0 : !cir.ptr, cir.ptr >