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 bdd7975..9daa21e 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -768,6 +768,11 @@
// 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 @@
// 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;
}