From patchwork Mon Oct 25 15:09:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 46631 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 689E3385840D for ; Mon, 25 Oct 2021 15:21:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 689E3385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635175273; bh=ctI0aRqomfiGgIAGJhrbmYhE3m1bxdp6DD4ng93F9Gs=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=jmRUXtbQncwMWp9Ta2CMTBCfiULI74MVpbq/BCJUjsa+6wkTlM82SlQO0s1Slq+F0 /WjBEDJ9v+b5zn3Sdaf6mT+vjWMnUvyMoGpMpFBSOmAYFPA8qUYo9HKoRIpwmPd0pi 2rFCDv6dO7ERXXw2puRhYHLoLBJpwbS7JXwvoDpE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by sourceware.org (Postfix) with ESMTPS id 6023D385840D for ; Mon, 25 Oct 2021 15:09:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6023D385840D Received: by mail-lj1-x235.google.com with SMTP id h11so1543988ljk.1 for ; Mon, 25 Oct 2021 08:09:22 -0700 (PDT) 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=ctI0aRqomfiGgIAGJhrbmYhE3m1bxdp6DD4ng93F9Gs=; b=Nm9ShO+harlezWoH/zmK9mXgTr+TUj1cWpQFP6fK6bKtjAUfCzPa+Q21UZDzYbccNg rQE5Xh6BhJCHqR3g7NP00skPq+85vov1rmcNAvNj/8W7Hrus08KtdKcoLysy9DwxIiiJ klU1WlTL9R/Au8X4ItkRFjbZoIg5cXJYph/HyGYnW8MhT55n+Qxh/9LLIBxk+g2ct+yC jmDpfKFIqOnvtdp5XYtnTJ5zpJkL11KD0rG/nRDQvprSlWi/UdCnvU4zVhJ1GTNObfWy gGGrCOX58Phdm2bHceCnqQ7rlWsz5Uthcnskjj+fagYz+ltlZvjWTgCrVq9KoqPARruZ NcSA== X-Gm-Message-State: AOAM53359we5HuoCByaZAeI/zpa308yySxuT8/YJ1rYfNyM4CMRz48B7 gxYMc2/SisXHiNpf4Un5P/4gqLD+r19lOjXQ X-Google-Smtp-Source: ABdhPJx/n2k+kG2Zden4fmBo3UIFnoXJ5CXtnVd2GesTvJhpQF7aYeBknr+HBI3rz1tPlxKKPMLf8g== X-Received: by 2002:a2e:8041:: with SMTP id p1mr19895294ljg.158.1635174559867; Mon, 25 Oct 2021 08:09:19 -0700 (PDT) Received: from adacore.com ([2a02:2ab8:224:2ce:72b5:e8ff:feef:ee60]) by smtp.gmail.com with ESMTPSA id d30sm1670686lfj.87.2021.10.25.08.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 08:09:19 -0700 (PDT) Date: Mon, 25 Oct 2021 15:09:18 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Global contracts on expression functions in Ada.Strings.Superbounded Message-ID: <20211025150918.GA346629@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.0 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 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-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Piotr Trojanek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" For consistency, add Global => null contracts also to expression functions in the Ada.Strings.Superbounded package. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/a-strsup.ads (Super_Length, Super_Element, Super_Slice): Add Global contracts. diff --git a/gcc/ada/libgnat/a-strsup.ads b/gcc/ada/libgnat/a-strsup.ads --- a/gcc/ada/libgnat/a-strsup.ads +++ b/gcc/ada/libgnat/a-strsup.ads @@ -76,7 +76,8 @@ package Ada.Strings.Superbounded with SPARK_Mode is -- that they can be renamed in Ada.Strings.Bounded.Generic_Bounded_Length. function Super_Length (Source : Super_String) return Natural - is (Source.Current_Length); + is (Source.Current_Length) + with Global => null; -------------------------------------------------------- -- Conversion, Concatenation, and Selection Functions -- @@ -620,7 +621,8 @@ package Ada.Strings.Superbounded with SPARK_Mode is is (if Index <= Source.Current_Length then Source.Data (Index) else raise Index_Error) - with Pre => Index <= Super_Length (Source); + with Pre => Index <= Super_Length (Source), + Global => null; procedure Super_Replace_Element (Source : in out Super_String; @@ -649,8 +651,9 @@ package Ada.Strings.Superbounded with SPARK_Mode is -- get the null string in accordance with normal Ada slice rules. String (Source.Data (Low .. High))) - with Pre => Low - 1 <= Super_Length (Source) - and then High <= Super_Length (Source); + with Pre => Low - 1 <= Super_Length (Source) + and then High <= Super_Length (Source), + Global => null; function Super_Slice (Source : Super_String;