diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-01-10 20:52:50 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-01-10 20:52:50 +0000 |
commit | 9d05e15c3a26c92ea6439fed7dfee37ee05c07ed (patch) | |
tree | 92ac40f4de8b37837322c786fbe5ec9d00678ff0 /clang | |
parent | 14ead30ab8bcd2ddf627b828a8765bcce21731e9 (diff) | |
download | bcm5719-llvm-9d05e15c3a26c92ea6439fed7dfee37ee05c07ed.tar.gz bcm5719-llvm-9d05e15c3a26c92ea6439fed7dfee37ee05c07ed.zip |
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.
llvm-svn: 291597
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 10 | ||||
-rw-r--r-- | clang/test/SemaTemplate/deduction.cpp | 17 |
2 files changed, 22 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 514b4af1c94..afdae4ed6d7 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/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<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; diff --git a/clang/test/SemaTemplate/deduction.cpp b/clang/test/SemaTemplate/deduction.cpp index 419464447d5..16e01a93463 100644 --- a/clang/test/SemaTemplate/deduction.cpp +++ b/clang/test/SemaTemplate/deduction.cpp @@ -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 { |