From 2322197e2feedc950e3aa0e7fd9fc38ad9fd7971 Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Mon, 15 Sep 2008 09:26:22 +0000 Subject: [PATCH] Build AST for [] even if none of the operands has pointer type. This prevents a segfault in the AST printer. Also always set a return type, even if the ] is missing. [r21962] --- parser.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/parser.c b/parser.c index 7b21630..7bfb77f 100644 --- a/parser.c +++ b/parser.c @@ -6855,19 +6855,18 @@ static expression_t *parse_array_expression(unsigned precedence, orig_type_left, orig_type_inside); } return_type = type_error_type; - array_access->array_ref = create_invalid_expression(); + array_access->array_ref = left; + array_access->index = inside; } + expression->base.type = automatic_type_conversion(return_type); + rem_anchor_token(']'); - if (token.type != ']') { + if (token.type == ']') { + next_token(); + } else { parse_error_expected("Problem while parsing array access", ']', NULL); - return expression; } - next_token(); - - return_type = automatic_type_conversion(return_type); - expression->base.type = return_type; - return expression; } -- 2.20.1