public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix proof of runtime unit s-valeu
@ 2022-05-18  8:43 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-18  8:43 UTC (permalink / raw)
  To: gcc-patches; +Cc: Claire Dross

[-- Attachment #1: Type: text/plain, Size: 210 bytes --]

Update to provers caused some proof regressions.  Fix the proof by
changing ghost code.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* libgnat/s-valueu.adb (Scan_Raw_Unsigned): Add assertions.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1831 bytes --]

diff --git a/gcc/ada/libgnat/s-valueu.adb b/gcc/ada/libgnat/s-valueu.adb
--- a/gcc/ada/libgnat/s-valueu.adb
+++ b/gcc/ada/libgnat/s-valueu.adb
@@ -522,6 +522,9 @@ package body System.Value_U is
                   Uval := Base;
                   Base := 10;
                   pragma Assert (Ptr.all = Last_Num_Init + 1);
+                  pragma Assert
+                    (if Starts_As_Based then P = Last_Num_Based + 1);
+                  pragma Assert (not Is_Based);
                   pragma Assert (if not Overflow then Uval = Init_Val.Value);
                   exit;
                end if;
@@ -569,10 +572,6 @@ package body System.Value_U is
                   end if;
                end if;
 
-               Lemma_Scan_Digit
-                 (Str, P, Last_Num_Based, Digit, Base, Old_Uval, Uval,
-                  Based_Val, Old_Overflow, Overflow);
-
                --  If at end of string with no base char, not a based number
                --  but we signal Constraint_Error and set the pointer past
                --  the end of the field, since this is what the ACVC tests
@@ -580,6 +579,10 @@ package body System.Value_U is
 
                P := P + 1;
 
+               Lemma_Scan_Digit
+                 (Str, P - 1, Last_Num_Based, Digit, Base, Old_Uval, Uval,
+                  Based_Val, Old_Overflow, Overflow);
+
                if P > Max then
                   Ptr.all := P;
                   Bad_Value (Str);
@@ -590,6 +593,7 @@ package body System.Value_U is
                if Str (P) = Base_Char then
                   Ptr.all := P + 1;
                   pragma Assert (Ptr.all = Last_Num_Based + 2);
+                  pragma Assert (Is_Based);
                   pragma Assert
                     (if not Overflow then
                        Based_Val = Scan_Based_Number_Ghost



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-18  8:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-18  8:43 [Ada] Fix proof of runtime unit s-valeu Pierre-Marie de Rodat

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).