From 419cca029e5d4b9b648402f9da3c38f302ca7b0a Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Tue, 25 Aug 2020 10:25:32 +0100 Subject: Revert "Fix for Bug 26372 [Modula-2] Parsing of multi-subscript arrays" This reverts commit 07758bdfa9e5a762f2ec0deeb51b11d6ad5fe376. --- gdb/m2-exp.y | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'gdb/m2-exp.y') diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index dba331f..70a3d9c 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -293,18 +293,21 @@ set : '{' arglist '}' ; -/* Modula-2 array subscript notation [a,b,c...]. */ -exp : exp '[' ArgumentList ']' %prec DOT - { - if (pstate->arglist_len > 1) - { - write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT); - write_exp_elt_longcst (pstate, pstate->arglist_len); - write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT); - } - else - write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT); - } +/* Modula-2 array subscript notation [a,b,c...] */ +exp : exp '[' + /* This function just saves the number of arguments + that follow in the list. It is *not* specific to + function types */ + { pstate->start_arglist(); } + non_empty_arglist ']' %prec DOT + { write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT); + write_exp_elt_longcst (pstate, + pstate->end_arglist()); + write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT); } + ; + +exp : exp '[' exp ']' + { write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT); } ; exp : exp '(' @@ -318,22 +321,24 @@ exp : exp '(' write_exp_elt_opcode (pstate, OP_FUNCALL); } ; -/* Non empty argument list. */ -ArgumentList: - exp +arglist : + ; + +arglist : exp { pstate->arglist_len = 1; } -| ArgumentList ',' exp - { pstate->arglist_len++; } ; -arglist : +arglist : arglist ',' exp %prec ABOVE_COMMA + { pstate->arglist_len++; } ; -arglist : exp +non_empty_arglist + : exp { pstate->arglist_len = 1; } ; -arglist : arglist ',' exp %prec ABOVE_COMMA +non_empty_arglist + : non_empty_arglist ',' exp %prec ABOVE_COMMA { pstate->arglist_len++; } ; -- cgit v1.1