This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR C++/28886, Template specialization with array rejected
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 30 Aug 2006 08:37:12 -0700
- Subject: [PATCH] Fix PR C++/28886, Template specialization with array rejected
The problem here is that fold will produce a NON_LVALUE_EXPR when
figuring out the size of the array but we are not ready to handle that.
This patch fixes the problem by stripping out the NON_LVALUE_EXPR right
after the fold that adds it.
OK? Bootstrapped and tested on i686-linux-gnu with no regressions.
Thanks,
Andrew Pinski
cp/ChangeLog:
* pt.c (unify): Strip nops that don't change the type after
calling fold for finding the length of the array.
testsuite/ChangeLog:
* g++.dg/template/partial-specialization-array.C: New test.
Index: testsuite/g++.dg/template/partial-specialization-array.C
===================================================================
--- testsuite/g++.dg/template/partial-specialization-array.C (revision 0)
+++ testsuite/g++.dg/template/partial-specialization-array.C (revision 0)
@@ -0,0 +1,7 @@
+template<typename> struct A;
+
+template<typename T, int N> struct A<T[N]> {};
+
+template<typename T, int N> struct A<const T[N]> {};
+
+A<const int[1]> a;
Index: cp/pt.c
===================================================================
--- cp/pt.c (revision 116579)
+++ cp/pt.c (working copy)
@@ -10627,6 +10627,8 @@ unify (tree tparms, tree targs, tree par
integer_type_node,
arg_max,
TREE_OPERAND (parm_max, 1));
+ /* Strip the NON_LVALUE_EXPRs that could show up via fold. */
+ STRIP_TYPE_NOPS (arg_max);
parm_max = TREE_OPERAND (parm_max, 0);
}