]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Fix proof of runtime unit a-strfix and a-strsup
authorClaire Dross <dross@adacore.com>
Tue, 12 Apr 2022 08:57:31 +0000 (10:57 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 19 May 2022 14:05:29 +0000 (14:05 +0000)
Update to provers caused some proof regressions.  Fix the proof by
adding an assertion.

gcc/ada/

* libgnat/a-strfix.adb: Add assertions.
* libgnat/a-strsup.adb: Idem.

gcc/ada/libgnat/a-strfix.adb
gcc/ada/libgnat/a-strsup.adb

index 7475254302466141b31068027415d27aab8eba95..a04bf9a0b1794d08eed5bfc4ab1abdf2c848d854 100644 (file)
@@ -628,6 +628,11 @@ package body Ada.Strings.Fixed with SPARK_Mode is
                  (Result (1 .. Integer'Max (0, Low - Source'First))
                   = Source (Source'First .. Low - 1));
                Result (Front_Len + 1 .. Front_Len + By'Length) := By;
+               pragma Assert
+                 (Result
+                    (Integer'Max (0, Low - Source'First) + 1
+                     .. Integer'Max (0, Low - Source'First) + By'Length)
+                  = By);
 
                if High < Source'Last then
                   Result (Front_Len + By'Length + 1 .. Result'Last) :=
index f1a40a2cd6bf5a224d84b592008dbcd0d64dc235..e301564d86f7fa92316f88b9987549455138b9fd 100644 (file)
@@ -1150,6 +1150,14 @@ package body Ada.Strings.Superbounded with SPARK_Mode is
          Result.Data (Position .. Position - 1 + New_Item'Length) :=
            Super_String_Data (New_Item);
          Result.Current_Length := Source.Current_Length;
+         pragma Assert
+           (String'(Super_Slice (Result, 1, Position - 1)) =
+              Super_Slice (Source, 1, Position - 1));
+         pragma Assert
+           (Super_Slice (Result,
+            Position, Position - 1 + New_Item'Length) =
+              New_Item);
+
          return Result;
 
       elsif Position - 1 <= Max_Length - New_Item'Length then
@@ -1157,6 +1165,14 @@ package body Ada.Strings.Superbounded with SPARK_Mode is
          Result.Data (Position .. Position - 1 + New_Item'Length) :=
            Super_String_Data (New_Item);
          Result.Current_Length := Position - 1 + New_Item'Length;
+         pragma Assert
+           (String'(Super_Slice (Result, 1, Position - 1)) =
+              Super_Slice (Source, 1, Position - 1));
+         pragma Assert
+           (Super_Slice (Result,
+            Position, Position - 1 + New_Item'Length) =
+              New_Item);
+
          return Result;
 
       else
@@ -1189,6 +1205,7 @@ package body Ada.Strings.Superbounded with SPARK_Mode is
          end case;
 
          Result.Current_Length := Max_Length;
+         pragma Assert (Super_Length (Result) = Source.Max_Length);
          return Result;
       end if;
    end Super_Overwrite;