aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-12-27 13:36:55 -0700
committerTom Tromey <tom@tromey.com>2020-12-27 13:36:55 -0700
commitc8f02daac9e367c7c2dc4c3ce08e85c733a56c7c (patch)
treec9c0eff97eb5493330f2515f10d9d79a5b1af068
parent9e87bc7f0fe304ba506bd26c8d818dd57b7d0eb4 (diff)
downloadfsf-binutils-gdb-c8f02daac9e367c7c2dc4c3ce08e85c733a56c7c.zip
fsf-binutils-gdb-c8f02daac9e367c7c2dc4c3ce08e85c733a56c7c.tar.gz
fsf-binutils-gdb-c8f02daac9e367c7c2dc4c3ce08e85c733a56c7c.tar.bz2
Simplify MULTI_SUBSCRIPT implementation
The MULTI_SUBSCRIPT code in evaluate_subexp_standard has a comment saying that perhaps the EVAL_SKIP handling is incorrect. This patch simplifies this code. In particular, it precomputes all the indices in a separate loop and removes some complicated flow-control. Tested using the gdb.modula2 and gdb.dlang test suites, as these are the only parsers that emit MULTI_SUBSCRIPT. gdb/ChangeLog 2020-12-27 Tom Tromey <tom@tromey.com> * eval.c (evaluate_subexp_standard) <case MULTI_SUBSCRIPT>: Simplify.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/eval.c36
2 files changed, 12 insertions, 29 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 649652e..449afdc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2020-12-27 Tom Tromey <tom@tromey.com>
+
+ * eval.c (evaluate_subexp_standard) <case MULTI_SUBSCRIPT>:
+ Simplify.
+
2020-12-24 Andrew Burgess <andrew.burgess@embecosm.com>
PR gdb/27059
diff --git a/gdb/eval.c b/gdb/eval.c
index dadadbb..58fa176 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2142,36 +2142,14 @@ evaluate_subexp_standard (struct type *expect_type,
(*pos) += 2;
nargs = longest_to_int (exp->elts[pc + 1].longconst);
arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
- while (nargs-- > 0)
+ argvec = XALLOCAVEC (struct value *, nargs);
+ for (ix = 0; ix < nargs; ++ix)
+ argvec[ix] = evaluate_subexp_with_coercion (exp, pos, noside);
+ if (noside == EVAL_SKIP)
+ return arg1;
+ for (ix = 0; ix < nargs; ++ix)
{
- arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
- /* FIXME: EVAL_SKIP handling may not be correct. */
- if (noside == EVAL_SKIP)
- {
- if (nargs > 0)
- continue;
- return eval_skip_value (exp);
- }
- /* FIXME: EVAL_AVOID_SIDE_EFFECTS handling may not be correct. */
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- {
- /* If the user attempts to subscript something that has no target
- type (like a plain int variable for example), then report this
- as an error. */
-
- type = TYPE_TARGET_TYPE (check_typedef (value_type (arg1)));
- if (type != NULL)
- {
- arg1 = value_zero (type, VALUE_LVAL (arg1));
- noside = EVAL_SKIP;
- continue;
- }
- else
- {
- error (_("cannot subscript something of type `%s'"),
- value_type (arg1)->name ());
- }
- }
+ arg2 = argvec[ix];
if (binop_user_defined_p (op, arg1, arg2))
{