[pushed] Preserve local variables in another Ada test case

Message ID 20250122150700.1942771-1-tromey@adacore.com
State New
Headers
Series [pushed] Preserve local variables in another Ada test case |

Checks

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

Commit Message

Tom Tromey Jan. 22, 2025, 3:07 p.m. UTC
  I found another Ada test case where gnat-llvm optimizes away the local
variables.  This patch applies the same fix to it as previous patches.
---
 gdb/testsuite/gdb.ada/local-enum/local.adb |  7 +++++--
 gdb/testsuite/gdb.ada/local-enum/pck.adb   | 21 +++++++++++++++++++++
 gdb/testsuite/gdb.ada/local-enum/pck.ads   | 19 +++++++++++++++++++
 3 files changed, 45 insertions(+), 2 deletions(-)
 create mode 100644 gdb/testsuite/gdb.ada/local-enum/pck.adb
 create mode 100644 gdb/testsuite/gdb.ada/local-enum/pck.ads
  

Patch

diff --git a/gdb/testsuite/gdb.ada/local-enum/local.adb b/gdb/testsuite/gdb.ada/local-enum/local.adb
index d4c1b65665b..29e8ebdc4d6 100644
--- a/gdb/testsuite/gdb.ada/local-enum/local.adb
+++ b/gdb/testsuite/gdb.ada/local-enum/local.adb
@@ -1,4 +1,4 @@ 
---  Copyright 2021-2024 Free Software Foundation, Inc.
+--  Copyright 2021-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
@@ -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 Local is
   type E1 is (one, two, three);
   type E2 is (three, four, five);
@@ -24,5 +26,6 @@  procedure Local is
   V2 : A2 := (3, 4, 5);
 
 begin
-  null; -- STOP
+  Do_Nothing (V1'Address); -- STOP
+  Do_Nothing (V2'Address);
 end Local;
diff --git a/gdb/testsuite/gdb.ada/local-enum/pck.adb b/gdb/testsuite/gdb.ada/local-enum/pck.adb
new file mode 100644
index 00000000000..a175b7bdc5a
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/local-enum/pck.adb
@@ -0,0 +1,21 @@ 
+--  Copyright 2014-2024 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/>.
+
+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/local-enum/pck.ads b/gdb/testsuite/gdb.ada/local-enum/pck.ads
new file mode 100644
index 00000000000..384bf0832f6
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/local-enum/pck.ads
@@ -0,0 +1,19 @@ 
+--  Copyright 2014-2024 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;