diff options
author | Tom Tromey <tom@tromey.com> | 2020-12-15 18:14:42 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-12-15 18:24:02 -0700 |
commit | 2adab65cc07f07a581d57b05dfbc100952fab748 (patch) | |
tree | cf31db8beca37152fd15d8fc9308350dc3cb0150 /gdb/varobj.c | |
parent | 1ab8280d7dbe01f51929d221621d38450f31895d (diff) | |
download | gdb-2adab65cc07f07a581d57b05dfbc100952fab748.zip gdb-2adab65cc07f07a581d57b05dfbc100952fab748.tar.gz gdb-2adab65cc07f07a581d57b05dfbc100952fab748.tar.bz2 |
Introduce expression::first_opcode
This adds a new helper method, expression::first_opcode, that extracts
the outermost opcode of an expression. This simplifies some patches
in the expression rewrite series.
Note that this patch requires the earlier patch to avoid manual
dissection of OP_TYPE operations.
2020-12-15 Tom Tromey <tom@tromey.com>
* varobj.c (varobj_create): Use first_opcode.
* value.c (init_if_undefined_command): Use first_opcode.
* typeprint.c (whatis_exp): Use first_opcode.
* tracepoint.c (validate_actionline): Use first_opcode.
(encode_actions_1): Use first_opcode.
* stack.c (return_command): Use first_opcode.
* expression.h (struct expression) <first_opcode>: New method.
* eval.c (parse_and_eval_type): Use first_opcode.
* dtrace-probe.c (dtrace_process_dof_probe): Use first_opcode.
Diffstat (limited to 'gdb/varobj.c')
-rw-r--r-- | gdb/varobj.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/gdb/varobj.c b/gdb/varobj.c index 19a90c7..6a95e1e 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -311,9 +311,10 @@ varobj_create (const char *objname, } /* Don't allow variables to be created for types. */ - if (var->root->exp->elts[0].opcode == OP_TYPE - || var->root->exp->elts[0].opcode == OP_TYPEOF - || var->root->exp->elts[0].opcode == OP_DECLTYPE) + enum exp_opcode opcode = var->root->exp->first_opcode (); + if (opcode == OP_TYPE + || opcode == OP_TYPEOF + || opcode == OP_DECLTYPE) { fprintf_unfiltered (gdb_stderr, "Attempt to use a type name" " as an expression.\n"); |