OSDN Git Service

PR c++/34950
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 19 Feb 2008 22:53:07 +0000 (22:53 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 19 Feb 2008 22:53:07 +0000 (22:53 +0000)
        * pt.c (resolve_overloaded_unification): Set processing_template_decl
        while we look for possible bindings.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132455 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/template/explicit-args1.C [new file with mode: 0644]

index 6f016fc..81a243a 100644 (file)
@@ -1,3 +1,9 @@
+2008-02-19  Jason Merrill  <jason@redhat.com>
+
+       PR c++/34950
+       * pt.c (resolve_overloaded_unification): Set processing_template_decl
+       while we look for possible bindings.
+
 2008-02-19  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/35028
index 5931126..e45f6da 100644 (file)
@@ -12137,6 +12137,7 @@ resolve_overloaded_unification (tree tparms,
          if (TREE_CODE (fn) != TEMPLATE_DECL)
            continue;
 
+         ++processing_template_decl;
          subargs = get_bindings (fn, DECL_TEMPLATE_RESULT (fn),
                                  expl_subargs, /*check_ret=*/false);
          if (subargs)
@@ -12145,6 +12146,7 @@ resolve_overloaded_unification (tree tparms,
              good += try_one_overload (tparms, targs, tempargs, parm,
                                        elem, strict, sub_strict, addr_p);
            }
+         --processing_template_decl;
        }
     }
   else if (TREE_CODE (arg) != OVERLOAD
diff --git a/gcc/testsuite/g++.dg/template/explicit-args1.C b/gcc/testsuite/g++.dg/template/explicit-args1.C
new file mode 100644 (file)
index 0000000..10d59e1
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/34950
+
+template <class T = int> struct policy {
+    typedef int unnecessary;
+};
+
+template <class Policy> struct A {
+    typedef int type;
+    typedef typename Policy::unnecessary unused;
+};
+
+template <class T> struct S {
+    typedef int type;
+    typedef typename A<T>::type unused;
+};
+
+template <class, class T> typename S<T>::type         foo();
+template <class>                   S<policy<> >::type foo();
+
+template <typename T> int def(T);
+const int i = def(foo<int>);