diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-01-11 19:55:36 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-01-11 19:55:36 +0000 |
| commit | b90b66178ef7cdb0247b61b0f2c07ff0c77d4dbb (patch) | |
| tree | 55d6972294fdce75a25175243e10bd3ab6c458e9 | |
| parent | 0662b16ad234f241331191c90753b8de90185207 (diff) | |
| download | bcm5719-llvm-b90b66178ef7cdb0247b61b0f2c07ff0c77d4dbb.tar.gz bcm5719-llvm-b90b66178ef7cdb0247b61b0f2c07ff0c77d4dbb.zip | |
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.
llvm-svn: 93178
| -rw-r--r-- | clang/lib/Sema/SemaTemplateDeduction.cpp | 5 | ||||
| -rw-r--r-- | clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp | 33 |
2 files changed, 37 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index ea79d9fd78c..471d0c2a2ab 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/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/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp index 2530f128a49..8fb736ca031 100644 --- a/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp +++ b/clang/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 <typename T> + void Func() {} + + template <typename R> + void Foo(R (*fp)()); + + void Test() { + Foo(Func<int>); + } +} + +// PR5949 +namespace PR5949 { + struct Bar; + + template <class Container> + void quuz(const Container &cont) { + } + + template<typename T> + int Foo(Bar *b, void (*Baz)(const T &t), T * = 0) { + return 0; + } + + template<typename T> + int Quux(Bar *b, T * = 0) + { + return Foo<T>(b, quuz); + } +} |

