]> granicus.if.org Git - clang/commitdiff
When comparing two method overload candidates during overload diagnostics,
authorJohn McCall <rjmccall@apple.com>
Thu, 25 Feb 2010 10:46:05 +0000 (10:46 +0000)
committerJohn McCall <rjmccall@apple.com>
Thu, 25 Feb 2010 10:46:05 +0000 (10:46 +0000)
skip the object argument conversion if either of the candidates didn't
initialize it.

Fixes PR6421, which is such a very straightforward extension of PR6398 that I
should have worked it into the last test case (and therefore caught it then).
Ah well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97135 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/SemaCXX/overload-call.cpp

index 7208b90939a787b954bb3b518c5b52954afce094..cfb4b91996255bacc0a44fec51565522fe76ee66 100644 (file)
@@ -4797,7 +4797,8 @@ struct CompareOverloadCandidatesForDisplay {
         assert(L->Conversions.size() == R->Conversions.size());
 
         int leftBetter = 0;
-        for (unsigned I = 0, E = L->Conversions.size(); I != E; ++I) {
+        unsigned I = (L->IgnoreObjectArgument || R->IgnoreObjectArgument);
+        for (unsigned E = L->Conversions.size(); I != E; ++I) {
           switch (S.CompareImplicitConversionSequences(L->Conversions[I],
                                                        R->Conversions[I])) {
           case ImplicitConversionSequence::Better:
index 21b5da21d8fb30b4a04014a9f613d5caf766b8e8..38a26d38ca3ae6c9c95edf3af44a48ffcf5895de 100644 (file)
@@ -360,12 +360,13 @@ namespace DerivedToBaseVsVoid {
   }
 }
 
-// PR 6398
+// PR 6398 + PR 6421
 namespace test4 {
   class A;
   class B {
     static void foo(); // expected-note {{not viable}}
     static void foo(int*); // expected-note {{not viable}}
+    static void foo(long*); // expected-note {{not viable}}
 
     void bar(A *a) { 
       foo(a); // expected-error {{no matching function for call}}