aboutsummaryrefslogtreecommitdiff
path: root/gdb/f-lang.c
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
commit9f1a1f3c4f8fd9dd7422bf246ef3d199df22eb18 (patch)
tree044a7532e95deed30076f603d636cab1ea162963 /gdb/f-lang.c
parent3dc41f3cdf92c5ed486f313ababb8b42f0573a15 (diff)
downloadgdb-9f1a1f3c4f8fd9dd7422bf246ef3d199df22eb18.zip
gdb-9f1a1f3c4f8fd9dd7422bf246ef3d199df22eb18.tar.gz
gdb-9f1a1f3c4f8fd9dd7422bf246ef3d199df22eb18.tar.bz2
Split out eval_op_f_floor
This splits UNOP_FORTRAN_FLOOR into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * f-lang.c (eval_op_f_floor): New function. (evaluate_subexp_f): Use it.
Diffstat (limited to 'gdb/f-lang.c')
-rw-r--r--gdb/f-lang.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index f3fce22..bd16052 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -1060,6 +1060,25 @@ eval_op_f_ceil (struct type *expect_type, struct expression *exp,
return value_from_host_double (type, val);
}
+/* A helper function for UNOP_FORTRAN_FLOOR. */
+
+static struct value *
+eval_op_f_floor (struct type *expect_type, struct expression *exp,
+ enum noside noside,
+ struct value *arg1)
+{
+ if (noside == EVAL_SKIP)
+ return eval_skip_value (exp);
+ struct type *type = value_type (arg1);
+ if (type->code () != TYPE_CODE_FLT)
+ error (_("argument to FLOOR must be of type float"));
+ double val
+ = target_float_to_host_double (value_contents (arg1),
+ value_type (arg1));
+ val = floor (val);
+ return value_from_host_double (type, val);
+}
+
/* Special expression evaluation cases for Fortran. */
static struct value *
@@ -1095,19 +1114,8 @@ evaluate_subexp_f (struct type *expect_type, struct expression *exp,
return eval_op_f_ceil (expect_type, exp, noside, arg1);
case UNOP_FORTRAN_FLOOR:
- {
- arg1 = evaluate_subexp (nullptr, exp, pos, noside);
- if (noside == EVAL_SKIP)
- return eval_skip_value (exp);
- type = value_type (arg1);
- if (type->code () != TYPE_CODE_FLT)
- error (_("argument to FLOOR must be of type float"));
- double val
- = target_float_to_host_double (value_contents (arg1),
- value_type (arg1));
- val = floor (val);
- return value_from_host_double (type, val);
- }
+ arg1 = evaluate_subexp (nullptr, exp, pos, noside);
+ return eval_op_f_floor (expect_type, exp, noside, arg1);
case UNOP_FORTRAN_ALLOCATED:
{