[pushed,4/4] Add gdb.ada/dyn_arrayidx testcase.

Message ID 1398715764-1548-5-git-send-email-brobecker@adacore.com
State Committed
Headers

Commit Message

Joel Brobecker April 28, 2014, 8:09 p.m. UTC
  This add a testcases that verifies correct handling of dynamicity
for lower bounds of arrays.

gdb/testsuite/ChangeLog:

        * gdb.ada/dyn_arrayidx: New testcase.

Tested on x86_64-linux, pushed.

---
 gdb/testsuite/ChangeLog                    |  4 ++++
 gdb/testsuite/gdb.ada/dyn_arrayidx.exp     | 36 ++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.ada/dyn_arrayidx/foo.adb | 32 ++++++++++++++++++++++++++
 3 files changed, 72 insertions(+)
 create mode 100644 gdb/testsuite/gdb.ada/dyn_arrayidx.exp
 create mode 100644 gdb/testsuite/gdb.ada/dyn_arrayidx/foo.adb
  

Patch

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 5bb89a2..8078a42 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -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
index 0000000..04c39b0
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/dyn_arrayidx.exp
@@ -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
index 0000000..4deb04d
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/dyn_arrayidx/foo.adb
@@ -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;