]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/f-lang.c
Split out eval_op_f_floor
[thirdparty/binutils-gdb.git] / gdb / f-lang.c
index f3fce2240d5ef07d8fbf1824e624790f74f0683a..bd1605294e59e2b0b3437ed74199d8f0aff88815 100644 (file)
@@ -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:
       {