forked from OSchip/llvm-project
Make the AST explicitly represent the cast of the first operand of a
pointer-to-member operator. llvm-svn: 93592
This commit is contained in:
parent
6d8f59e65f
commit
1fcf66b0dd
|
@ -1450,12 +1450,14 @@ QualType Sema::CheckPointerToMemberOperands(
|
||||||
// overkill?
|
// overkill?
|
||||||
if (!IsDerivedFrom(LType, Class, Paths) ||
|
if (!IsDerivedFrom(LType, Class, Paths) ||
|
||||||
Paths.isAmbiguous(Context.getCanonicalType(Class))) {
|
Paths.isAmbiguous(Context.getCanonicalType(Class))) {
|
||||||
const char *ReplaceStr = isIndirect ? ".*" : "->*";
|
|
||||||
Diag(Loc, diag::err_bad_memptr_lhs) << OpSpelling
|
Diag(Loc, diag::err_bad_memptr_lhs) << OpSpelling
|
||||||
<< (int)isIndirect << lex->getType() <<
|
<< (int)isIndirect << lex->getType();
|
||||||
CodeModificationHint::CreateReplacement(SourceRange(Loc), ReplaceStr);
|
|
||||||
return QualType();
|
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())) {
|
if (isa<CXXZeroInitValueExpr>(rex->IgnoreParens())) {
|
||||||
|
|
|
@ -139,3 +139,14 @@ namespace PR5940 {
|
||||||
void (foo::*ptr)(void) = &foo::baz;
|
void (foo::*ptr)(void) = &foo::baz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace MemberPointerImpCast {
|
||||||
|
struct A {
|
||||||
|
int x;
|
||||||
|
};
|
||||||
|
struct B : public A {
|
||||||
|
};
|
||||||
|
void f(B* obj, void (A::*method)()) {
|
||||||
|
(obj->*method)();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue