aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-05-02 02:18:30 +0000
committerDouglas Gregor <dgregor@apple.com>2009-05-02 02:18:30 +0000
commit33bbbc5ec8269bc2cde5b84f970fa49319a30267 (patch)
tree229102a2c45a24da3c6f24d503de940f1c3e0900 /lib/Sema/SemaOverload.cpp
parentb3b0b3624e462c2940f65b86e773bfc300005203 (diff)
When determining whether an expression refers to a bit-field, look
into the left-hand side of an assignment expression. This completes most of PR3500; the only remaining part is to deal with the GCC-specific implementation-defined behavior for "unsigned long" (and other) bit-fields. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70623 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r--lib/Sema/SemaOverload.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index eb4c4e6706..e6b8056a42 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -746,14 +746,14 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
// other value of that type for promotion purposes (C++ 4.5p3).
// FIXME: We should delay checking of bit-fields until we actually
// perform the conversion.
- if (MemberExpr *MemRef = dyn_cast_or_null<MemberExpr>(From)) {
- using llvm::APSInt;
- if (FieldDecl *MemberDecl = dyn_cast<FieldDecl>(MemRef->getMemberDecl())) {
+ using llvm::APSInt;
+ if (From)
+ if (FieldDecl *MemberDecl = From->getBitField()) {
APSInt BitWidth;
- if (MemberDecl->isBitField() &&
- FromType->isIntegralType() && !FromType->isEnumeralType() &&
- From->isIntegerConstantExpr(BitWidth, Context)) {
- APSInt ToSize(Context.getTypeSize(ToType));
+ if (FromType->isIntegralType() && !FromType->isEnumeralType() &&
+ MemberDecl->getBitWidth()->isIntegerConstantExpr(BitWidth, Context)) {
+ APSInt ToSize(BitWidth.getBitWidth(), BitWidth.isUnsigned());
+ ToSize = Context.getTypeSize(ToType);
// Are we promoting to an int from a bitfield that fits in an int?
if (BitWidth < ToSize ||
@@ -770,8 +770,7 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
return false;
}
}
- }
-
+
// An rvalue of type bool can be converted to an rvalue of type int,
// with false becoming zero and true becoming one (C++ 4.5p4).
if (FromType->isBooleanType() && To->getKind() == BuiltinType::Int) {