summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-12 23:42:09 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-12 23:42:09 +0000
commit2c326bce387c87b58e578d729b5942e3a50cf365 (patch)
treeb8f858a88ab2f9609548ef8516da0e907ec13da1 /clang/lib/Sema/SemaOverload.cpp
parent5c0066f1cf88d57b7f10ea6c85e95e60d6e803b6 (diff)
downloadbcm5719-llvm-2c326bce387c87b58e578d729b5942e3a50cf365.tar.gz
bcm5719-llvm-2c326bce387c87b58e578d729b5942e3a50cf365.zip
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. llvm-svn: 101089
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index fa8e3600f5f..cfc8068b96c 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/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: {
OpenPOWER on IntegriCloud