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:10 -0700
commit82390ab88ce41c4fcc26584de895bb2fc24c697e (patch)
tree64bfee804afd65dade309fe308752671ee7f0316
parent62d4bd947e056a28c2b5086fa82a84b0721b3c97 (diff)
downloadgdb-82390ab88ce41c4fcc26584de895bb2fc24c697e.zip
gdb-82390ab88ce41c4fcc26584de895bb2fc24c697e.tar.gz
gdb-82390ab88ce41c4fcc26584de895bb2fc24c697e.tar.bz2
Split out ada_unop_neg
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.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/ada-lang.c22
2 files changed, 20 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6eddb9f..7d959f2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
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.
(ada_evaluate_subexp): Use it.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index b311609..c171e03 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -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: