Split out eval_op_f_allocated
authorTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:27:57 +0000 (07:27 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:28:07 +0000 (07:28 -0700)
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.

gdb/ChangeLog
gdb/f-lang.c

index 6450bbe05f57398e1ba43200a8b498471a4e7aea..e72feb8addb00835822208908eb2d2efe50a5cd8 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * f-lang.c (eval_op_f_allocated): New function.
+       (evaluate_subexp_f): Use it.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * f-lang.c (fortran_require_array): New function.
index 0ee2806f1a1e3841826c85c1db9cb0a627a509fb..1fb4e630bcc17dc86549d798b1cca1e27607ac94 100644 (file)
@@ -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:
This page took 0.035126 seconds and 4 git commands to generate.