diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-09-14 20:41:01 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-09-14 20:41:01 +0000 |
commit | b191e2dda9f4dc033cb21f9625a78fe80d4ac105 (patch) | |
tree | 978a90ce448cf27366367c3e737b2bcdc333fc51 /lib/Sema/SemaOverload.cpp | |
parent | 90b6acf414327f953aa696cd64a449a4bd4fbb0d (diff) |
Used visible conversion function api to do overload
resolution of type conversion functions in base and
current class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81784 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 5f9a963c90..3e89a6413a 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -1412,9 +1412,8 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType, if (CXXRecordDecl *FromRecordDecl = dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) { // Add all of the conversion functions as candidates. - // FIXME: Look for conversions in base classes! OverloadedFunctionDecl *Conversions - = FromRecordDecl->getConversionFunctions(); + = FromRecordDecl->getVisibleConversionFunctions(); for (OverloadedFunctionDecl::function_iterator Func = Conversions->function_begin(); Func != Conversions->function_end(); ++Func) { @@ -2427,7 +2426,11 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion, Candidate.Viable = true; Candidate.Conversions.resize(1); Candidate.Conversions[0] = TryObjectArgumentInitialization(From, Conversion); - + // Conversion functions to a different type in the base class is visible in + // the derived class. So, a derived to base conversion should not participate + // in overload resolution. + if (Candidate.Conversions[0].Standard.Second == ICK_Derived_To_Base) + Candidate.Conversions[0].Standard.Second = ICK_Identity; if (Candidate.Conversions[0].ConversionKind == ImplicitConversionSequence::BadConversion) { Candidate.Viable = false; |