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:
Anders Carlsson 2009-09-15 07:42:44 +00:00
Родитель f6c213a931
Коммит aac6e3a6bb
2 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -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();
};