* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116789
138bc75d-0d04-0410-961f-
82ee72b054a4
+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
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. */
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.
arg_info->tags = tags;
arg_info->types = types;
arg_info->others = others;
+ arg_info->pending_sizes = get_pending_sizes ();
return arg_info;
}
\f
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 ();
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;
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;
ret->tags = 0;
ret->types = 0;
ret->others = 0;
+ ret->pending_sizes = 0;
ret->had_vla_unspec = 0;
return ret;
}
ret->tags = 0;
ret->types = 0;
ret->others = 0;
+ ret->pending_sizes = 0;
ret->had_vla_unspec = 0;
return ret;
}
/* 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;
};
+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
--- /dev/null
+/* 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])) {}