+2014-09-10 Joel Brobecker <brobecker@adacore.com>
+
+ * ada-lang.c (ada_value_ptr_subscript): Remove parameter "type".
+ Adjust function implementation and documentation accordingly.
+ (ada_evaluate_subexp) <OP_FUNCALL>: Only assign "type" if
+ NOSIDE is EVAL_AVOID_SIDE_EFFECTS.
+ Update call to ada_value_ptr_subscript.
+
2014-09-10 Joel Brobecker <brobecker@adacore.com>
* ada-valprint.c (ada_value_print): Use VAL's enclosing type
return elt;
}
-/* Assuming ARR is a pointer to a standard GDB array of type TYPE, the
- value of the element of *ARR at the ARITY indices given in
- IND. Does not read the entire array into memory. */
+/* Assuming ARR is a pointer to a GDB array, the value of the element
+ of *ARR at the ARITY indices given in IND.
+ Does not read the entire array into memory. */
static struct value *
-ada_value_ptr_subscript (struct value *arr, struct type *type, int arity,
- struct value **ind)
+ada_value_ptr_subscript (struct value *arr, int arity, struct value **ind)
{
int k;
+ struct type *type
+ = check_typedef (value_enclosing_type (ada_value_ind (arr)));
for (k = 0; k < arity; k += 1)
{
(ada_coerce_to_simple_array (argvec[0]),
nargs, argvec + 1));
case TYPE_CODE_PTR: /* Pointer to array */
- type = to_fixed_array_type (TYPE_TARGET_TYPE (type), NULL, 1);
if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
+ type = to_fixed_array_type (TYPE_TARGET_TYPE (type), NULL, 1);
type = ada_array_element_type (type, nargs);
if (type == NULL)
error (_("element type of array unknown"));
return value_zero (ada_aligned_type (type), lval_memory);
}
return
- unwrap_value (ada_value_ptr_subscript (argvec[0], type,
- nargs, argvec + 1));
+ unwrap_value (ada_value_ptr_subscript (argvec[0],
+ nargs, argvec + 1));
default:
error (_("Attempt to index or call something other than an "
+2014-09-10 Joel Brobecker <brobecker@adacore.com>
+
+ * gdb.dwarf2/dynarr-ptr.exp: Add subscripting tests.
+
2014-09-10 Joel Brobecker <brobecker@adacore.com>
* gdb.dwarf2/dynarr-ptr.c: New file.
gdb_test "print foo.three_ptr.all" \
" = \\(1, 2, 3\\)"
+gdb_test "print foo.three_ptr.all(1)" \
+ " = 1"
+
+gdb_test "print foo.three_ptr.all(2)" \
+ " = 2"
+
+gdb_test "print foo.three_ptr.all(3)" \
+ " = 3"
+
+# foo.three_ptr
+
+gdb_test "print foo.three_ptr(1)" \
+ " = 1"
+
+gdb_test "print foo.three_ptr(2)" \
+ " = 2"
+
+gdb_test "print foo.three_ptr(3)" \
+ " = 3"
+
# foo.three_ptr_tdef.all
gdb_test "print foo.three_ptr_tdef.all" \
" = \\(1, 2, 3\\)"
+gdb_test "print foo.three_ptr_tdef.all(1)" \
+ " = 1"
+
+gdb_test "print foo.three_ptr_tdef.all(2)" \
+ " = 2"
+
+gdb_test "print foo.three_ptr_tdef.all(3)" \
+ " = 3"
+
+# foo.three_ptr_tdef
+
+gdb_test "print foo.three_ptr_tdef(1)" \
+ " = 1"
+
+gdb_test "print foo.three_ptr_tdef(2)" \
+ " = 2"
+
+gdb_test "print foo.three_ptr_tdef(3)" \
+ " = 3"
+
# foo.five_ptr.all
gdb_test "print foo.five_ptr.all" \
" = \\(2 => 5, 8, 13, 21, 34\\)"
+gdb_test "print foo.five_ptr.all(2)" \
+ " = 5"
+
+gdb_test "print foo.five_ptr.all(3)" \
+ " = 8"
+
+gdb_test "print foo.five_ptr.all(4)" \
+ " = 13"
+
+gdb_test "print foo.five_ptr.all(5)" \
+ " = 21"
+
+gdb_test "print foo.five_ptr.all(6)" \
+ " = 34"
+
+# foo.five_ptr
+
+gdb_test "print foo.five_ptr(2)" \
+ " = 5"
+
+gdb_test "print foo.five_ptr(3)" \
+ " = 8"
+
+gdb_test "print foo.five_ptr(4)" \
+ " = 13"
+
+gdb_test "print foo.five_ptr(5)" \
+ " = 21"
+
+gdb_test "print foo.five_ptr(6)" \
+ " = 34"
+
# foo.five_ptr_tdef.all
gdb_test "print foo.five_ptr_tdef.all" \
" = \\(2 => 5, 8, 13, 21, 34\\)"
+
+gdb_test "print foo.five_ptr_tdef.all(2)" \
+ " = 5"
+
+gdb_test "print foo.five_ptr_tdef.all(3)" \
+ " = 8"
+
+gdb_test "print foo.five_ptr_tdef.all(4)" \
+ " = 13"
+
+gdb_test "print foo.five_ptr_tdef.all(5)" \
+ " = 21"
+
+gdb_test "print foo.five_ptr_tdef.all(6)" \
+ " = 34"
+
+# foo.five_ptr_tdef
+
+gdb_test "print foo.five_ptr_tdef(2)" \
+ " = 5"
+
+gdb_test "print foo.five_ptr_tdef(3)" \
+ " = 8"
+
+gdb_test "print foo.five_ptr_tdef(4)" \
+ " = 13"
+
+gdb_test "print foo.five_ptr_tdef(5)" \
+ " = 21"
+
+gdb_test "print foo.five_ptr_tdef(6)" \
+ " = 34"