OSDN Git Service

PR c++/11834
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Aug 2003 05:50:53 +0000 (05:50 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Aug 2003 05:50:53 +0000 (05:50 +0000)
* pt.c (more_specialized): Bump processing_template_decl.

PR c++/11834
* g++.dg/template/deduce2.C: New test.

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

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

index fc6ae49..8ef1aeb 100644 (file)
@@ -1,3 +1,8 @@
+2003-08-20  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/11834
+       * pt.c (more_specialized): Bump processing_template_decl.
+
 2003-08-21  Jason Merrill  <jason@redhat.com>
 
        PR c++/11614
index 20642c3..c66b5bc 100644 (file)
@@ -9880,6 +9880,10 @@ more_specialized (tree pat1, tree pat2, int deduce, int len)
   tree targs;
   int winner = 0;
 
+  /* If template argument deduction succeeds, we substitute the
+     resulting arguments into non-deduced contexts.  While doing that,
+     we must be aware that we may encounter dependent types.  */
+  ++processing_template_decl;
   targs = get_bindings_real (pat1, DECL_TEMPLATE_RESULT (pat2),
                              NULL_TREE, 0, deduce, len);
   if (targs)
@@ -9889,6 +9893,7 @@ more_specialized (tree pat1, tree pat2, int deduce, int len)
                              NULL_TREE, 0, deduce, len);
   if (targs)
     ++winner;
+  --processing_template_decl;
 
   return winner;
 }
index 7e11352..5670652 100644 (file)
@@ -1,3 +1,8 @@
+2003-08-20  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/11834
+       * g++.dg/template/deduce2.C: New test.
+
 2003-08-21  Josef Zlomek  <zlomekj@suse.cz>
 
        * gcc.c-torture/execute/20030821-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/template/deduce2.C b/gcc/testsuite/g++.dg/template/deduce2.C
new file mode 100644 (file)
index 0000000..bcf77b3
--- /dev/null
@@ -0,0 +1,30 @@
+template <typename T0> struct tuple {
+    typedef tuple<int> tail;
+};
+
+template <> struct tuple<int> {
+};
+
+template <typename L>
+struct length  {
+  static const int i = length<typename tuple<L>::tail>::i;
+};
+
+template<>
+struct length<tuple<int> > {
+    static const int i = 1;
+};
+
+template <int> struct M {};
+
+template <typename A>
+M<length<tuple<A> >::i > foo (A*);
+
+template <typename A>
+M<length<tuple<A> >::i> foo (const A*);
+
+const int i1 = 3;
+
+void bar() {
+  foo (&i1);
+}