Ada: unable to compare strings (Attempt to compare array with non-array)
authorJoel Brobecker <brobecker@adacore.com>
Thu, 14 Dec 2017 05:05:24 +0000 (00:05 -0500)
committerJoel Brobecker <brobecker@adacore.com>
Thu, 14 Dec 2017 05:16:39 +0000 (00:16 -0500)
commit79e8fcaafa92e7b4a74e510c5487e87c60ff1945
tree1bbe4eda3e411b0312125ea7f23b82dac6127123
parente05fa6f9df82886043e1f1df30e0b9be3fee2d55
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.
gdb/ChangeLog
gdb/ada-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/str_binop_equal.exp [new file with mode: 0644]
gdb/testsuite/gdb.ada/str_binop_equal/foo_p211_061.adb [new file with mode: 0644]
gdb/testsuite/gdb.ada/str_binop_equal/pck.adb [new file with mode: 0644]
gdb/testsuite/gdb.ada/str_binop_equal/pck.ads [new file with mode: 0644]