[C++ PATCH] [PR13997] Fix partial ordering of array types (regression 3.4/3.5)

Giovanni Bajo giovannibajo@libero.it
Wed Feb 4 01:06:00 GMT 2004


Hello,

This is a fallout of a patch of mines:
http://gcc.gnu.org/ml/gcc-patches/2004-01/msg00822.html

My fix to tsubst <INTEGER_TYPE> for array domains was assuming that subsequent
code (compute_array_index_type) was able to properly check for value
dependness. This was untrue in some cases, for instance while trying to order
between two different partial specializations. The following patch cures this,
in exactly the same way it's already cured in more_specialized for function
templates.

Tested on i686-pc-linux-gnu, OK for 3.4/mainline?

Giovanni Bajo


cp/
2003-02-03  Giovanni Bajo  <giovannibajo@gcc.gnu.org>

        * pt.c (more_specialized_class): Increase processing_template_decl
        while partial ordering.


testsuite/
2003-02-03  Giovanni Bajo  <giovannibajo@gcc.gnu.org>

        * g++.dg/template/partial3.C: New test.


Index: pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.826
diff -c -3 -p -r1.826 pt.c
*** pt.c 3 Feb 2004 16:53:25 -0000 1.826
--- pt.c 3 Feb 2004 19:32:23 -0000
*************** more_specialized_class (tree pat1, tree
*** 10121,10126 ****
--- 10121,10131 ----
    tree targs;
    int winner = 0;

+   /* Just like what happens for functions, if we are ordering between
+      different class template specializations, we may encounter dependent
+      types in the arguments, and we need our dependency check functions
+      to behave correctly.  */
+   ++processing_template_decl;
    targs = get_class_bindings (TREE_VALUE (pat1), TREE_PURPOSE (pat1),
           add_outermost_template_args (full_args, TREE_PURPOSE (pat2)));
    if (targs)
*************** more_specialized_class (tree pat1, tree
*** 10130,10135 ****
--- 10135,10141 ----
           add_outermost_template_args (full_args, TREE_PURPOSE (pat1)));
    if (targs)
      ++winner;
+   --processing_template_decl;

    return winner;
  }



// { dg-do compile }
// Origin: John Maddock <john at johnmaddock dot co dot uk>
// PR c++/13997: Error while matching partial specialization of array type

template <typename T>
struct is_array;

template <typename T, unsigned int N>
struct is_array<T[N]>;

template <typename T, unsigned int N>
struct is_array<const T[N]> {};

template struct is_array<int const[2]>;




More information about the Gcc-patches mailing list