aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada/str_binop_equal.exp
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@adacore.com>2017-12-14 00:05:24 -0500
committerJoel Brobecker <brobecker@adacore.com>2017-12-14 00:16:39 -0500
commit79e8fcaafa92e7b4a74e510c5487e87c60ff1945 (patch)
tree1bbe4eda3e411b0312125ea7f23b82dac6127123 /gdb/testsuite/gdb.ada/str_binop_equal.exp
parente05fa6f9df82886043e1f1df30e0b9be3fee2d55 (diff)
downloadgdb-79e8fcaafa92e7b4a74e510c5487e87c60ff1945.zip
gdb-79e8fcaafa92e7b4a74e510c5487e87c60ff1945.tar.gz
gdb-79e8fcaafa92e7b4a74e510c5487e87c60ff1945.tar.bz2
Ada: unable to compare strings (Attempt to compare array with non-array)
Consider the following Ada Code: type Str is new String (1 .. 4); My_str : Str := "ABCD"; This simply declares a 4-character string type. Trying to perform equality tests using it currently yield an error: (gdb) p my_str = my_str Attempt to compare array with non-array (gdb) p my_str = "ABCD" Attempt to compare array with non-array The error occurs because my_str is defined as an object whose type is a typdef to a TYPE_CODE_ARRAY, which ada_value_equal is not expecting at all (yet). This patch fixes this oversight. gdb/ChangeLog: * ada-lang.c (ada_value_equal): Add handling of typedef types when comparing array objects. gdb/testsuite/ChangeLog: * gdb.ada/str_binop_equal: New testcase. Tested on x86_64-linux.
Diffstat (limited to 'gdb/testsuite/gdb.ada/str_binop_equal.exp')
-rw-r--r--gdb/testsuite/gdb.ada/str_binop_equal.exp39
1 files changed, 39 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/str_binop_equal.exp b/gdb/testsuite/gdb.ada/str_binop_equal.exp
new file mode 100644
index 0000000..2481bac
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/str_binop_equal.exp
@@ -0,0 +1,39 @@
+# Copyright 2017 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 foo_p211_061
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "STOP" ${testdir}/foo_p211_061.adb]
+runto "foo_p211_061.adb:$bp_location"
+
+gdb_test "print my_str = my_str" \
+ " = true"
+
+gdb_test "print my_str = \"ABCD\"" \
+ " = true"
+
+gdb_test "print my_str = \"EFGH\"" \
+ " = false"
+
+gdb_test "print my_str = \"AB\"" \
+ " = false"