if (PTy->getPointeeType()->isUnionType())
isUnion = true;
CVRQualifiers = PTy->getPointeeType().getCVRQualifiers();
- if (const CXXRecordDecl *ClassDecl =
- BaseExpr->getType()->getCXXRecordDeclForPointerType()) {
- FieldDecl *Field = dyn_cast<FieldDecl>(E->getMemberDecl());
- if (const CXXRecordDecl *BaseClassDecl =
- dyn_cast<CXXRecordDecl>(Field->getDeclContext()))
- BaseValue = AddressCXXOfBaseClass(BaseValue, ClassDecl, BaseClassDecl);
- }
} else if (isa<ObjCPropertyRefExpr>(BaseExpr) ||
isa<ObjCKVCRefExpr>(BaseExpr)) {
RValue RV = EmitObjCPropertyGet(BaseExpr);
if (BaseTy->isUnionType())
isUnion = true;
CVRQualifiers = BaseTy.getCVRQualifiers();
- if (const CXXRecordDecl *ClassDecl =
- dyn_cast<CXXRecordDecl>(
- BaseTy->getAsRecordType()->getDecl())) {
- FieldDecl *Field = dyn_cast<FieldDecl>(E->getMemberDecl());
- if (const CXXRecordDecl *BaseClassDecl =
- dyn_cast<CXXRecordDecl>(Field->getDeclContext()))
- BaseValue =
- AddressCXXOfBaseClass(BaseValue, ClassDecl, BaseClassDecl);
- }
}
FieldDecl *Field = dyn_cast<FieldDecl>(E->getMemberDecl());
ImplicitConversionSequence TryContextuallyConvertToBool(Expr *From);
bool PerformContextuallyConvertToBool(Expr *&From);
+
+ void PerformObjectMemberConversion(Expr *&From, NamedDecl *Member);
/// OverloadingResult - Capture the result of performing overload
/// resolution.
return BuildDeclarationNameExpr(Loc, D, HasTrailingLParen, SS, isAddressOfOperand);
}
+/// \brief Cast member's object to its own class if necessary.
+void
+Sema::PerformObjectMemberConversion(Expr *&From, NamedDecl *Member) {
+ if (FieldDecl *FD = dyn_cast<FieldDecl>(Member))
+ if (CXXRecordDecl *RD =
+ dyn_cast<CXXRecordDecl>(FD->getDeclContext())) {
+ QualType DestType =
+ Context.getCanonicalType(Context.getTypeDeclType(RD));
+ if (!DestType->isDependentType() &&
+ !From->getType()->isDependentType()) {
+ if (From->getType()->getAsPointerType())
+ DestType = Context.getPointerType(DestType);
+ ImpCastExprToType(From, DestType, /*isLvalue=*/true);
+ }
+ }
+}
/// \brief Complete semantic analysis for a reference to the given declaration.
Sema::OwningExprResult
Expr *This = new (Context) CXXThisExpr(SourceLocation(),
MD->getThisType(Context));
MarkDeclarationReferenced(Loc, D);
+ PerformObjectMemberConversion(This, D);
return Owned(new (Context) MemberExpr(This, true, D,
Loc, MemberType));
}
}
MarkDeclarationReferenced(MemberLoc, FD);
+ PerformObjectMemberConversion(BaseExpr, FD);
return Owned(new (Context) MemberExpr(BaseExpr, OpKind == tok::arrow, FD,
MemberLoc, MemberType));
}
printf("iQ = %d\n", iQ);
printf("iP = %d\n", iP);
printf("iM = %d\n", iM);
- printf("iQ = %d\n", (*this).iQ);
- printf("iP = %d\n", ((*this)).iP);
+ // FIXME. We don't yet support this syntax.
+ // printf("iQ = %d\n", (*this).iQ);
+ printf("iQ = %d\n", this->iQ);
+ printf("iP = %d\n", this->iP);
printf("iM = %d\n", this->iM);
}
float ld;