From: Eli Friedman Date: Sun, 25 May 2008 14:13:57 +0000 (+0000) Subject: Fix for PR2001. I'm not really fond of it, but it is correct (unless X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1849128c7d88247d914f05efe4c03907f0932174;p=clang Fix for PR2001. I'm not really fond of it, but it is correct (unless 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 --- diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index bdd7975fa0..9daa21eb34 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -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; }