Implement partial ordering of function templates when calling a

conversion function.

llvm-svn: 81807
This commit is contained in:
Douglas Gregor
2009-09-14 23:02:14 +00:00
parent 2e0807cd75
commit 6010da024c
2 changed files with 12 additions and 2 deletions

View File

@@ -3711,7 +3711,8 @@ Sema::isBetterOverloadCandidate(const OverloadCandidate& Cand1,
if (FunctionTemplateDecl *BetterTemplate
= getMoreSpecializedTemplate(Cand1.Function->getPrimaryTemplate(),
Cand2.Function->getPrimaryTemplate(),
TPOC_Call))
isa<CXXConversionDecl>(Cand1.Function)? TPOC_Conversion
: TPOC_Call))
return BetterTemplate == Cand1.Function->getPrimaryTemplate();
// -- the context is an initialization by user-defined conversion

View File

@@ -1,5 +1,4 @@
// RUN: clang-cc -fsyntax-only -verify %s
template<typename T>
int &f0(T);
@@ -84,3 +83,13 @@ void test_f6(int i, const int ic) {
int &ir = f6(i, i);
float &fr = f6(ic, ic);
}
struct CrazyFun {
template<typename T, typename U> operator A<T, U>();
template<typename T> operator A<T, T>();
};
void fun(CrazyFun cf) {
A<int, float> aif = cf;
A<int, int> aii = cf;
}