[gdb/ada] Fix gdb.ada/overloads.exp on s390x

Message ID 20250415104058.25599-1-tdevries@suse.de
State Committed
Headers
Series [gdb/ada] Fix gdb.ada/overloads.exp on s390x |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply

Commit Message

Tom de Vries April 15, 2025, 10:40 a.m. UTC
  On s390x-linux, with test-case gdb.ada/overloads.exp and gcc 7.5.0 I run into:
...
(gdb) print Oload(CA)^M
Could not find a match for oload^M
(gdb) FAIL: $exp: print Oload(CA)
...

The mismatch happens here in ada_type_match:
...
      return ftype->code () == atype->code ();
...
with:
...
(gdb) p ftype->code ()
$3 = TYPE_CODE_TYPEDEF
(gdb) p atype->code ()
$4 = TYPE_CODE_ARRAY
...

At the start of ada_type_match, typedefs are skipped:
...
  ftype = ada_check_typedef (ftype);
  atype = ada_check_typedef (atype);
...
but immediately after this, refs are skipped:
...
  if (ftype->code () == TYPE_CODE_REF)
    ftype = ftype->target_type ();
  if (atype->code () == TYPE_CODE_REF)
    atype = atype->target_type ();
...
which in this case makes ftype a typedef.

Fix this by using ada_check_typedef after skipping the refs as well.

Tested on x86_64-linux and s390x-linux.

PR ada/32409
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32409
---
 gdb/ada-lang.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


base-commit: 88891208c3f0e05f560f39bcdce65a55cc750acb
  

Comments

Tom Tromey April 15, 2025, 2:05 p.m. UTC | #1
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> Fix this by using ada_check_typedef after skipping the refs as well.

Tom> Tested on x86_64-linux and s390x-linux.

Ok, thanks.
Approved-By: Tom Tromey <tom@tromey.com>

Tom
  

Patch

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 9d354407bc3..38c79740290 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3950,9 +3950,9 @@  ada_type_match (struct type *ftype, struct type *atype)
   atype = ada_check_typedef (atype);
 
   if (ftype->code () == TYPE_CODE_REF)
-    ftype = ftype->target_type ();
+    ftype = ada_check_typedef (ftype->target_type ());
   if (atype->code () == TYPE_CODE_REF)
-    atype = atype->target_type ();
+    atype = ada_check_typedef (atype->target_type ());
 
   switch (ftype->code ())
     {