diff options
author | Bob Duff <duff@adacore.com> | 2022-07-20 17:37:51 -0400 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2022-09-05 09:21:03 +0200 |
commit | fc32180d704e59553584ae2a814089c2af1bce09 (patch) | |
tree | d3ef834afc1a3407debaef5c747d9477dfda0560 | |
parent | 7449db0bf4a2c920538a7f947ccec2831802ded4 (diff) | |
download | gcc-fc32180d704e59553584ae2a814089c2af1bce09.zip gcc-fc32180d704e59553584ae2a814089c2af1bce09.tar.gz gcc-fc32180d704e59553584ae2a814089c2af1bce09.tar.bz2 |
[Ada] Suppress warnings in trivial subprograms with finalization
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.
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.
-rw-r--r-- | gcc/ada/sem_ch6.adb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index e4af71c..7240129 100644 --- 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; |