From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Piotr Trojanek <trojanek@adacore.com>
Subject: [Ada] Split spec and body of expression function with Subprogram_Variant
Date: Thu, 2 Dec 2021 16:28:49 +0000 [thread overview]
Message-ID: <20211202162849.GA2158494@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 526 bytes --]
Due to a latent bug with freezing, the expression function with
Subprogram_Variant which was recently added to the System.Val_Util unit
triggers a crash in CodePeer.
Ordinary compilation was not affected by this bug, because of the
Assertion_Policy (Ghost => Ignore) applied to this unit.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* libgnat/s-valuti.ads (Scan_Natural_Ghost): Split body from
spec and put it into private part, so that GNATprove can pick it
both when analysing the unit and its clients.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1735 bytes --]
diff --git a/gcc/ada/libgnat/s-valuti.ads b/gcc/ada/libgnat/s-valuti.ads
--- a/gcc/ada/libgnat/s-valuti.ads
+++ b/gcc/ada/libgnat/s-valuti.ads
@@ -218,21 +218,6 @@ is
P : Natural;
Acc : Natural)
return Natural
- is
- (if Str (P) = '_' then
- Scan_Natural_Ghost (Str, P + 1, Acc)
- else
- (declare
- Shift_Acc : constant Natural :=
- Acc * 10 + (Character'Pos (Str (P)) - Character'Pos ('0'));
- begin
- (if P = Str'Last
- or else Str (P + 1) not in '0' .. '9' | '_'
- or else Shift_Acc >= Integer'Last / 10
- then
- Shift_Acc
- else
- Scan_Natural_Ghost (Str, P + 1, Shift_Acc))))
with
Ghost,
Subprogram_Variant => (Increases => P),
@@ -352,4 +337,31 @@ is
-- no check for this case, the caller must ensure this condition is met.
pragma Warnings (GNATprove, On, """Ptr"" is not modified");
+private
+
+ ------------------------
+ -- Scan_Natural_Ghost --
+ ------------------------
+
+ function Scan_Natural_Ghost
+ (Str : String;
+ P : Natural;
+ Acc : Natural)
+ return Natural
+ is
+ (if Str (P) = '_' then
+ Scan_Natural_Ghost (Str, P + 1, Acc)
+ else
+ (declare
+ Shift_Acc : constant Natural :=
+ Acc * 10 + (Character'Pos (Str (P)) - Character'Pos ('0'));
+ begin
+ (if P = Str'Last
+ or else Str (P + 1) not in '0' .. '9' | '_'
+ or else Shift_Acc >= Integer'Last / 10
+ then
+ Shift_Acc
+ else
+ Scan_Natural_Ghost (Str, P + 1, Shift_Acc))));
+
end System.Val_Util;
reply other threads:[~2021-12-02 16:28 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=20211202162849.GA2158494@adacore.com \
--to=derodat@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=trojanek@adacore.com \
/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).