Create a temporary if the lvalue is a bitfield. Reported by Eli.

llvm-svn: 72155
This commit is contained in:
Anders Carlsson 2009-05-20 01:24:22 +00:00
parent 61da18645b
commit ad007d44b6
3 changed files with 8 additions and 1 deletions

View File

@ -182,6 +182,10 @@ public:
/// declaration of that bit-field.
FieldDecl *getBitField();
const FieldDecl *getBitField() const {
return const_cast<Expr*>(this)->getBitField();
}
/// isIntegerConstantExpr - Return true if this expression is a valid integer
/// constant expression, and, if so, return its value in Result. If not a
/// valid i-c-e, return false and fill in Loc (if specified) with the location

View File

@ -72,7 +72,7 @@ RValue CodeGenFunction::EmitAnyExprToTemp(const Expr *E, llvm::Value *AggLoc,
RValue CodeGenFunction::EmitReferenceBindingToExpr(const Expr* E,
QualType DestType) {
if (E->isLvalue(getContext()) == Expr::LV_Valid) {
if (E->isLvalue(getContext()) == Expr::LV_Valid && !E->getBitField()) {
// Emit the expr as an lvalue.
LValue LV = EmitLValue(E);
return RValue::get(LV.getAddress());

View File

@ -35,6 +35,9 @@ void test_scalar() {
int a = 10;
f(a);
struct { int bitfield : 3; } s = { 3 };
f(s.bitfield)
f(10);
}