diff options
author | Tom Tromey <tom@tromey.com> | 2021-03-08 07:27:57 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-03-08 07:28:07 -0700 |
commit | 9cbd1c2011286ac8982f9d606390d3359f78f9c8 (patch) | |
tree | 44a54650d8b23a16adfcf2d4a3c379f15c8efa8e /gdb/f-lang.c | |
parent | 3c18c49c63f8dcdacbb33c2e8f2582789e39487b (diff) | |
download | gdb-9cbd1c2011286ac8982f9d606390d3359f78f9c8.zip gdb-9cbd1c2011286ac8982f9d606390d3359f78f9c8.tar.gz gdb-9cbd1c2011286ac8982f9d606390d3359f78f9c8.tar.bz2 |
Split out eval_op_f_allocated
This splits out a helper function, eval_op_f_allocated, that will be
used in a later patch.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* f-lang.c (eval_op_f_allocated): New function.
(evaluate_subexp_f): Use it.
Diffstat (limited to 'gdb/f-lang.c')
-rw-r--r-- | gdb/f-lang.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 0ee2806..1fb4e63 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -1175,6 +1175,22 @@ eval_op_f_kind (struct type *expect_type, struct expression *exp, TYPE_LENGTH (TYPE_TARGET_TYPE (type))); } +/* A helper function for UNOP_FORTRAN_ALLOCATED. */ + +static struct value * +eval_op_f_allocated (struct type *expect_type, struct expression *exp, + enum noside noside, enum exp_opcode op, + struct value *arg1) +{ + struct type *type = check_typedef (value_type (arg1)); + if (type->code () != TYPE_CODE_ARRAY) + error (_("ALLOCATED can only be applied to arrays")); + struct type *result_type + = builtin_f_type (exp->gdbarch)->builtin_logical; + LONGEST result_value = type_not_allocated (type) ? 0 : 1; + return value_from_longest (result_type, result_value); +} + /* Special expression evaluation cases for Fortran. */ static struct value * @@ -1218,13 +1234,7 @@ evaluate_subexp_f (struct type *expect_type, struct expression *exp, arg1 = evaluate_subexp (nullptr, exp, pos, noside); if (noside == EVAL_SKIP) return eval_skip_value (exp); - type = check_typedef (value_type (arg1)); - if (type->code () != TYPE_CODE_ARRAY) - error (_("ALLOCATED can only be applied to arrays")); - struct type *result_type - = builtin_f_type (exp->gdbarch)->builtin_logical; - LONGEST result_value = type_not_allocated (type) ? 0 : 1; - return value_from_longest (result_type, result_value); + return eval_op_f_allocated (expect_type, exp, noside, op, arg1); } case BINOP_FORTRAN_MODULO: |