Add gdb.ada/dyn_arrayidx testcase.
authorJoel Brobecker <brobecker@adacore.com>
Sun, 20 Apr 2014 05:19:02 +0000 (22:19 -0700)
committerJoel Brobecker <brobecker@adacore.com>
Mon, 28 Apr 2014 19:48:11 +0000 (15:48 -0400)
This add a testcases that verifies correct handling of dynamicity
for lower bounds of arrays.

gdb/testsuite/ChangeLog:

        * gdb.ada/dyn_arrayidx: New testcase.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/dyn_arrayidx.exp [new file with mode: 0644]
gdb/testsuite/gdb.ada/dyn_arrayidx/foo.adb [new file with mode: 0644]

index 5bb89a2..8078a42 100644 (file)
@@ -1,3 +1,7 @@
+2014-04-28  Joel Brobecker  <brobecker@adacore.com>
+
+       * gdb.ada/dyn_arrayidx: New testcase.
+
 2014-04-26  Yao Qi  <yao@codesourcery.com>
 
        * gdb.dwarf2/dwz.exp: Compile main.c to object.  Restart GDB
diff --git a/gdb/testsuite/gdb.ada/dyn_arrayidx.exp b/gdb/testsuite/gdb.ada/dyn_arrayidx.exp
new file mode 100644 (file)
index 0000000..04c39b0
--- /dev/null
@@ -0,0 +1,36 @@
+# Copyright 2014 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 }
+
+standard_ada_testfile foo
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
+    return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "START" ${testdir}/foo.adb]
+runto "foo.adb:$bp_location"
+
+# Make sure we do not use any of the descriptive types, even if
+# the compiler generated them.
+gdb_test_no_output "maintenance set ada ignore-descriptive-types"
+
+gdb_test "ptype array_type" \
+         " = array \\(5 \\.\\. 10\\) of natural" \
diff --git a/gdb/testsuite/gdb.ada/dyn_arrayidx/foo.adb b/gdb/testsuite/gdb.ada/dyn_arrayidx/foo.adb
new file mode 100644 (file)
index 0000000..4deb04d
--- /dev/null
@@ -0,0 +1,32 @@
+--  Copyright 2014 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/>.
+
+procedure Foo is
+   function Range_Count (L, U : Integer) return Natural
+   is
+      type Array_Type is array (L .. U) of Natural;
+      A : Array_Type := (others => 1);
+      Result : Natural := 0;
+   begin
+      for I of A loop  -- START
+         Result := Result + I;
+      end loop;
+      return Result;
+   end Range_Count;
+
+   R2 : constant Natural := Range_Count (5, 10);
+begin
+   null;
+end Foo;