+2018-01-05 Jerome Guitton <guitton@adacore.com>
+
+ * ada-lang.c (ada_array_length): Use ada_index_type instead of
+ TYPE_INDEX_TYPE.
+
2018-01-05 Joel Brobecker <brobecker@adacore.com>
* ada-lang.c (ada_to_fixed_value_create): Add handling of
}
arr_type = check_typedef (arr_type);
- index_type = TYPE_INDEX_TYPE (arr_type);
+ index_type = ada_index_type (arr_type, n, "length");
if (index_type != NULL)
{
struct type *base_type;
+2018-01-05 Jerome Guitton <guitton@adacore.com>
+
+ * gdb.ada/arr_acc_idx_w_gap: New testcase.
+
2018-01-05 Joel Brobecker <brobecker@adacore.com>
* gdb.ada/convvar_comp: New testcase.
--- /dev/null
+# Copyright 2018 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"
+
+standard_ada_testfile enum_with_gap_main
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "BREAK" ${testdir}/enum_with_gap_main.adb]
+if ![runto "enum_with_gap_main.adb:$bp_location" ] then {
+ perror "Couldn't run ${testfile}"
+ return
+}
+
+gdb_test "print indexed_by_enum.all" \
+ " = \\(lit1 => 1, 43, 42, 41\\)"
+gdb_test "print s.all" \
+ " = \"Hello!\""
+
+gdb_test "print indexed_by_enum'length" \
+ " = 4"
+gdb_test "print s'length" \
+ " = 6"
+
+gdb_test "print indexed_by_enum'first" \
+ " = lit1"
+gdb_test "print s'first" \
+ " = 1"
+
+gdb_test "print indexed_by_enum'last" \
+ " = lit4"
+gdb_test "print s'last" \
+ " = 6"
+
+gdb_test "print indexed_by_enum(lit2..lit4)" \
+ " = \\(lit2 => 43, 42, 41\\)"
+gdb_test "print s(2..4)" \
+ " = \"ell\""
--- /dev/null
+-- Copyright 2018 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 Enum_With_Gap is
+
+ procedure Do_Nothing (E : AR_Access) is
+ begin
+ null;
+ end Do_Nothing;
+
+ procedure Do_Nothing (E : String_Access) is
+ begin
+ null;
+ end Do_Nothing;
+
+end Enum_With_Gap;
--- /dev/null
+-- Copyright 2018 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 Enum_With_Gap is
+
+ type Enum_With_Gaps is
+ (
+ LIT0,
+ LIT1,
+ LIT2,
+ LIT3,
+ LIT4
+ );
+
+ for Enum_With_Gaps use
+ (
+ LIT0 => 3,
+ LIT1 => 5,
+ LIT2 => 8,
+ LIT3 => 13,
+ LIT4 => 21
+ );
+ for Enum_With_Gaps'size use 16;
+
+ type MyWord is range 0 .. 16#FFFF# ;
+ for MyWord'Size use 16;
+
+ type AR is array (Enum_With_Gaps range <>) of MyWord;
+ type AR_Access is access AR;
+
+ type String_Access is access String;
+
+ procedure Do_Nothing (E : AR_Access);
+ procedure Do_Nothing (E : String_Access);
+
+end Enum_With_Gap;
--- /dev/null
+-- Copyright 2018 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 Enum_With_Gap; use Enum_With_Gap;
+
+procedure Enum_With_Gap_Main is
+ Indexed_By_Enum : AR_Access :=
+ new AR'(LIT1 => 1, LIT2 => 43, LIT3 => 42, LIT4 => 41);
+ S : String_Access := new String'("Hello!");
+begin
+ Do_Nothing (Indexed_By_Enum); -- BREAK
+ Do_Nothing (S);
+end Enum_With_Gap_Main;