[cfe-commits] r81852 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/CodeGenCXX/conversion-function.cpp
Anders Carlsson
andersca at mac.com
Tue Sep 15 00:42:44 PDT 2009
Author: andersca
Date: Tue Sep 15 02:42:44 2009
New Revision: 81852
URL: http://llvm.org/viewvc/llvm-project?rev=81852&view=rev
Log:
If a conversion operator exists in a base class, make sure to cast the object to that base class.
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/CodeGenCXX/conversion-function.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=81852&r1=81851&r2=81852&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Sep 15 02:42:44 2009
@@ -1991,9 +1991,15 @@
}
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());
Modified: cfe/trunk/test/CodeGenCXX/conversion-function.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/conversion-function.cpp?rev=81852&r1=81851&r2=81852&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/conversion-function.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/conversion-function.cpp Tue Sep 15 02:42:44 2009
@@ -79,11 +79,13 @@
// 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();
};
More information about the cfe-commits
mailing list