diff options
-rw-r--r-- | include/clang/AST/Expr.h | 4 | ||||
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 2 | ||||
-rw-r--r-- | test/CodeGenCXX/references.cpp | 3 |
3 files changed, 8 insertions, 1 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 5692ec880c..0a42be9f5c 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -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 diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 299bb6b4a4..eaf0873610 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -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()); diff --git a/test/CodeGenCXX/references.cpp b/test/CodeGenCXX/references.cpp index a1a6c0ae71..82b9ec73ff 100644 --- a/test/CodeGenCXX/references.cpp +++ b/test/CodeGenCXX/references.cpp @@ -35,6 +35,9 @@ void test_scalar() { int a = 10; f(a); + struct { int bitfield : 3; } s = { 3 }; + f(s.bitfield) + f(10); } |