Add support for member references (E1.E2, E1->E2) with C++ semantics,
which can refer to static data members, enumerators, and member
functions as well as to non-static data members.
Implement correct lvalue computation for member references in C++.
Compute the result type of non-static data members of reference type properly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61294 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index c719f56..fe4b763 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -666,26 +666,27 @@
// other value of that type for promotion purposes (C++ 4.5p3).
if (MemberExpr *MemRef = dyn_cast<MemberExpr>(From)) {
using llvm::APSInt;
- FieldDecl *MemberDecl = MemRef->getMemberDecl();
- APSInt BitWidth;
- if (MemberDecl->isBitField() &&
- FromType->isIntegralType() && !FromType->isEnumeralType() &&
- From->isIntegerConstantExpr(BitWidth, Context)) {
- APSInt ToSize(Context.getTypeSize(ToType));
-
- // Are we promoting to an int from a bitfield that fits in an int?
- if (BitWidth < ToSize ||
- (FromType->isSignedIntegerType() && BitWidth <= ToSize)) {
- return To->getKind() == BuiltinType::Int;
+ if (FieldDecl *MemberDecl = dyn_cast<FieldDecl>(MemRef->getMemberDecl())) {
+ APSInt BitWidth;
+ if (MemberDecl->isBitField() &&
+ FromType->isIntegralType() && !FromType->isEnumeralType() &&
+ From->isIntegerConstantExpr(BitWidth, Context)) {
+ APSInt ToSize(Context.getTypeSize(ToType));
+
+ // Are we promoting to an int from a bitfield that fits in an int?
+ if (BitWidth < ToSize ||
+ (FromType->isSignedIntegerType() && BitWidth <= ToSize)) {
+ return To->getKind() == BuiltinType::Int;
+ }
+
+ // Are we promoting to an unsigned int from an unsigned bitfield
+ // that fits into an unsigned int?
+ if (FromType->isUnsignedIntegerType() && BitWidth <= ToSize) {
+ return To->getKind() == BuiltinType::UInt;
+ }
+
+ return false;
}
-
- // Are we promoting to an unsigned int from an unsigned bitfield
- // that fits into an unsigned int?
- if (FromType->isUnsignedIntegerType() && BitWidth <= ToSize) {
- return To->getKind() == BuiltinType::UInt;
- }
-
- return false;
}
}