re PR c/28504 (ICE with variable sized array)

PR c/28504
	* c-tree.h (struct c_arg_info): Add pending_sizes.
	* c-parser.c (c_parser_parms_declarator,
	c_parser_parms_list_declarator): Initialize pending_sizes.
	* c-decl.c (get_parm_info): Initialize pending_sizes.
	(get_parm_info): Set pending_sizes.
	(grokdeclarator): Call put_pending_sizes for parameters for
	function definition only.

testsuite:
	* gcc.dg/vla-10.c: New test.

From-SVN: r116789
This commit is contained in:
Joseph Myers 2006-09-09 00:41:21 +01:00 committed by Joseph Myers
parent a7b9d08c35
commit 3542a5c0f6
6 changed files with 37 additions and 0 deletions

View file

@ -1,3 +1,14 @@
2006-09-08 Joseph S. Myers <joseph@codesourcery.com>
PR c/28504
* c-tree.h (struct c_arg_info): Add pending_sizes.
* c-parser.c (c_parser_parms_declarator,
c_parser_parms_list_declarator): Initialize pending_sizes.
* c-decl.c (get_parm_info): Initialize pending_sizes.
(get_parm_info): Set pending_sizes.
(grokdeclarator): Call put_pending_sizes for parameters for
function definition only.
2006-09-07 Jason Merrill <jason@redhat.com>
PR middle-end/27724

View file

@ -4420,6 +4420,8 @@ grokdeclarator (const struct c_declarator *declarator,
inner layer of declarator. */
arg_info = declarator->u.arg_info;
arg_types = grokparms (arg_info, really_funcdef);
if (really_funcdef)
put_pending_sizes (arg_info->pending_sizes);
/* Type qualifiers before the return type of the function
qualify the return type, not the function type. */
@ -4981,6 +4983,7 @@ get_parm_info (bool ellipsis)
arg_info->tags = 0;
arg_info->types = 0;
arg_info->others = 0;
arg_info->pending_sizes = 0;
arg_info->had_vla_unspec = current_scope->had_vla_unspec;
/* The bindings in this scope must not get put into a block.
@ -5136,6 +5139,7 @@ get_parm_info (bool ellipsis)
arg_info->tags = tags;
arg_info->types = types;
arg_info->others = others;
arg_info->pending_sizes = get_pending_sizes ();
return arg_info;
}

View file

@ -2537,6 +2537,7 @@ c_parser_parms_declarator (c_parser *parser, bool id_list_ok, tree attrs)
ret->tags = 0;
ret->types = list;
ret->others = 0;
ret->pending_sizes = 0;
ret->had_vla_unspec = 0;
c_parser_consume_token (parser);
pop_scope ();
@ -2579,6 +2580,7 @@ c_parser_parms_list_declarator (c_parser *parser, tree attrs)
ret->tags = 0;
ret->types = 0;
ret->others = 0;
ret->pending_sizes = 0;
ret->had_vla_unspec = 0;
c_parser_consume_token (parser);
return ret;
@ -2589,6 +2591,7 @@ c_parser_parms_list_declarator (c_parser *parser, tree attrs)
ret->parms = 0;
ret->tags = 0;
ret->others = 0;
ret->pending_sizes = 0;
ret->had_vla_unspec = 0;
/* Suppress -Wold-style-definition for this case. */
ret->types = error_mark_node;
@ -2640,6 +2643,7 @@ c_parser_parms_list_declarator (c_parser *parser, tree attrs)
ret->tags = 0;
ret->types = 0;
ret->others = 0;
ret->pending_sizes = 0;
ret->had_vla_unspec = 0;
return ret;
}
@ -2666,6 +2670,7 @@ c_parser_parms_list_declarator (c_parser *parser, tree attrs)
ret->tags = 0;
ret->types = 0;
ret->others = 0;
ret->pending_sizes = 0;
ret->had_vla_unspec = 0;
return ret;
}

View file

@ -309,6 +309,11 @@ struct c_arg_info {
/* A list of non-parameter decls (notably enumeration constants)
defined with the parameters. */
tree others;
/* A list of VLA sizes from the parameters. In a function
definition, these are used to ensure that side-effects in sizes
of arrays converted to pointers (such as a parameter int i[n++])
take place; otherwise, they are ignored. */
tree pending_sizes;
/* True when these arguments had [*]. */
BOOL_BITFIELD had_vla_unspec : 1;
};

View file

@ -1,3 +1,8 @@
2006-09-08 Joseph S. Myers <joseph@codesourcery.com>
PR c/28504
* gcc.dg/vla-10.c: New test.
2006-09-08 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/28858

View file

@ -0,0 +1,7 @@
/* ICE with VLA in nested parameter declaration: should be treated
like [*] instead of the size being expanded. Bug 28504 from Volker
Reichelt <reichelt@gcc.gnu.org>. */
/* { dg-do compile } */
/* { dg-options "" } */
void foo(void (*p)(int n, int x[n])) {}