From: Richard Smith Date: Tue, 10 Jan 2017 20:52:50 +0000 (+0000) Subject: Don't try to check implicit conversion sequences for an object argument if X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=19a05b4ede7f02d2c169bf33ba92b500b096c9ff;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291597 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 514b4af1c9..afdae4ed6d 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -6596,7 +6596,9 @@ Sema::AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, Candidate.Function = MethodTmpl->getTemplatedDecl(); Candidate.Viable = false; Candidate.IsSurrogate = false; - Candidate.IgnoreObjectArgument = false; + Candidate.IgnoreObjectArgument = + cast(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(Candidate.Function) && + !isa(Candidate.Function); Candidate.ExplicitCallArguments = Args.size(); if (Result == TDK_NonDependentConversionFailure) Candidate.FailureKind = ovl_fail_bad_conversion; diff --git a/test/SemaTemplate/deduction.cpp b/test/SemaTemplate/deduction.cpp index 419464447d..16e01a9346 100644 --- a/test/SemaTemplate/deduction.cpp +++ b/test/SemaTemplate/deduction.cpp @@ -385,10 +385,21 @@ namespace deduction_after_explicit_pack { void q() { p(X(0), 0); } // expected-error {{no match}} struct A { - template 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 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 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 {