]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix one test case for gnat-llvm
authorTom Tromey <tromey@adacore.com>
Wed, 29 Apr 2026 19:41:35 +0000 (13:41 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 30 Apr 2026 13:42:53 +0000 (07:42 -0600)
LLVM is a bit eager about removing unused locals.  Investigating this
test case showed that the problem was that some array bounds, which
are stored in artificial locals, are not emitted.

Since this isn't really germane to the test, and because real code
doesn't normally do this kind of thing, I think it's best to simply
update the test to preserve the bounds.

As this patch is Ada-specific, I am checking it in.

gdb/testsuite/gdb.ada/enum_idx_packed/foo.adb

index 27e2e7257d5565d58212d1bb6925e9240d9f0f0e..48509b75730a0a2f63cdedd85c26f257f4bb7237 100644 (file)
@@ -30,12 +30,39 @@ procedure Foo is
                                             Green => (5, 6, 7),
                                             others => (others => 72));
 
+   --  These variables ensure the bounds aren't elided by LLVM.
+   Small_First : Color := Small'First;
+   Small_Last : Color := Small'Last;
+   Multi_First1 : Color := Multi'First (1);
+   Multi_Last1 : Color := Multi'Last (1);
+   Multi_First2 : Strength := Multi'First (2);
+   Multi_Last2 : Strength := Multi'Last (2);
+
+   MM_First1 : Positive := Multi_Multi'First (1);
+   MM_Last1 : Positive := Multi_Multi'Last (1);
+   MM_First2 : Positive := Multi_Multi'First (2);
+   MM_Last2 : Positive := Multi_Multi'Last (2);
+   MM_First3 : Positive := Multi_Multi'First (3);
+   MM_Last3 : Positive := Multi_Multi'Last (3);
+
 begin
    Do_Nothing (Full'Address);  -- STOP
    Do_Nothing (Primary'Address);
    Do_Nothing (Cold'Address);
    Do_Nothing (Small'Address);
+   Do_Nothing (Small_First'Address);
+   Do_Nothing (Small_Last'Address);
    Do_Nothing (Multi'Address);
+   Do_Nothing (Multi_First1'Address);
+   Do_Nothing (Multi_Last1'Address);
+   Do_Nothing (Multi_First2'Address);
+   Do_Nothing (Multi_Last2'Address);
    Do_Nothing (Multi_Multi'Address);
    Do_Nothing (Multi_Access'Address);
+   Do_Nothing (MM_First1'Address);
+   Do_Nothing (MM_Last1'Address);
+   Do_Nothing (MM_First2'Address);
+   Do_Nothing (MM_Last2'Address);
+   Do_Nothing (MM_First3'Address);
+   Do_Nothing (MM_Last3'Address);
 end Foo;