implement l-value codegen of comma expr


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71595 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 8ff2080..06d8d97 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -1108,6 +1108,12 @@
 }
 
 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/test/CodeGen/exprs.c b/test/CodeGen/exprs.c
index ad3e4e0..36cfff9 100644
--- a/test/CodeGen/exprs.c
+++ b/test/CodeGen/exprs.c
@@ -104,3 +104,15 @@
 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]);
+}
+