diff options
author | Tom Tromey <tromey@adacore.com> | 2023-06-23 09:39:57 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-07-13 11:44:47 -0600 |
commit | 1e5ae3d17f02bba07b07e1b6367563cf4d0eff99 (patch) | |
tree | cb0b320fa3baf4914447ba0536f1129411d3aeed /gdb | |
parent | f6f78318fca803c4907fb8d7f6ded8295f1947b1 (diff) | |
download | gdb-1e5ae3d17f02bba07b07e1b6367563cf4d0eff99.zip gdb-1e5ae3d17f02bba07b07e1b6367563cf4d0eff99.tar.gz gdb-1e5ae3d17f02bba07b07e1b6367563cf4d0eff99.tar.bz2 |
Remove ada_attribute_name
ada_attribute_name uses an array that must be kept in sync with an
enum -- but the comment here refers to an enum that no longer exists.
Looking at the sole caller, I see this can only be called for two
opcodes. So, remove this entirely and inline it.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ada-lang.c | 41 |
1 files changed, 9 insertions, 32 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 8e506bd..3d629cc 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -8767,35 +8767,6 @@ ada_to_fixed_value (struct value *val) /* Attributes */ -/* Table mapping attribute numbers to names. - NOTE: Keep up to date with enum ada_attribute definition in ada-lang.h. */ - -static const char * const attribute_names[] = { - "<?>", - - "first", - "last", - "length", - "image", - "max", - "min", - "modulus", - "pos", - "size", - "tag", - "val", - 0 -}; - -static const char * -ada_attribute_name (enum exp_opcode n) -{ - if (n >= OP_ATR_FIRST && n <= (int) OP_ATR_VAL) - return attribute_names[n - OP_ATR_FIRST + 1]; - else - return attribute_names[0]; -} - /* Evaluate the 'POS attribute applied to ARG. */ static LONGEST @@ -10271,6 +10242,12 @@ static value * ada_unop_atr (struct expression *exp, enum noside noside, enum exp_opcode op, struct value *arg1, struct type *type_arg, int tem) { + const char *attr_name = nullptr; + if (op == OP_ATR_FIRST) + attr_name = "first"; + else if (op == OP_ATR_LAST) + attr_name = "last"; + if (noside == EVAL_AVOID_SIDE_EFFECTS) { if (type_arg == NULL) @@ -10288,7 +10265,7 @@ ada_unop_atr (struct expression *exp, enum noside noside, enum exp_opcode op, case OP_ATR_FIRST: case OP_ATR_LAST: type_arg = ada_index_type (type_arg, tem, - ada_attribute_name (op)); + attr_name); break; case OP_ATR_LENGTH: type_arg = builtin_type (exp->gdbarch)->builtin_int; @@ -10311,7 +10288,7 @@ ada_unop_atr (struct expression *exp, enum noside noside, enum exp_opcode op, else { type = ada_index_type (arg1->type (), tem, - ada_attribute_name (op)); + attr_name); if (type == NULL) type = builtin_type (exp->gdbarch)->builtin_int; } @@ -10369,7 +10346,7 @@ ada_unop_atr (struct expression *exp, enum noside noside, enum exp_opcode op, type = builtin_type (exp->gdbarch)->builtin_int; else { - type = ada_index_type (type_arg, tem, ada_attribute_name (op)); + type = ada_index_type (type_arg, tem, attr_name); if (type == NULL) type = builtin_type (exp->gdbarch)->builtin_int; } |