aboutsummaryrefslogtreecommitdiff
path: root/gdb/m2-exp.y
diff options
context:
space:
mode:
authorGaius Mulley <gaiusmod2@gmail.com>2020-08-25 11:16:56 +0200
committerTom de Vries <tdevries@suse.de>2020-08-25 11:16:56 +0200
commit07758bdfa9e5a762f2ec0deeb51b11d6ad5fe376 (patch)
treea5ff4eb1a519c45afde966c03689e2d86ba81ca3 /gdb/m2-exp.y
parent2677f2d3fdb07cc77d0d88e52fb37dfb6217dec9 (diff)
downloadgdb-07758bdfa9e5a762f2ec0deeb51b11d6ad5fe376.zip
gdb-07758bdfa9e5a762f2ec0deeb51b11d6ad5fe376.tar.gz
gdb-07758bdfa9e5a762f2ec0deeb51b11d6ad5fe376.tar.bz2
Fix for Bug 26372 [Modula-2] Parsing of multi-subscript arrays
Here is a bugfix for Pr 26372 [Modula-2] Parsing of multi-subscript arrays. Also included is a dejagnu testcase. No extra regressions are caused on Debian GNU/Linux Buster amd64. gdb/ChangeLog: 2020-08-25 Gaius Mulley <gaiusmod2@gmail.com> PR m2/26372 * m2-exp.y: Rewrite array subscript rules to support multidimension array access. (ArgumentList) replaces non_empty_arglist. gdb/testsuite/ChangeLog: 2020-08-25 Gaius Mulley <gaiusmod2@gmail.com> PR m2/26372 * testsuite/gdb.modula2/multidim.exp: New file. * testsuite/gdb.modula2/multidim.c: New file.
Diffstat (limited to 'gdb/m2-exp.y')
-rw-r--r--gdb/m2-exp.y45
1 files changed, 20 insertions, 25 deletions
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
index 70a3d9c..dba331f 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp.y
@@ -293,21 +293,18 @@ set : '{' arglist '}'
;
-/* 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); }
+/* 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);
+ }
;
exp : exp '('
@@ -321,24 +318,22 @@ exp : exp '('
write_exp_elt_opcode (pstate, OP_FUNCALL); }
;
-arglist :
- ;
-
-arglist : exp
+/* Non empty argument list. */
+ArgumentList:
+ exp
{ pstate->arglist_len = 1; }
+| ArgumentList ',' exp
+ { pstate->arglist_len++; }
;
-arglist : arglist ',' exp %prec ABOVE_COMMA
- { pstate->arglist_len++; }
+arglist :
;
-non_empty_arglist
- : exp
+arglist : exp
{ pstate->arglist_len = 1; }
;
-non_empty_arglist
- : non_empty_arglist ',' exp %prec ABOVE_COMMA
+arglist : arglist ',' exp %prec ABOVE_COMMA
{ pstate->arglist_len++; }
;