]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix type of imported variable for arraydim.exp master
authorTom Tromey <tromey@adacore.com>
Wed, 29 Jul 2026 14:06:06 +0000 (08:06 -0600)
committerTom Tromey <tromey@adacore.com>
Mon, 3 Aug 2026 13:29:44 +0000 (07:29 -0600)
The test code for gdb.ada/arraydim.exp imports a variable using a
dummy type.  Then the test tries to print the type of this variable.
This works ok with GCC, because the import is emitted as a
declaration; but this fails with gnat-llvm, where a definition is
emitted.

This seems to be a test bug to me.  This patch fixes the problem by
using the correct type here.

Reviewed-By: Tom de Vries <tdevries@suse.de>
gdb/testsuite/gdb.ada/arraydim.exp
gdb/testsuite/gdb.ada/arraydim/foo.adb

index 7b84a7af9b799faab332cbd812e5d61147761326..815a91ffa82272188d644c8ed2b075feb90d1808 100644 (file)
@@ -52,8 +52,13 @@ gdb_test "print m'first(3)" " = 4"
 gdb_test "print m'last(3)" " = 6"
 gdb_test "print m'length(3)" " = 3"
 
+# With GCC the test shows "int" as the element type, but with
+# gnat-llvm it shows "integer"; both of these are reasonable enough so
+# we accept either.  The difference here is because GCC emits a
+# declaration in the DWARF for foo.o, but gnat-llvm emits a
+# definition.
 gdb_test "ptype global_3dim_for_gdb_testing" \
-    "array \\(0 \\.\\. 0, 0 \\.\\. 1, 0 \\.\\. 2\\) of int"
+    [quotemeta "array (0 .. 0, 0 .. 1, 0 .. 2) of @/(int|integer)/"]
 
 gdb_test "print global_3dim_for_gdb_testing'first" " = 0"
 gdb_test "print global_3dim_for_gdb_testing'last" " = 0"
index 86204956d00bfbe3ae3ce25507f8920d3c07320a..8da63e1af93a1747875c77699e0e53e6aa32a358 100644 (file)
@@ -18,11 +18,8 @@ procedure Foo is
    type Multi is array (1 .. 1, 2 .. 3, 4 .. 6) of Integer;
    M : Multi := (others => (others => (others => 0)));
 
-   --  Use a fake type for importing our C multi-dimensional array.
-   --  It's only to make sure the C unit gets linked in, regardless
-   --  of possible optimizations.
-   type Void_Star is access integer;
-   E : Void_Star;
+   type C_Multi is array (0 .. 0, 0 .. 1, 0 .. 2) of Integer;
+   E : C_Multi;
    pragma Import (C, E, "global_3dim_for_gdb_testing");
 begin
    Do_Nothing (M'Address);  -- STOP