]> granicus.if.org Git - clang/commitdiff
Don't try to check implicit conversion sequences for an object argument if
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 10 Jan 2017 20:52:50 +0000 (20:52 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 10 Jan 2017 20:52:50 +0000 (20:52 +0000)
there is no object argument, when early checking of implicit conversion
sequences for a function template fails.

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

lib/Sema/SemaOverload.cpp
test/SemaTemplate/deduction.cpp

index 514b4af1c94fe547bb2022c4551f43c9efa2ebe1..afdae4ed6d7d357d0e5a4a62590ab01f57209599 100644 (file)
@@ -6596,7 +6596,9 @@ Sema::AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl,
     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(FunctionTemplateDecl *FunctionTemplate,
     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;
index 419464447d500ac2acbb12ddc20cc8b94776d35b..16e01a934630d1c7b128313dd6b4f107991e49d1 100644 (file)
@@ -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 {