public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-643] [Ada] Fix proof of runtime unit a-strfix and a-strsup
Date: Thu, 19 May 2022 14:07:04 +0000 (GMT)	[thread overview]
Message-ID: <20220519140704.AA975385703E@sourceware.org> (raw)

https://gcc.gnu.org/g:c92f4fddd68463e7bc21e6a71c89848410311351

commit r13-643-gc92f4fddd68463e7bc21e6a71c89848410311351
Author: Claire Dross <dross@adacore.com>
Date:   Tue Apr 12 10:57:31 2022 +0200

    [Ada] Fix proof of runtime unit a-strfix and a-strsup
    
    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.

Diff:
---
 gcc/ada/libgnat/a-strfix.adb |  5 +++++
 gcc/ada/libgnat/a-strsup.adb | 17 +++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/gcc/ada/libgnat/a-strfix.adb b/gcc/ada/libgnat/a-strfix.adb
index 74752543024..a04bf9a0b17 100644
--- a/gcc/ada/libgnat/a-strfix.adb
+++ b/gcc/ada/libgnat/a-strfix.adb
@@ -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) :=
diff --git a/gcc/ada/libgnat/a-strsup.adb b/gcc/ada/libgnat/a-strsup.adb
index f1a40a2cd6b..e301564d86f 100644
--- a/gcc/ada/libgnat/a-strsup.adb
+++ b/gcc/ada/libgnat/a-strsup.adb
@@ -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;


                 reply	other threads:[~2022-05-19 14:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220519140704.AA975385703E@sourceware.org \
    --to=pmderodat@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).