From 5bd11b494e012ffb823925c2f9533bf6788e491f Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Thu, 22 Apr 2010 16:19:19 +0000 Subject: [PATCH] Fix C/should_fail/array[13].c: static array parameters require a size. [r27433] --- parser.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/parser.c b/parser.c index 353c70d..4aaa98e 100644 --- a/parser.c +++ b/parser.c @@ -3538,11 +3538,12 @@ static construct_type_t *parse_array_declarator(void) array->type_qualifiers = type_qualifiers; array->is_static = is_static; + expression_t *size = NULL; if (token.type == '*' && look_ahead(1)->type == ']') { array->is_variable = true; next_token(); } else if (token.type != ']') { - expression_t *const size = parse_assignment_expression(); + size = parse_assignment_expression(); /* §6.7.5.2:1 Array size must have integer type */ type_t *const orig_type = size->base.type; @@ -3557,6 +3558,9 @@ static construct_type_t *parse_array_declarator(void) mark_vars_read(size, NULL); } + if (is_static && size == NULL) + errorf(HERE, "static array parameters require a size"); + rem_anchor_token(']'); expect(']', end_error); -- 2.20.1