]> granicus.if.org Git - clang/commitdiff
When resolving a single function template specialization to a
authorDouglas Gregor <dgregor@apple.com>
Mon, 11 Jan 2010 19:55:36 +0000 (19:55 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 11 Jan 2010 19:55:36 +0000 (19:55 +0000)
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

lib/Sema/SemaTemplateDeduction.cpp
test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp

index ea79d9fd78c6a8c575a217d31c8f9eab03a00552..471d0c2a2ab22baec616473f45bc8a7b92444caf 100644 (file)
@@ -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;
       
index 2530f128a49d42559cc4283d3b59dcaf27b1a94d..8fb736ca0313e26a6d4942aa545a23a4a454bac8 100644 (file)
@@ -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);
+  }
+}