mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-10-17 12:53:17 +08:00
gdb/fortran: add support for RANK keyword
gfortran supports the RANK keyword, see: https://gcc.gnu.org/onlinedocs/gfortran/RANK.html#RANK this commit adds support for this keyword to GDB's Fortran expression parser. gdb/ChangeLog: * f-exp.h (eval_op_f_rank): Declare. (expr::fortran_rank_operation): New typedef. * f-exp.y (exp): Handle UNOP_FORTRAN_RANK after parsing an UNOP_INTRINSIC. (f77_keywords): Add "rank" keyword. * f-lang.c (eval_op_f_rank): New function. * std-operator.def (UNOP_FORTRAN_RANK): New operator. gdb/testsuite/ChangeLog: * gdb.fortran/rank.exp: New file. * gdb.fortran/rank.f90: New file.
This commit is contained in:
20
gdb/f-lang.c
20
gdb/f-lang.c
@ -773,6 +773,26 @@ eval_op_f_allocated (struct type *expect_type, struct expression *exp,
|
||||
return value_from_longest (result_type, result_value);
|
||||
}
|
||||
|
||||
/* See f-exp.h. */
|
||||
|
||||
struct value *
|
||||
eval_op_f_rank (struct type *expect_type,
|
||||
struct expression *exp,
|
||||
enum noside noside,
|
||||
enum exp_opcode op,
|
||||
struct value *arg1)
|
||||
{
|
||||
gdb_assert (op == UNOP_FORTRAN_RANK);
|
||||
|
||||
struct type *result_type
|
||||
= builtin_f_type (exp->gdbarch)->builtin_integer;
|
||||
struct type *type = check_typedef (value_type (arg1));
|
||||
if (type->code () != TYPE_CODE_ARRAY)
|
||||
return value_from_longest (result_type, 0);
|
||||
LONGEST ndim = calc_f77_array_dims (type);
|
||||
return value_from_longest (result_type, ndim);
|
||||
}
|
||||
|
||||
namespace expr
|
||||
{
|
||||
|
||||
|
Reference in New Issue
Block a user