From: Douglas Gregor Date: Mon, 11 Jan 2010 19:55:36 +0000 (+0000) Subject: When resolving a single function template specialization to a X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9e68871f1e99e7e1536f16d5364fd5e2a352e9c4;p=clang When resolving a single function template specialization to a function, be sure to adjust the resulting argument type to a pointer (if necessary). Fixes PR5910 and PR5949. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93178 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index ea79d9fd78..471d0c2a2a 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -1473,8 +1473,11 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, return TDK_FailedOverloadResolution; } - // Get the type of the resolved argument. + // Get the type of the resolved argument, and adjust it per + // C++0x [temp.deduct.call]p3. ArgType = ResolvedArg->getType(); + if (!ParamWasReference && ArgType->isFunctionType()) + ArgType = Context.getPointerType(ArgType); if (ArgType->isPointerType() || ArgType->isMemberPointerType()) TDF |= TDF_IgnoreQualifiers; diff --git a/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp b/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp index 2530f128a4..8fb736ca03 100644 --- a/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp +++ b/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp @@ -9,3 +9,36 @@ void g() { // Z is deduced to be double f("aa",3.0); // expected-error{{no matching}} } + +// PR5910 +namespace PR5910 { + template + void Func() {} + + template + void Foo(R (*fp)()); + + void Test() { + Foo(Func); + } +} + +// PR5949 +namespace PR5949 { + struct Bar; + + template + void quuz(const Container &cont) { + } + + template + int Foo(Bar *b, void (*Baz)(const T &t), T * = 0) { + return 0; + } + + template + int Quux(Bar *b, T * = 0) + { + return Foo(b, quuz); + } +}