зеркало из https://github.com/microsoft/clang-1.git
If a conversion operator exists in a base class, make sure to cast the object to that base class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81852 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
f6c213a931
Коммит
aac6e3a6bb
|
@ -1991,9 +1991,15 @@ Sema::OwningExprResult Sema::BuildCXXCastArgument(SourceLocation CastLoc,
|
|||
}
|
||||
|
||||
case CastExpr::CK_UserDefinedConversion: {
|
||||
assert(!From->getType()->isPointerType() && "Arg can't have pointer type!");
|
||||
|
||||
// Cast to base if needed.
|
||||
if (PerformObjectArgumentInitialization(From, Method))
|
||||
return ExprError();
|
||||
|
||||
// Create an implicit member expr to refer to the conversion operator.
|
||||
MemberExpr *ME =
|
||||
new (Context) MemberExpr(From, From->getType()->isPointerType(), Method,
|
||||
new (Context) MemberExpr(From, /*IsArrow=*/false, Method,
|
||||
SourceLocation(), Method->getType());
|
||||
|
||||
|
||||
|
|
|
@ -79,11 +79,13 @@ int main() {
|
|||
|
||||
// Test. Conversion in base class is visible in derived class.
|
||||
class XB {
|
||||
int a;
|
||||
public:
|
||||
operator int();
|
||||
};
|
||||
|
||||
class Yb : public XB {
|
||||
double b;
|
||||
public:
|
||||
operator char();
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче