================ @@ -23,16 +25,57 @@ using namespace clang; using namespace clang::CIRGen; using namespace cir; -void CIRGenFunction::emitCompoundStmtWithoutScope(const CompoundStmt &s) { - for (auto *curStmt : s.body()) { - if (emitStmt(curStmt, /*useCurrentScope=*/false).failed()) - getCIRGenModule().errorNYI(curStmt->getSourceRange(), - std::string("emitCompoundStmtWithoutScope: ") + - curStmt->getStmtClassName()); +mlir::LogicalResult CIRGenFunction::emitCompoundStmtWithoutScope( + const CompoundStmt &s, Address *lastValue, AggValueSlot slot) { + mlir::LogicalResult result = mlir::success(); + const Stmt *exprResult = s.getStmtExprResult(); + assert((!lastValue || (lastValue && exprResult)) && + "If lastValue is not null then the CompoundStmt must have a " + "StmtExprResult"); + + for (const Stmt *curStmt : s.body()) { + // We have to special case labels here. They are statements, but when put + // at the end of a statement expression, they yield the value of their + // subexpression. Handle this by walking through all labels we encounter, + // emitting them before we evaluate the subexpr. + // Similar issues arise for attributed statements. + if (lastValue && exprResult == curStmt) { ---------------- bcardosolopes wrote:
Might be cleaner to factor the content of this `if` out in a helper function. https://github.com/llvm/llvm-project/pull/153677 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits