]> granicus.if.org Git - clang/commitdiff
Per the note in C++0x [temp.deduct.call]p4, don't attempt template
authorDouglas Gregor <dgregor@apple.com>
Sun, 9 Oct 2011 22:06:46 +0000 (22:06 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sun, 9 Oct 2011 22:06:46 +0000 (22:06 +0000)
argument deduction against a function parameter that has no deducible
template parameters in it. Fixes PR8598.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141517 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateDeduction.cpp
test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp [new file with mode: 0644]

index 70fdf64e7ca48960565e9d08c0f75e846b983874..03850bb7600876419900d47bd4464c2208e33891 100644 (file)
@@ -2969,16 +2969,19 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
                                                     TDF))
         continue;
 
+      // If we have nothing to deduce, we're done.
+      if (!hasDeducibleTemplateParameters(*this, FunctionTemplate, ParamType))
+        continue;
+
       // Keep track of the argument type and corresponding parameter index,
       // so we can check for compatibility between the deduced A and A.
-      if (hasDeducibleTemplateParameters(*this, FunctionTemplate, ParamType))
-        OriginalCallArgs.push_back(OriginalCallArg(OrigParamType, ArgIdx-1, 
-                                                   ArgType));
+      OriginalCallArgs.push_back(OriginalCallArg(OrigParamType, ArgIdx-1, 
+                                                 ArgType));
 
       if (TemplateDeductionResult Result
-          = ::DeduceTemplateArguments(*this, TemplateParams,
-                                      ParamType, ArgType, Info, Deduced,
-                                      TDF))
+            = ::DeduceTemplateArguments(*this, TemplateParams,
+                                        ParamType, ArgType, Info, Deduced,
+                                        TDF))
         return Result;
 
       continue;
diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp
new file mode 100644 (file)
index 0000000..9236efc
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace PR8598 {
+  template<class T> struct identity { typedef T type; };
+
+  template<class T, class C>
+  void f(T C::*, typename identity<T>::type*){}
+  
+  struct X { void f() {}; };
+  
+  void g() { (f)(&X::f, 0); }
+}