From e541ea3a61a3331e39d5a90387472126453293bd Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 12 May 2009 21:28:12 +0000 Subject: [PATCH] implement l-value codegen of comma expr llvm-svn: 71595 --- clang/lib/CodeGen/CGExpr.cpp | 6 ++++++ clang/test/CodeGen/exprs.c | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 8ff2080efa33..06d8d974b081 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -1108,6 +1108,12 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E) { } LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) { + // Comma expressions just emit their LHS then their RHS as an l-value. + if (E->getOpcode() == BinaryOperator::Comma) { + EmitAnyExpr(E->getLHS()); + return EmitLValue(E->getRHS()); + } + // Can only get l-value for binary operator expressions which are a // simple assignment of aggregate type. if (E->getOpcode() != BinaryOperator::Assign) diff --git a/clang/test/CodeGen/exprs.c b/clang/test/CodeGen/exprs.c index ad3e4e095686..36cfff9e8a69 100644 --- a/clang/test/CodeGen/exprs.c +++ b/clang/test/CodeGen/exprs.c @@ -104,3 +104,15 @@ void f7() { int f8() { return ({ foo(); }).Y; } + +// rdar://6880558 +struct S; +struct C { + int i; + struct S *tab[]; +}; +struct S { struct C c; }; +void f9(struct S *x) { + foo(((void)1, x->c).tab[0]); +} +