Split out ada_unop_neg
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:10 +0000 (07:28 -0700)
This splits UNOP_NEG into a new function for future use.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

* ada-lang.c (ada_unop_neg): New function.
(ada_evaluate_subexp): Use it.

gdb/ChangeLog
gdb/ada-lang.c

index 6eddb9f4b72b5797312e3179a8a059661d3e0478..7d959f2a2897e10c7de5bf1025fbc4e3878d22fe 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * ada-lang.c (ada_unop_neg): New function.
+       (ada_evaluate_subexp): Use it.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * ada-lang.c (eval_ternop_in_range): New function.
index b311609fe4188d94c568abdc6c4590b4768ff98f..c171e03b339302aac7d012e2f1fde021e8421d18 100644 (file)
@@ -9960,6 +9960,20 @@ eval_ternop_in_range (struct type *expect_type, struct expression *exp,
                            || value_equal (arg2, arg1)));
 }
 
+/* A helper function for UNOP_NEG.  */
+
+static value *
+ada_unop_neg (struct type *expect_type,
+             struct expression *exp,
+             enum noside noside, enum exp_opcode op,
+             struct value *arg1)
+{
+  if (noside == EVAL_SKIP)
+    return eval_skip_value (exp);
+  unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+  return value_neg (arg1);
+}
+
 /* Implement the evaluate_exp routine in the exp_descriptor structure
    for the Ada language.  */
 
@@ -10150,13 +10164,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
 
     case UNOP_NEG:
       arg1 = evaluate_subexp (nullptr, exp, pos, noside);
-      if (noside == EVAL_SKIP)
-       goto nosideret;
-      else
-       {
-         unop_promote (exp->language_defn, exp->gdbarch, &arg1);
-         return value_neg (arg1);
-       }
+      return ada_unop_neg (expect_type, exp, noside, op, arg1);
 
     case BINOP_LOGICAL_AND:
     case BINOP_LOGICAL_OR:
This page took 0.033669 seconds and 4 git commands to generate.