[cfe-commits] r81807 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaTemplate/temp_func_order.cpp

Douglas Gregor dgregor at apple.com
Mon Sep 14 16:02:14 PDT 2009


Author: dgregor
Date: Mon Sep 14 18:02:14 2009
New Revision: 81807

URL: http://llvm.org/viewvc/llvm-project?rev=81807&view=rev
Log:
Implement partial ordering of function templates when calling a
conversion function.

Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaTemplate/temp_func_order.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=81807&r1=81806&r2=81807&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Sep 14 18:02:14 2009
@@ -3711,7 +3711,8 @@
     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

Modified: cfe/trunk/test/SemaTemplate/temp_func_order.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_func_order.cpp?rev=81807&r1=81806&r2=81807&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/temp_func_order.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_func_order.cpp Mon Sep 14 18:02:14 2009
@@ -1,5 +1,4 @@
 // RUN: clang-cc -fsyntax-only -verify %s
-
 template<typename T>
 int &f0(T);
 
@@ -84,3 +83,13 @@
   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;  
+}





More information about the cfe-commits mailing list