From 4b0e2a30e0fe55d55d3c0255fa79c14be3138722 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 20 May 2008 07:56:31 +0000 Subject: [PATCH] Implement codegen for comma operator for structs. llvm-svn: 51304 --- clang/lib/CodeGen/CGExprAgg.cpp | 7 +++++++ clang/test/CodeGen/struct-comma.c | 4 ++++ 2 files changed, 11 insertions(+) create mode 100644 clang/test/CodeGen/struct-comma.c diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index c7c250ee7beb..2ac473439e67 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -82,6 +82,7 @@ public: void VisitBinaryOperator(const BinaryOperator *BO); void VisitBinAssign(const BinaryOperator *E); void VisitOverloadExpr(const OverloadExpr *E); + void VisitBinComma(const BinaryOperator *E); void VisitConditionalOperator(const ConditionalOperator *CO); @@ -213,6 +214,12 @@ void AggExprEmitter::VisitOverloadExpr(const OverloadExpr *E) EmitAggregateCopy(DestPtr, RV.getAggregateAddr(), E->getType()); } +void AggExprEmitter::VisitBinComma(const BinaryOperator *E) +{ + CGF.EmitAnyExpr(E->getLHS()); + CGF.EmitAggExpr(E->getRHS(), DestPtr, false); +} + void AggExprEmitter::VisitStmtExpr(const StmtExpr *E) { CGF.EmitCompoundStmt(*E->getSubStmt(), true, DestPtr, VolatileDest); } diff --git a/clang/test/CodeGen/struct-comma.c b/clang/test/CodeGen/struct-comma.c new file mode 100644 index 000000000000..e8070dd17821 --- /dev/null +++ b/clang/test/CodeGen/struct-comma.c @@ -0,0 +1,4 @@ +// RUN: clang %s -emit-llvm + +struct S {int a, b;} x; +void a(struct S* b) {*b = (r(), x);}