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:
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: {
/// 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).
--- /dev/null
+// RUN: %clang_cc1 -fsyntax-only -std=c++0x -verify %s
+
+namespace PR6285 {
+ template<typename T> struct identity
+ { typedef T type; };
+
+ struct D {
+ template<typename T = short>
+ operator typename identity<T>::type(); // expected-note{{candidate}}
+ };
+
+ int f() { return D(); } // expected-error{{no viable conversion}}
+}
+