Make the AST explicitly represent the cast of the first operand of a
pointer-to-member operator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93592 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 1ad931e..e481268 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -1450,12 +1450,14 @@
// overkill?
if (!IsDerivedFrom(LType, Class, Paths) ||
Paths.isAmbiguous(Context.getCanonicalType(Class))) {
- const char *ReplaceStr = isIndirect ? ".*" : "->*";
Diag(Loc, diag::err_bad_memptr_lhs) << OpSpelling
- << (int)isIndirect << lex->getType() <<
- CodeModificationHint::CreateReplacement(SourceRange(Loc), ReplaceStr);
+ << (int)isIndirect << lex->getType();
return QualType();
}
+ // Cast LHS to type of use.
+ QualType UseType = isIndirect ? Context.getPointerType(Class) : Class;
+ bool isLValue = !isIndirect && lex->isLvalue(Context) == Expr::LV_Valid;
+ ImpCastExprToType(lex, UseType, CastExpr::CK_DerivedToBase, isLValue);
}
if (isa<CXXZeroInitValueExpr>(rex->IgnoreParens())) {