From 63efd116baafd6210a65b29973766c3fa264098f Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 21 Jan 2025 08:19:21 -0700 Subject: [PATCH] Preserve local variables in another Ada test case 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 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 . +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 . + +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 . + +with System; +package Pck is + procedure Do_Nothing (A : System.Address); +end Pck; -- 2.39.5