]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix missing flag for GNATprove
authorYannick Moy <moy@adacore.com>
Thu, 4 Jan 2024 13:18:04 +0000 (14:18 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 7 May 2024 07:55:53 +0000 (09:55 +0200)
GNATprove expects the frontend to position correctly range check
flags, on expressions which might lead to a range check failure.
This was missing on in-out parameters of calls. Now fixed.

There is no impact on compilation.

gcc/ada/

* sem_res.adb (Resolve_Actuals): Add range check flag.

gcc/ada/sem_res.adb

index 67062c6b32bb5b6089faab16f73b753f3028cef5..dc48b0b7638bda88eba567952cbd25fe9e2a85a0 100644 (file)
@@ -4388,6 +4388,17 @@ package body Sem_Res is
                   Resolve (Expression (A));
                end if;
 
+               --  In GNATprove mode, add a range check flag on scalar
+               --  conversions for IN OUT parameters. The check may be
+               --  needed on entry from the call.
+
+               if GNATprove_Mode
+                 and then Ekind (F) = E_In_Out_Parameter
+                 and then Is_Scalar_Type (Etype (F))
+               then
+                  Set_Do_Range_Check (Expression (A));
+               end if;
+
             --  If the actual is a function call that returns a limited
             --  unconstrained object that needs finalization, create a
             --  transient scope for it, so that it can receive the proper