[pushed] Add Do_Nothing to two more Ada tests

Message ID 20251218134807.17487-1-tromey@adacore.com
State New
Headers
Series [pushed] Add Do_Nothing to two more Ada tests |

Commit Message

Tom Tromey Dec. 18, 2025, 1:48 p.m. UTC
  A couple of Ada tests were failing with gnat-llvm, because LLVM is a
bit more aggressive about eliminating unused local variables.  This
patch arranges for some variables to be kept alive a little longer,
using the usual Do_Nothing technique.
---
 gdb/testsuite/gdb.ada/py_taft/main.adb        |  2 +-
 gdb/testsuite/gdb.ada/py_taft/pkg.adb         |  5 ++++
 gdb/testsuite/gdb.ada/py_taft/pkg.ads         |  4 +++
 .../gdb.ada/recursive-variant/main.adb        |  4 ++-
 .../gdb.ada/recursive-variant/pck.adb         | 25 +++++++++++++++++++
 .../gdb.ada/recursive-variant/pck.ads         | 22 ++++++++++++++++
 6 files changed, 60 insertions(+), 2 deletions(-)
 create mode 100644 gdb/testsuite/gdb.ada/recursive-variant/pck.adb
 create mode 100644 gdb/testsuite/gdb.ada/recursive-variant/pck.ads


base-commit: 1b5496684056bce7e2910db0afc050f7b73e45d7
  

Patch

diff --git a/gdb/testsuite/gdb.ada/py_taft/main.adb b/gdb/testsuite/gdb.ada/py_taft/main.adb
index 273f637bd15..32b03f62f9a 100644
--- a/gdb/testsuite/gdb.ada/py_taft/main.adb
+++ b/gdb/testsuite/gdb.ada/py_taft/main.adb
@@ -18,5 +18,5 @@  with Pkg;
 procedure Main is
    V : Pkg.Value := Pkg.Create (42);
 begin
-   null;				--  STOP
+   Pkg.Do_Nothing (V'Address);      --  STOP
 end Main;
diff --git a/gdb/testsuite/gdb.ada/py_taft/pkg.adb b/gdb/testsuite/gdb.ada/py_taft/pkg.adb
index 854df1086ff..8a5bdf52798 100644
--- a/gdb/testsuite/gdb.ada/py_taft/pkg.adb
+++ b/gdb/testsuite/gdb.ada/py_taft/pkg.adb
@@ -15,6 +15,11 @@ 
 
 package body Pkg is
 
+   procedure Do_Nothing (A : System.Address) is
+   begin
+      null;
+   end Do_Nothing;
+
    type Value_Record is record
       I : Integer;
    end record;
diff --git a/gdb/testsuite/gdb.ada/py_taft/pkg.ads b/gdb/testsuite/gdb.ada/py_taft/pkg.ads
index c9944025fef..faa7e5fdfe1 100644
--- a/gdb/testsuite/gdb.ada/py_taft/pkg.ads
+++ b/gdb/testsuite/gdb.ada/py_taft/pkg.ads
@@ -13,7 +13,11 @@ 
 --  You should have received a copy of the GNU General Public License
 --  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+with System;
+
 package Pkg is
+   procedure Do_Nothing (A : System.Address);
+
    type Value is private;
    function Create (I : Integer) return Value;
 private
diff --git a/gdb/testsuite/gdb.ada/recursive-variant/main.adb b/gdb/testsuite/gdb.ada/recursive-variant/main.adb
index d4c3ab6c024..6978ddba2df 100644
--- a/gdb/testsuite/gdb.ada/recursive-variant/main.adb
+++ b/gdb/testsuite/gdb.ada/recursive-variant/main.adb
@@ -13,6 +13,8 @@ 
 --  You should have received a copy of the GNU General Public License
 --  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+with Pck; use Pck;
+
 procedure Main is
 
    type Rec_Type;
@@ -33,6 +35,6 @@  procedure Main is
 
 begin
 
-   null; -- STOP
+   Do_Nothing (Instance'Address); -- STOP
 
 end Main;
diff --git a/gdb/testsuite/gdb.ada/recursive-variant/pck.adb b/gdb/testsuite/gdb.ada/recursive-variant/pck.adb
new file mode 100644
index 00000000000..cf6d02cfde6
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/recursive-variant/pck.adb
@@ -0,0 +1,25 @@ 
+--  Copyright 2025 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/>.
+
+with System;
+
+package body Pck is
+
+   procedure Do_Nothing (A : System.Address) is
+   begin
+      null;
+   end Do_Nothing;
+
+end Pck;
diff --git a/gdb/testsuite/gdb.ada/recursive-variant/pck.ads b/gdb/testsuite/gdb.ada/recursive-variant/pck.ads
new file mode 100644
index 00000000000..965e702e152
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/recursive-variant/pck.ads
@@ -0,0 +1,22 @@ 
+--  Copyright 2025 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/>.
+
+with System;
+
+package Pck is
+
+   procedure Do_Nothing (A : System.Address);
+
+end Pck;