+2012-02-29 Joel Brobecker <brobecker@adacore.com>
+
+ * ada-lang.c (constrained_packed_array_type): If there is a
+ parallel XA type, use it to determine the array index type.
+
2012-02-29 Joel Brobecker <brobecker@adacore.com>
* ada-valprint.c (ada_val_print_1): If our value is a reference
{
struct type *new_elt_type;
struct type *new_type;
+ struct type *index_type_desc;
+ struct type *index_type;
LONGEST low_bound, high_bound;
type = ada_check_typedef (type);
if (TYPE_CODE (type) != TYPE_CODE_ARRAY)
return type;
+ index_type_desc = ada_find_parallel_type (type, "___XA");
+ if (index_type_desc)
+ index_type = to_fixed_range_type (TYPE_FIELD_TYPE (index_type_desc, 0),
+ NULL);
+ else
+ index_type = TYPE_INDEX_TYPE (type);
+
new_type = alloc_type_copy (type);
new_elt_type =
constrained_packed_array_type (ada_check_typedef (TYPE_TARGET_TYPE (type)),
elt_bits);
- create_array_type (new_type, new_elt_type, TYPE_INDEX_TYPE (type));
+ create_array_type (new_type, new_elt_type, index_type);
TYPE_FIELD_BITSIZE (new_type, 0) = *elt_bits;
TYPE_NAME (new_type) = ada_type_name (type);
- if (get_discrete_bounds (TYPE_INDEX_TYPE (type),
- &low_bound, &high_bound) < 0)
+ if (get_discrete_bounds (index_type, &low_bound, &high_bound) < 0)
low_bound = high_bound = 0;
if (high_bound < low_bound)
*elt_bits = TYPE_LENGTH (new_type) = 0;
+2012-02-29 Joel Brobecker <brobecker@adacore.com>
+
+ * gdb.ada/arrayidx.exp: Adjust expected output for p_one_two_three.
+ * gdb.ada/enum_idx_packed: New testcase.
+
2012-02-29 Joel Brobecker <brobecker@adacore.com>
* gdb.ada/aliased_array: New testcase.
"print u_one_two_three, indexes off"
gdb_test "print p_one_two_three" \
- "= \\(0 => false, true, true\\)" \
+ "= \\(false, true, true\\)" \
"print p_one_two_three, indexes off"
gdb_test "print few_reps" \
"print u_one_two_three"
gdb_test "print p_one_two_three" \
- "= \\(0 => false, 1 => true, 2 => true\\)" \
+ "= \\(one => false, two => true, three => true\\)" \
"print p_one_two_three"
gdb_test "print few_reps" \
--- /dev/null
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+load_lib "ada.exp"
+
+if { [skip_ada_tests] } { return -1 }
+
+set testdir "enum_idx_packed"
+set testfile "${testdir}/foo"
+set srcfile ${srcdir}/${subdir}/${testfile}.adb
+set binfile ${objdir}/${subdir}/${testfile}
+
+file mkdir ${objdir}/${subdir}/${testdir}
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
+runto "foo.adb:$bp_location"
+
+gdb_test "print full" " = \\(false, true, false, true, false\\)"
+
+gdb_test "print full'first" " = black"
+
--- /dev/null
+-- Copyright 2012 Free Software Foundation, Inc.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+with Pck; use Pck;
+
+procedure Foo is
+ Full : Full_Table := (False, True, False, True, False);
+begin
+ Do_Nothing (Full'Address); -- STOP
+end Foo;
+
+
--- /dev/null
+-- Copyright 2012 Free Software Foundation, Inc.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package body Pck is
+ procedure Do_Nothing (A : System.Address) is
+ begin
+ null;
+ end Do_Nothing;
+end Pck;
--- /dev/null
+-- Copyright 2012 Free Software Foundation, Inc.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+with System;
+package Pck is
+ type Color is (Black, Red, Green, Blue, White);
+ type Full_Table is array (Color) of Boolean;
+ pragma Pack (Full_Table);
+
+ procedure Do_Nothing (A : System.Address);
+end Pck;