]> granicus.if.org Git - clang/commitdiff
implement l-value codegen of comma expr
authorChris Lattner <sabre@nondot.org>
Tue, 12 May 2009 21:28:12 +0000 (21:28 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 12 May 2009 21:28:12 +0000 (21:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71595 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
test/CodeGen/exprs.c

index 8ff2080efa33992548bc9743acd255b1183f6432..06d8d974b08145a13f9f0300a9e6653b7ba2b268 100644 (file)
@@ -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)
index ad3e4e095686242840a787ecf9a39739136c4723..36cfff9e8a699e9744c0a932daf699bc4ce99dae 100644 (file)
@@ -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]);
+}
+