This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling
- From: uweigand at de dot ibm dot com
- To: gdb-patches at sourceware dot org
- Date: Sun, 31 Aug 2008 19:51:04 +0200
- Subject: [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling
- References: <20080831175045.128504000@de.ibm.com>
Hello,
two more small changes to ada-lang.c: ada_array_length would simply use
builtin_type_int as type of its return value, even though it should probably
better use the type of the array bounds.
Similarly, ada_evaluate_subexp at one place uses a builtin_type_int to hold
bounds of a range type, instead of using the underlying scalar type.
Bye,
Ulrich
ChangeLog:
* ada-lang.c (ada_array_length): Use type of array bounds instead
of builtin_type_int.
(ada_evaluate_subexp): Likewise.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -2633,12 +2633,13 @@ ada_array_length (struct value *arr, int
return value_from_longest (type, v);
}
else
- return
- value_from_longest (builtin_type_int,
- value_as_long (desc_one_bound (desc_bounds (arr),
- n, 1))
- - value_as_long (desc_one_bound (desc_bounds (arr),
- n, 0)) + 1);
+ {
+ struct value *high = desc_one_bound (desc_bounds (arr), n, 1);
+ struct value *low = desc_one_bound (desc_bounds (arr), n, 0);
+ return value_from_longest (value_type (high),
+ value_as_long (high)
+ - value_as_long (low) + 1);
+ }
}
/* An empty array whose type is that of ARR_TYPE (an array type),
@@ -8871,9 +8872,10 @@ ada_evaluate_subexp (struct type *expect
return value_from_longest (type, (LONGEST) 1);
case TYPE_CODE_RANGE:
- arg2 = value_from_longest (builtin_type_int, TYPE_LOW_BOUND (type));
- arg3 = value_from_longest (builtin_type_int,
- TYPE_HIGH_BOUND (type));
+ arg2 = value_from_longest (TYPE_TARGET_TYPE (type),
+ TYPE_LOW_BOUND (type));
+ arg3 = value_from_longest (TYPE_TARGET_TYPE (type),
+ TYPE_HIGH_BOUND (type));
binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3);
type = language_bool_type (exp->language_defn, exp->gdbarch);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com