This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: PR 23437
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 10 Oct 2005 15:32:33 -0700
- Subject: C++ PATCH: PR 23437
- Reply-to: mark at codesourcery dot com
Giovanni posted this patch in August:
http://gcc.gnu.org/ml/gcc-patches/2005-08/msg01169.html
and I asked for a couple of minor change. The patch never got checked
in, so I made the change, retested, and checked it in.
Tested on x86_64-unknown-linux-gnu, applied on the mainline and on the
4.0 branch.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2005-10-10 Giovanni Bajo <giovannibajo@gcc.gnu.org>
Mark Mitchell <mark@codesourcery.com>
PR c++/23437
* parser.c (cp_parser_template_argument_list): Do not treat
contents of argument list as part of a constant expression.
2005-10-10 Mark Mitchell <mark@codesourcery.com>
PR c++/23437
* g++.dg/template/arg4.C: New test.
Index: gcc/cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.361
diff -c -5 -p -r1.361 parser.c
*** gcc/cp/parser.c 8 Oct 2005 18:11:01 -0000 1.361
--- gcc/cp/parser.c 10 Oct 2005 18:58:12 -0000
*************** cp_parser_template_argument_list (cp_par
*** 8902,8914 ****
--- 8902,8923 ----
unsigned n_args = 0;
unsigned alloced = 10;
tree *arg_ary = fixed_args;
tree vec;
bool saved_in_template_argument_list_p;
+ bool saved_ice_p;
+ bool saved_non_ice_p;
saved_in_template_argument_list_p = parser->in_template_argument_list_p;
parser->in_template_argument_list_p = true;
+ /* Even if the template-id appears in an integral
+ constant-expression, the contents of the argument list do
+ not. */
+ saved_ice_p = parser->integral_constant_expression_p;
+ parser->integral_constant_expression_p = false;
+ saved_non_ice_p = parser->non_integral_constant_expression_p;
+ parser->non_integral_constant_expression_p = false;
do
{
tree argument;
if (n_args)
*************** cp_parser_template_argument_list (cp_par
*** 8938,8947 ****
--- 8947,8958 ----
while (n_args--)
TREE_VEC_ELT (vec, n_args) = arg_ary[n_args];
if (arg_ary != fixed_args)
free (arg_ary);
+ parser->non_integral_constant_expression_p = saved_non_ice_p;
+ parser->integral_constant_expression_p = saved_ice_p;
parser->in_template_argument_list_p = saved_in_template_argument_list_p;
return vec;
}
/* Parse a template-argument.
Index: gcc/testsuite/g++.dg/template/arg4.C
===================================================================
RCS file: gcc/testsuite/g++.dg/template/arg4.C
diff -N gcc/testsuite/g++.dg/template/arg4.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/g++.dg/template/arg4.C 10 Oct 2005 18:59:48 -0000
***************
*** 0 ****
--- 1,7 ----
+ template <void (*p)()> struct S {
+ static const int i = 10;
+ };
+
+ void g();
+
+ int a[S<g>::i];