]> granicus.if.org Git - clang/commitdiff
Fix for PR2001. I'm not really fond of it, but it is correct (unless
authorEli Friedman <eli.friedman@gmail.com>
Sun, 25 May 2008 14:13:57 +0000 (14:13 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sun, 25 May 2008 14:13:57 +0000 (14:13 +0000)
someone tries to make a bitfield volatile?).

Not sure how to write a test; any suggestions?

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

lib/CodeGen/CGExprScalar.cpp

index bdd7975fa0cadc8009d1a3e2a0e08429303b7094..9daa21eb340a150f769a4df78840ad9f938fa5ac 100644 (file)
@@ -768,6 +768,11 @@ Value *ScalarExprEmitter::EmitCompoundAssign(const CompoundAssignOperator *E,
   // Store the result value into the LHS lvalue.
   CGF.EmitStoreThroughLValue(RValue::get(Result), LHSLV, E->getType());
 
+  // For bitfields, we need the value in the bitfield
+  // FIXME: This adds an extra bitfield load
+  if (LHSLV.isBitfield())
+    Result = EmitLoadOfLValue(LHSLV, LHSTy);
+
   return Result;
 }
 
@@ -963,7 +968,11 @@ Value *ScalarExprEmitter::VisitBinAssign(const BinaryOperator *E) {
   // Store the value into the LHS.
   // FIXME: Volatility!
   CGF.EmitStoreThroughLValue(RValue::get(RHS), LHS, E->getType());
-  
+
+  // For bitfields, we need the value in the bitfield
+  // FIXME: This adds an extra bitfield load
+  if (LHS.isBitfield())
+    return EmitLoadOfLValue(LHS, E->getLHS()->getType());
   // Return the RHS.
   return RHS;
 }