diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-04-12 23:42:09 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-04-12 23:42:09 +0000 |
commit | c520c84f7e9c2d8d4a66ac438e10d815daaeae64 (patch) | |
tree | 27dc9d095c38115d0d7013244dc9e9a70b47ea56 /lib | |
parent | 05baacbfd67017b2724f3e0503fd23609f5d32bc (diff) |
Implement C++ [over.ics.user]p3, which restricts the final conversion
from a conversion function template specialization to one of exact
match rank. We only know how to test this in C++0x with default
function template arguments, but it's also in the C++03 spec. Fixes
PR6285.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101089 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 12 | ||||
-rw-r--r-- | lib/Sema/SemaOverload.h | 6 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index fa8e3600f5..cfc8068b96 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -2819,6 +2819,17 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion, switch (ICS.getKind()) { case ImplicitConversionSequence::StandardConversion: Candidate.FinalConversion = ICS.Standard; + + // C++ [over.ics.user]p3: + // If the user-defined conversion is specified by a specialization of a + // conversion function template, the second standard conversion sequence + // shall have exact match rank. + if (Conversion->getPrimaryTemplate() && + GetConversionRank(ICS.Standard.Second) != ICR_Exact_Match) { + Candidate.Viable = false; + Candidate.FailureKind = ovl_fail_final_conversion_not_exact; + } + break; case ImplicitConversionSequence::BadConversion: @@ -4628,6 +4639,7 @@ void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand, case ovl_fail_trivial_conversion: case ovl_fail_bad_final_conversion: + case ovl_fail_final_conversion_not_exact: return S.NoteOverloadCandidate(Fn); case ovl_fail_bad_conversion: { diff --git a/lib/Sema/SemaOverload.h b/lib/Sema/SemaOverload.h index d6b46e91c9..2b9604ac14 100644 --- a/lib/Sema/SemaOverload.h +++ b/lib/Sema/SemaOverload.h @@ -440,7 +440,11 @@ namespace clang { /// This conversion candidate is not viable because its result /// type is not implicitly convertible to the desired type. - ovl_fail_bad_final_conversion + ovl_fail_bad_final_conversion, + + /// This conversion function template specialization candidate is not + /// viable because the final conversion was not an exact match. + ovl_fail_final_conversion_not_exact }; /// OverloadCandidate - A single candidate in an overload set (C++ 13.3). |