This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA/commit] Allow for references in more places (Ada)
- From: Paul Hilfinger <Hilfinger at adacore dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 8 Aug 2008 05:07:41 -0400 (EDT)
- Subject: [RFA/commit] Allow for references in more places (Ada)
- Reply-to: Hilfinger at adacore dot com
The following patch fixes a small problem with indexing arrays in Ada
when the index expression evaluates to a reference. Tested on Linux with
no regressions. I will commit in a week if there is no objection.
Paul Hilfinger
ChangeLog:
2008-08-05 Paul N. Hilfinger <hilfinger@adacore.com>
* ada-lang.c (pos_atr): Account for the possibility that the
argument may be a reference.
Index: gdb/ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.151
diff -u -p -r1.151 ada-lang.c
--- gdb/ada-lang.c 21 Jul 2008 16:47:10 -0000 1.151
+++ gdb/ada-lang.c 8 Aug 2008 08:57:43 -0000
@@ -7634,7 +7634,8 @@ ada_attribute_name (enum exp_opcode n)
static LONGEST
pos_atr (struct value *arg)
{
- struct type *type = value_type (arg);
+ struct value *val = coerce_ref (arg);
+ struct type *type = value_type (val);
if (!discrete_type_p (type))
error (_("'POS only defined on discrete types"));
@@ -7642,7 +7643,7 @@ pos_atr (struct value *arg)
if (TYPE_CODE (type) == TYPE_CODE_ENUM)
{
int i;
- LONGEST v = value_as_long (arg);
+ LONGEST v = value_as_long (val);
for (i = 0; i < TYPE_NFIELDS (type); i += 1)
{
@@ -7652,7 +7653,7 @@ pos_atr (struct value *arg)
error (_("enumeration value is invalid: can't find 'POS"));
}
else
- return value_as_long (arg);
+ return value_as_long (val);
}
static struct value *