aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:06 -0700
commit3c18c49c63f8dcdacbb33c2e8f2582789e39487b (patch)
treec32c00d429a97e535102fe832309e261ced7a9b1
parent216f6fcbefa770589def331a4bcd1d244fbaf858 (diff)
downloadgdb-3c18c49c63f8dcdacbb33c2e8f2582789e39487b.zip
gdb-3c18c49c63f8dcdacbb33c2e8f2582789e39487b.tar.gz
gdb-3c18c49c63f8dcdacbb33c2e8f2582789e39487b.tar.bz2
Split out fortran_require_array
This splits out a helper function, fortran_require_array, that will be used in a later patch. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * f-lang.c (fortran_require_array): New function. (evaluate_subexp_f): Use it.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/f-lang.c26
2 files changed, 23 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0958f59..6450bbe 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * f-lang.c (fortran_require_array): New function.
+ (evaluate_subexp_f): Use it.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* f-lang.c (eval_op_f_kind): New function.
(evaluate_subexp_f): Use it.
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 659b0c8..0ee2806 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -130,6 +130,23 @@ const struct op_print f_language::op_print_tab[] =
};
+/* A helper function for the "bound" intrinsics that checks that TYPE
+ is an array. LBOUND_P is true for lower bound; this is used for
+ the error message, if any. */
+
+static void
+fortran_require_array (struct type *type, bool lbound_p)
+{
+ type = check_typedef (type);
+ if (type->code () != TYPE_CODE_ARRAY)
+ {
+ if (lbound_p)
+ error (_("LBOUND can only be applied to arrays"));
+ else
+ error (_("UBOUND can only be applied to arrays"));
+ }
+}
+
/* Create an array containing the lower bounds (when LBOUND_P is true) or
the upper bounds (when LBOUND_P is false) of ARRAY (which must be of
array type). GDBARCH is the current architecture. */
@@ -1228,14 +1245,7 @@ evaluate_subexp_f (struct type *expect_type, struct expression *exp,
/* Check that the first argument is array like. */
arg1 = evaluate_subexp (nullptr, exp, pos, noside);
- type = check_typedef (value_type (arg1));
- if (type->code () != TYPE_CODE_ARRAY)
- {
- if (lbound_p)
- error (_("LBOUND can only be applied to arrays"));
- else
- error (_("UBOUND can only be applied to arrays"));
- }
+ fortran_require_array (value_type (arg1), lbound_p);
if (nargs == 1)
return fortran_bounds_all_dims (lbound_p, exp->gdbarch, arg1);