aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2008-01-03 14:07:10 +0000
committerJoel Brobecker <brobecker@gnat.com>2008-01-03 14:07:10 +0000
commitabb68b3e0c2fb2d48e10a0edbc7fc34fa748f14f (patch)
treed4c7c5996c616e6b743886b54411a12667d8af14
parenta4d0b9c3e1ad2c359fc6bc1e7bb21ad506cdbc60 (diff)
downloadgdb-abb68b3e0c2fb2d48e10a0edbc7fc34fa748f14f.zip
gdb-abb68b3e0c2fb2d48e10a0edbc7fc34fa748f14f.tar.gz
gdb-abb68b3e0c2fb2d48e10a0edbc7fc34fa748f14f.tar.bz2
* ada-lang.c (ada_array_bound_from_type): Make non-static.
Handle properly the case when the index type is an enumerated type. Do not return the subtype of the bounds type, just return the bounds type directly - this is not needed and is more consistent with what we do for arrays when no XA parallel type exists.
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/ada-lang.c27
2 files changed, 24 insertions, 11 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 67cfd7e..0a9e63c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2008-01-03 Joel Brobecker <brobecker@adacore.com>
+ * ada-lang.c (ada_array_bound_from_type): Make non-static.
+ Handle properly the case when the index type is an enumerated type.
+ Do not return the subtype of the bounds type, just return the
+ bounds type directly - this is not needed and is more consistent
+ with what we do for arrays when no XA parallel type exists.
+
+2008-01-03 Joel Brobecker <brobecker@adacore.com>
+
* ada-lang.c (static_unwrap_type): Add forward declaration.
(template_to_static_fixed_type): Fields of dynamic types sometimes
also need to be unwrapped. Take this into account.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 76fe71a..c91fd77 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -2480,7 +2480,7 @@ ada_index_type (struct type *type, int n)
bounds type. It works for other arrays with bounds supplied by
run-time quantities other than discriminants. */
-LONGEST
+static LONGEST
ada_array_bound_from_type (struct type * arr_type, int n, int which,
struct type ** typep)
{
@@ -2505,7 +2505,6 @@ ada_array_bound_from_type (struct type * arr_type, int n, int which,
index_type_desc = ada_find_parallel_type (type, "___XA");
if (index_type_desc == NULL)
{
- struct type *range_type;
struct type *index_type;
while (n > 1)
@@ -2514,24 +2513,30 @@ ada_array_bound_from_type (struct type * arr_type, int n, int which,
n -= 1;
}
- range_type = TYPE_INDEX_TYPE (type);
- index_type = TYPE_TARGET_TYPE (range_type);
- if (TYPE_CODE (index_type) == TYPE_CODE_UNDEF)
- index_type = builtin_type_long;
+ 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_LOW_BOUND (range_type)
- : TYPE_HIGH_BOUND (range_type));
+ ? TYPE_FIELD_BITPOS (index_type, 0)
+ : TYPE_FIELD_BITPOS (index_type,
+ TYPE_NFIELDS (index_type) - 1));
}
else
{
struct type *index_type =
to_fixed_range_type (TYPE_FIELD_NAME (index_type_desc, n - 1),
NULL, TYPE_OBJFILE (arr_type));
+
if (typep != NULL)
- *typep = TYPE_TARGET_TYPE (index_type);
+ *typep = index_type;
+
return
(LONGEST) (which == 0
? TYPE_LOW_BOUND (index_type)
@@ -2540,8 +2545,8 @@ ada_array_bound_from_type (struct type * arr_type, int n, int which,
}
/* Given that arr is an array value, returns the lower bound of the
- nth index (numbering from 1) if which is 0, and the upper bound if
- which is 1. This routine will also work for arrays with bounds
+ nth index (numbering from 1) if WHICH is 0, and the upper bound if
+ WHICH is 1. This routine will also work for arrays with bounds
supplied by run-time quantities other than discriminants. */
struct value *