From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Bob Duff <duff@adacore.com>
Subject: [Ada] Suppress warnings in trivial subprograms with finalization
Date: Mon, 5 Sep 2022 09:26:03 +0200 [thread overview]
Message-ID: <20220905072603.GA1174684@poulhies-Precision-5550> (raw)
[-- Attachment #1: Type: text/plain, Size: 615 bytes --]
There are heuristics for suppressing warnings about unused objects in
trivial cases. In particular, we try to suppress warnings here:
function F (A : Integer) return Some_Type;
X : Some_Type;
begin
raise Not_Yet_Implemented;
return X;
end F;
But it doesn't work if Some_Type is controlled. This patch fixes that
bug.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_ch6.adb
(Analyze_Subprogram_Body_Helper): Use First_Real_Statement to deal
with this case. Note that First_Real_Statement is likely to be
removed as part of this ticket, so this is a temporary fix.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1009 bytes --]
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -5409,14 +5409,20 @@ package body Sem_Ch6 is
-- we have a special test to set X as apparently assigned to suppress
-- the warning.
- declare
- Stm : Node_Id;
+ -- If X above is controlled, we need to use First_Real_Statement to skip
+ -- generated finalization-related code. Otherwise (First_Real_Statement
+ -- is Empty), we just get the first statement.
+ declare
+ Stm : Node_Id := First_Real_Statement (HSS);
begin
+ if No (Stm) then
+ Stm := First (Statements (HSS));
+ end if;
+
-- Skip call markers installed by the ABE mechanism, labels, and
-- Push_xxx_Error_Label to find the first real statement.
- Stm := First (Statements (HSS));
while Nkind (Stm) in N_Call_Marker | N_Label | N_Push_xxx_Label loop
Next (Stm);
end loop;
reply other threads:[~2022-09-05 7:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220905072603.GA1174684@poulhies-Precision-5550 \
--to=poulhies@adacore.com \
--cc=duff@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).