aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r--gdb/ada-lang.c60
1 files changed, 28 insertions, 32 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index bcbd709..71d99b0 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -1777,11 +1777,11 @@ packed_array_type (struct type *type, long *elt_bits)
new_type = alloc_type (TYPE_OBJFILE (type));
new_elt_type = packed_array_type (ada_check_typedef (TYPE_TARGET_TYPE (type)),
elt_bits);
- create_array_type (new_type, new_elt_type, TYPE_FIELD_TYPE (type, 0));
+ create_array_type (new_type, new_elt_type, TYPE_INDEX_TYPE (type));
TYPE_FIELD_BITSIZE (new_type, 0) = *elt_bits;
TYPE_NAME (new_type) = ada_type_name (type);
- if (get_discrete_bounds (TYPE_FIELD_TYPE (type, 0),
+ if (get_discrete_bounds (TYPE_INDEX_TYPE (type),
&low_bound, &high_bound) < 0)
low_bound = high_bound = 0;
if (high_bound < low_bound)
@@ -2468,7 +2468,7 @@ ada_index_type (struct type *type, int n)
for (i = 1; i < n; i += 1)
type = TYPE_TARGET_TYPE (type);
- result_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0));
+ result_type = TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type));
/* FIXME: The stabs type r(0,0);bound;bound in an array type
has a target type of TYPE_CODE_UNDEF. We compensate here, but
perhaps stabsread.c would make more sense. */
@@ -2492,8 +2492,10 @@ static LONGEST
ada_array_bound_from_type (struct type * arr_type, int n, int which,
struct type ** typep)
{
- struct type *type;
- struct type *index_type_desc;
+ struct type *type, *index_type_desc, *index_type;
+ LONGEST retval;
+
+ gdb_assert (which == 0 || which == 1);
if (ada_is_packed_array_type (arr_type))
arr_type = decode_packed_array_type (arr_type);
@@ -2511,10 +2513,11 @@ ada_array_bound_from_type (struct type * arr_type, int n, int which,
type = arr_type;
index_type_desc = ada_find_parallel_type (type, "___XA");
- if (index_type_desc == NULL)
+ if (index_type_desc != NULL)
+ index_type = to_fixed_range_type (TYPE_FIELD_NAME (index_type_desc, n - 1),
+ NULL, TYPE_OBJFILE (arr_type));
+ else
{
- struct type *index_type;
-
while (n > 1)
{
type = TYPE_TARGET_TYPE (type);
@@ -2522,34 +2525,27 @@ ada_array_bound_from_type (struct type * arr_type, int n, int which,
}
index_type = TYPE_INDEX_TYPE (type);
- if (typep != NULL)
- *typep = index_type;
-
- /* The index type is either a range type or an enumerated type.
- For the range type, we have some macros that allow us to
- extract the value of the low and high bounds. But they
- do now work for enumerated types. The expressions used
- below work for both range and enum types. */
- return
- (LONGEST) (which == 0
- ? TYPE_FIELD_BITPOS (index_type, 0)
- : TYPE_FIELD_BITPOS (index_type,
- TYPE_NFIELDS (index_type) - 1));
}
- else
+
+ switch (TYPE_CODE (index_type))
{
- struct type *index_type =
- to_fixed_range_type (TYPE_FIELD_NAME (index_type_desc, n - 1),
- NULL, TYPE_OBJFILE (arr_type));
+ case TYPE_CODE_RANGE:
+ retval = which == 0 ? TYPE_LOW_BOUND (index_type)
+ : TYPE_HIGH_BOUND (index_type);
+ break;
+ case TYPE_CODE_ENUM:
+ retval = which == 0 ? TYPE_FIELD_BITPOS (index_type, 0)
+ : TYPE_FIELD_BITPOS (index_type,
+ TYPE_NFIELDS (index_type) - 1);
+ break;
+ default:
+ internal_error (__FILE__, __LINE__, _("invalid type code of index type"));
+ }
- if (typep != NULL)
- *typep = index_type;
+ if (typep != NULL)
+ *typep = index_type;
- return
- (LONGEST) (which == 0
- ? TYPE_LOW_BOUND (index_type)
- : TYPE_HIGH_BOUND (index_type));
- }
+ return retval;
}
/* Given that arr is an array value, returns the lower bound of the