diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-10-08 16:34:58 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-10-22 09:24:43 +0100 |
commit | 6b4c676cc7f48f656cf235dd0507c41ab11d7cb5 (patch) | |
tree | 2aaee877ea0ddba4b3c99541a394833252b44b6d /gdb/f-exp.y | |
parent | f2d8e4c59770975415585af20b3d4249ff57b36e (diff) | |
download | gdb-6b4c676cc7f48f656cf235dd0507c41ab11d7cb5.zip gdb-6b4c676cc7f48f656cf235dd0507c41ab11d7cb5.tar.gz gdb-6b4c676cc7f48f656cf235dd0507c41ab11d7cb5.tar.bz2 |
gdb/fortran: add support for parsing array strides in expressions
With this commit GDB now understands the syntax of Fortran array
strides, a user can type an expression including an array stride, but
they will only get an error informing them that array strides are not
supported.
This alone is an improvement on what we had before in GDB, better to
give the user a helpful message that a particular feature is not
supported than to just claim a syntax error.
Before:
(gdb) p array (1:10:2, 2:10:2)
A syntax error in expression, near `:2, 2:10:2)'.
Now:
(gdb) p array (1:10:2, 2:10:2)
Fortran array strides are not currently supported
Later commits will allow GDB to handle array strides correctly.
gdb/ChangeLog:
* expprint.c (dump_subexp_body_standard): Print RANGE_HAS_STRIDE.
* expression.h (enum range_type): Add RANGE_HAS_STRIDE.
* f-exp.y (arglist): Allow for a series of subranges.
(subrange): Add cases for subranges with strides.
* f-lang.c (value_f90_subarray): Catch use of array strides and
throw an error.
* parse.c (operator_length_standard): Handle RANGE_HAS_STRIDE.
gdb/testsuite/ChangeLog:
* gdb.fortran/array-slices.exp: Add a new test.
Diffstat (limited to 'gdb/f-exp.y')
-rw-r--r-- | gdb/f-exp.y | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gdb/f-exp.y b/gdb/f-exp.y index a331408..eaa7214 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -284,6 +284,10 @@ arglist : arglist ',' exp %prec ABOVE_COMMA { pstate->arglist_len++; } ; +arglist : arglist ',' subrange %prec ABOVE_COMMA + { pstate->arglist_len++; } + ; + /* There are four sorts of subrange types in F90. */ subrange: exp ':' exp %prec ABOVE_COMMA @@ -314,6 +318,38 @@ subrange: ':' %prec ABOVE_COMMA write_exp_elt_opcode (pstate, OP_RANGE); } ; +/* And each of the four subrange types can also have a stride. */ +subrange: exp ':' exp ':' exp %prec ABOVE_COMMA + { write_exp_elt_opcode (pstate, OP_RANGE); + write_exp_elt_longcst (pstate, RANGE_HAS_STRIDE); + write_exp_elt_opcode (pstate, OP_RANGE); } + ; + +subrange: exp ':' ':' exp %prec ABOVE_COMMA + { write_exp_elt_opcode (pstate, OP_RANGE); + write_exp_elt_longcst (pstate, + (RANGE_HIGH_BOUND_DEFAULT + | RANGE_HAS_STRIDE)); + write_exp_elt_opcode (pstate, OP_RANGE); } + ; + +subrange: ':' exp ':' exp %prec ABOVE_COMMA + { write_exp_elt_opcode (pstate, OP_RANGE); + write_exp_elt_longcst (pstate, + (RANGE_LOW_BOUND_DEFAULT + | RANGE_HAS_STRIDE)); + write_exp_elt_opcode (pstate, OP_RANGE); } + ; + +subrange: ':' ':' exp %prec ABOVE_COMMA + { write_exp_elt_opcode (pstate, OP_RANGE); + write_exp_elt_longcst (pstate, + (RANGE_LOW_BOUND_DEFAULT + | RANGE_HIGH_BOUND_DEFAULT + | RANGE_HAS_STRIDE)); + write_exp_elt_opcode (pstate, OP_RANGE); } + ; + complexnum: exp ',' exp { } ; |