aboutsummaryrefslogtreecommitdiff
path: root/gdb/f-exp.h
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2021-02-25 16:15:52 +0000
committerAndrew Burgess <andrew.burgess@embecosm.com>2021-03-09 09:51:23 +0000
commit7ba155b37073a3512c85f1d7f12dbaed9a6db3e2 (patch)
tree41e98c0082c4cae7c641a83851708fef750eec8e /gdb/f-exp.h
parente14816a8ba5ecf8d7c0125a08afe87fb7d1a6bba (diff)
downloadgdb-7ba155b37073a3512c85f1d7f12dbaed9a6db3e2.zip
gdb-7ba155b37073a3512c85f1d7f12dbaed9a6db3e2.tar.gz
gdb-7ba155b37073a3512c85f1d7f12dbaed9a6db3e2.tar.bz2
gdb/fortran: add support for 'SIZE' keyword
Add support for the 'SIZE' keyword to the Fortran expression parser. This returns the number of elements either in an entire array (passing a single argument to SIZE), or in a particular dimension of an array (passing two arguments to SIZE). At this point I have not added support for the optional third argument to SIZE, which controls the exact integer type of the result. gdb/ChangeLog: * f-exp.y (eval_op_f_array_size): Declare 1 and 2 argument forms of this function. (expr::fortran_array_size_1arg): New type. (expr::fortran_array_size_2arg): Likewise. * f-exp.y (exp): Handle FORTRAN_ARRAY_SIZE after parsing UNOP_OR_BINOP_INTRINSIC. (f77_keywords): Add "size" keyword. * f-lang.c (fortran_array_size): New function. (eval_op_f_array_size): New function, has a 1 arg and 2 arg form. * std-operator.def (FORTRAN_ARRAY_SIZE): New operator. gdb/testsuite/ChangeLog: * gdb.fortran/size.exp: New file. * gdb.fortran/size.f90: New file.
Diffstat (limited to 'gdb/f-exp.h')
-rw-r--r--gdb/f-exp.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/gdb/f-exp.h b/gdb/f-exp.h
index f23c426..fc46c12 100644
--- a/gdb/f-exp.h
+++ b/gdb/f-exp.h
@@ -85,6 +85,30 @@ extern struct value *eval_op_f_rank (struct type *expect_type,
enum exp_opcode op,
struct value *arg1);
+/* Implement expression evaluation for Fortran's SIZE keyword. For
+ EXPECT_TYPE, EXP, and NOSIDE see expression::evaluate (in
+ expression.h). OP will always for FORTRAN_ARRAY_SIZE. ARG1 is the
+ value passed to SIZE if it is only passed a single argument. For the
+ two argument form see the overload of this function below. */
+
+extern struct value *eval_op_f_array_size (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside,
+ enum exp_opcode opcode,
+ struct value *arg1);
+
+/* An overload of EVAL_OP_F_ARRAY_SIZE above, this version takes two
+ arguments, representing the two values passed to Fortran's SIZE
+ keyword. */
+
+extern struct value *eval_op_f_array_size (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside,
+ enum exp_opcode opcode,
+ struct value *arg1,
+ struct value *arg2);
+
+
namespace expr
{
@@ -107,6 +131,10 @@ using fortran_associated_2arg = binop_operation<FORTRAN_ASSOCIATED,
eval_op_f_associated>;
using fortran_rank_operation = unop_operation<UNOP_FORTRAN_RANK,
eval_op_f_rank>;
+using fortran_array_size_1arg = unop_operation<FORTRAN_ARRAY_SIZE,
+ eval_op_f_array_size>;
+using fortran_array_size_2arg = binop_operation<FORTRAN_ARRAY_SIZE,
+ eval_op_f_array_size>;
/* The Fortran "complex" operation. */
class fortran_cmplx_operation