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.
This commit is contained in:
parent
f2d8e4c597
commit
6b4c676cc7
8 changed files with 84 additions and 1 deletions
10
gdb/f-lang.c
10
gdb/f-lang.c
|
@ -124,7 +124,7 @@ value_f90_subarray (struct value *array,
|
|||
struct expression *exp, int *pos, enum noside noside)
|
||||
{
|
||||
int pc = (*pos) + 1;
|
||||
LONGEST low_bound, high_bound;
|
||||
LONGEST low_bound, high_bound, stride;
|
||||
struct type *range = check_typedef (value_type (array)->index_type ());
|
||||
enum range_flag range_flag
|
||||
= (enum range_flag) longest_to_int (exp->elts[pc].longconst);
|
||||
|
@ -141,6 +141,14 @@ value_f90_subarray (struct value *array,
|
|||
else
|
||||
high_bound = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
|
||||
|
||||
if (range_flag & RANGE_HAS_STRIDE)
|
||||
stride = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
|
||||
else
|
||||
stride = 1;
|
||||
|
||||
if (stride != 1)
|
||||
error (_("Fortran array strides are not currently supported"));
|
||||
|
||||
return value_slice (array, low_bound, high_bound - low_bound + 1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue