From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 922B13857C59 for ; Thu, 2 Dec 2021 16:28:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 922B13857C59 Received: by mail-wm1-x32c.google.com with SMTP id k37-20020a05600c1ca500b00330cb84834fso2774055wms.2 for ; Thu, 02 Dec 2021 08:28:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=LbaI/VUe5aN/lAwkFpdiOtSvL55+gyfXNxCSUKQK6Os=; b=12Sjdmy/6fndNZ0Ea+Am9p8u12INtcVJ0pdjCrRgavL6JLAGZ4/FHvzYxbZR70/Upp 6P2yD7YvNXR2cak1LeN9qGyF8EadjFqTYhIzvjMYUMD5155vt7jFJU9kNToiSXisBUWw 5RC7i4L9eI6lnPcJFSi91MlQ/tHqTk9+MwnftUCiYvVnpSvG0/26HEZ8QGSGpsB5Eo7b GhwQUvSyLp9sClv27mK/0i/iC7Zylhlliq79aEtmFMBGWExd/3DVbxWzuAGf4JHM3Lcl P+0VGXd+IlnGT9SNRvAGmV77iFysAPPRA7oTAncESNcq27MJL6jM+IC7p4kyvx2pZ37j K8rg== X-Gm-Message-State: AOAM5305lPl5d6iItxtwcmvzp/g4XaGLOpYVmh0wavx8k5X3ufqppviN K2jD0uwyhs1l+4upeu0SnPmM/KLUM3xISQ== X-Google-Smtp-Source: ABdhPJwkdXF2Zf/fArfWHK1zonSEfx6DujI7jpJYnSwHiWeZwgl1Bm1BpDfJBa4fTSB9AdeTxX8JEg== X-Received: by 2002:a1c:7405:: with SMTP id p5mr7330315wmc.152.1638462530615; Thu, 02 Dec 2021 08:28:50 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id i17sm125904wmq.48.2021.12.02.08.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 08:28:49 -0800 (PST) Date: Thu, 2 Dec 2021 16:28:49 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [Ada] Split spec and body of expression function with Subprogram_Variant Message-ID: <20211202162849.GA2158494@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="EVF5PPMfhYS0aIcm" Content-Disposition: inline X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, WEIRD_QUOTING autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Dec 2021 16:28:53 -0000 --EVF5PPMfhYS0aIcm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --EVF5PPMfhYS0aIcm Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" 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; --EVF5PPMfhYS0aIcm--