]> granicus.if.org Git - clang/commitdiff
Fix PR7889 by generalizing some over specialized code. There is no
authorChris Lattner <sabre@nondot.org>
Wed, 18 Aug 2010 00:08:27 +0000 (00:08 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 18 Aug 2010 00:08:27 +0000 (00:08 +0000)
reason that this should be limited to simple lvalues.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111331 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
test/CodeGenCXX/expr.cpp

index e9788709963002236a13dfda69084389b6d0f48f..18ecf1719f2cd25959ab16ee77a0a78bec5384b5 100644 (file)
@@ -1938,10 +1938,8 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) {
   if (!hasAggregateLLVMType(E->getType())) {
     // Emit the LHS as an l-value.
     LValue LV = EmitLValue(E->getLHS());
-    
-    llvm::Value *RHS = EmitScalarExpr(E->getRHS());
-    EmitStoreOfScalar(RHS, LV.getAddress(), LV.isVolatileQualified(), 
-                      E->getType());
+    // Sore the value through the l-value.
+    EmitStoreThroughLValue(EmitAnyExpr(E->getRHS()), LV, E->getType());
     return LV;
   }
   
index 26bda055b3d768939edeaa7118a057c0dd4a5516..775169d9578bc804d24e0ef1f0744d7aae9e0008 100644 (file)
@@ -18,3 +18,13 @@ void test2() { ++a+=10; }
 // PR7892
 int test3(const char*);
 int test3g = test3(__PRETTY_FUNCTION__);
+
+
+// PR7889
+struct test4A {
+  int j : 2;
+};
+int test4() {
+  test4A a;
+  (a.j = 2) = 3;
+}