r291597 - Don't try to check implicit conversion sequences for an object argument if

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 10 12:52:50 PST 2017


Author: rsmith
Date: Tue Jan 10 14:52:50 2017
New Revision: 291597

URL: http://llvm.org/viewvc/llvm-project?rev=291597&view=rev
Log:
Don't try to check implicit conversion sequences for an object argument if
there is no object argument, when early checking of implicit conversion
sequences for a function template fails.

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

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=291597&r1=291596&r2=291597&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Jan 10 14:52:50 2017
@@ -6596,7 +6596,9 @@ Sema::AddMethodTemplateCandidate(Functio
     Candidate.Function = MethodTmpl->getTemplatedDecl();
     Candidate.Viable = false;
     Candidate.IsSurrogate = false;
-    Candidate.IgnoreObjectArgument = false;
+    Candidate.IgnoreObjectArgument =
+        cast<CXXMethodDecl>(Candidate.Function)->isStatic() ||
+        ObjectType.isNull();
     Candidate.ExplicitCallArguments = Args.size();
     if (Result == TDK_NonDependentConversionFailure)
       Candidate.FailureKind = ovl_fail_bad_conversion;
@@ -6658,7 +6660,11 @@ Sema::AddTemplateOverloadCandidate(Funct
     Candidate.Function = FunctionTemplate->getTemplatedDecl();
     Candidate.Viable = false;
     Candidate.IsSurrogate = false;
-    Candidate.IgnoreObjectArgument = false;
+    // Ignore the object argument if there is one, since we don't have an object
+    // type.
+    Candidate.IgnoreObjectArgument =
+        isa<CXXMethodDecl>(Candidate.Function) &&
+        !isa<CXXConstructorDecl>(Candidate.Function);
     Candidate.ExplicitCallArguments = Args.size();
     if (Result == TDK_NonDependentConversionFailure)
       Candidate.FailureKind = ovl_fail_bad_conversion;

Modified: cfe/trunk/test/SemaTemplate/deduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/deduction.cpp?rev=291597&r1=291596&r2=291597&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/deduction.cpp (original)
+++ cfe/trunk/test/SemaTemplate/deduction.cpp Tue Jan 10 14:52:50 2017
@@ -385,10 +385,21 @@ namespace deduction_after_explicit_pack
   void q() { p(X<int>(0), 0); } // expected-error {{no match}}
 
   struct A {
-    template <typename T> void f(T, void *, int = 0); // expected-note {{no known conversion from 'double' to 'void *' for 2nd argument}}
-    void f(); // expected-note {{requires 0}}
+    template <typename T> void f(T, void *, int = 0); // expected-note 2{{no known conversion from 'double' to 'void *' for 2nd argument}}
+    void f(); // expected-note 2{{requires 0}}
+
+    template <typename T> static void g(T, void *, int = 0); // expected-note 2{{no known conversion from 'double' to 'void *' for 2nd argument}}
+    void g(); // expected-note 2{{requires 0}}
+
+    void h() {
+      f(1.0, 2.0); // expected-error {{no match}}
+      g(1.0, 2.0); // expected-error {{no match}}
+    }
   };
-  void f(A a) { a.f(1.0, 2.0); } // expected-error {{no match}}
+  void f(A a) {
+    a.f(1.0, 2.0); // expected-error {{no match}}
+    a.g(1.0, 2.0); // expected-error {{no match}}
+  }
 }
 
 namespace overload_vs_pack {




More information about the cfe-commits mailing list