From 1ef1ac768ff108a6a2c08e18eec3309e182df142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= Date: Fri, 17 Jun 2022 16:07:35 +0200 Subject: [Ada] Fix missing Overflow and Range checks While doing Preanalysis (as is the case during ghost code handling), some range and/or overflow checks can be saved (see Saved_Checks in checks.adb) and later one omitted as they would be redundant (see Find_Check in checks.adb). In the case of ghost code, the node being Preanalyzed is a temporary copy that is discarded, so its corresponding check is not expanded later. The node that gets expanded later is not having any checks expanded as it is wrongly assumed it has already been done before. As is already the case in Preanalyze_And_Resolve, this change suppresses all checks during Preanalyze except for GNATprove mode. gcc/ada/ * sem.adb (Preanalyze): Suppress checks when not in GNATprove mode. * sem_res.adb (Preanalyze_And_Resolve): Add cross reference in comment to above procedure. * sinfo.ads: Typo fix in comment. --- gcc/ada/sem.adb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'gcc/ada/sem.adb') diff --git a/gcc/ada/sem.adb b/gcc/ada/sem.adb index 796fffb..6c1e9d7 100644 --- a/gcc/ada/sem.adb +++ b/gcc/ada/sem.adb @@ -1338,7 +1338,15 @@ package body Sem is Full_Analysis := False; Expander_Mode_Save_And_Set (False); - Analyze (N); + -- See comment in sem_res.adb for Preanalyze_And_Resolve + + if GNATprove_Mode + or else Nkind (Parent (N)) = N_Simple_Return_Statement + then + Analyze (N); + else + Analyze (N, Suppress => All_Checks); + end if; Expander_Mode_Restore; Full_Analysis := Save_Full_Analysis; -- cgit v1.1