From patchwork Mon Aug 7 11:16:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 131800 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1374261vqr; Mon, 7 Aug 2023 04:18:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGS0tXgCj0L2ZRvPc+bpa7EOv2d0wZzUdIGHxQ7QWpywf/VR1Y2++7ikoD8y5LBLjN5DkBt X-Received: by 2002:aa7:dc0a:0:b0:522:79e8:e51b with SMTP id b10-20020aa7dc0a000000b0052279e8e51bmr7131267edu.32.1691407080199; Mon, 07 Aug 2023 04:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691407080; cv=none; d=google.com; s=arc-20160816; b=nI2szNvQfn94aEPRHYl2vWMHOGrTwvQ9D0tSwYSoiNzqDEVLjcAMPMbv7XRVe4Sr6v cpI2LpFS3xSSSnamoZtwg/hjaphno6dhkHG0IldGKVuqEOc9voqrGLGPUbbWnsDcgidk ke/TJ4nVVOzc6ZUfnHm/uciQthk2NH5c2lmojvk59uh10DIxHn/hxTdVuYnhrxC7yI6p PJJTNFvxYYE4kWvxEbKSKmJqUgzdU+pGaqjCoLy/wv93/mx3y9YZJuyjdts20u7vtJST e3+eqcqLkv0fRrPvpoLwww+Gk/hN/ihPbdQc3qHOTjcpbEwLwIyQcKHWt/uKx2C4LTRX j63w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Py9DHqnTyAcRLnd2xJzxaV/BY0FPF0+yjOP/vL1qtLQ=; fh=Lj1VijP3LnkAVEPcMi7kRiXijG3l76C04Ep5oiVm8fk=; b=j1FwAWwQyHTcWi9kXUqU4812Udl7libhdnf7vRxaNypmKupnleInvxShnYIBfRqUop jac1v05O4Pq2emeUyK584IQ6t4QCjPS6Xey/POTjVFSplhj3/LAkcC6HbdSigVle7OQT o29cbwAx/e0JMtCKvMBcqJdQssppKnRfIu1XXdKRD1FMynZyBgWu+XnrHwfwl+f/bqBE QVRwVR5FfRy/9NjI2nHVgKDTPiR1/6ajreGkyEMzDxEC2KisfgTbMsmQx5itxnPTb4DH g6DTx7ehQL3tNa5imK33GYLfjt91fxUofrLOJ/ryyCBbOHhk4jHe6vjv54RPrI5KSfL6 nSkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hVh4syR6; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id a7-20020aa7d907000000b005225a609054si399278edr.291.2023.08.07.04.17.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 04:18:00 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hVh4syR6; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A0B3538582B0 for ; Mon, 7 Aug 2023 11:17:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0B3538582B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691407046; bh=Py9DHqnTyAcRLnd2xJzxaV/BY0FPF0+yjOP/vL1qtLQ=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=hVh4syR6grGdYW1YoH25QHjmad8dJtVoAyIi+sp5fYoYOIOnP16D8CDgVUi1zRX7j Ce+MdrS4Lff+5GecgmLUbTGun4KanrbQENEsmLy3XM6dr8R4PtskQUxSq/MQkvtdKQ bmb/V5JjOG936rRrp8qW1xFnDvW8igAfiwdTmo7Q= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id D71EF3858280 for ; Mon, 7 Aug 2023 11:16:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D71EF3858280 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fe167d4a18so42835255e9.0 for ; Mon, 07 Aug 2023 04:16:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691407000; x=1692011800; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Py9DHqnTyAcRLnd2xJzxaV/BY0FPF0+yjOP/vL1qtLQ=; b=Wvu75HwsWUiAAyirQ4BxZ8KDzRoej8685R69ry+qlEwg3U1ImRt8UJJsO+TyVQMhXY lwMRPksHhEtvtxfL9SvZ4vBgKapOmw2It6ZVT+qkaCXJtm/Qa5JLGBSp7zUuQ/CrCfaC mnJ7qlJWOIpMFMLVUYd9mlqw2wpswO6uq6L85y1gW+LskhYC63WP/LVNJVd00n5HwT+u 6PPytvBxdtw7M84Yg2RYbQSk4TjGBYyfCgUhDRrS1YStLpAKlg6LcksRwZ3IH75g9QF7 EH0oguNIqvUy/43u29up6KeRQMfFBKT5thdTk0JeHAzhK9BOoduQwjKWpPLqagJ2VOD/ 66Sw== X-Gm-Message-State: AOJu0YwzJfAVmGJuSJZoKSnHHTYWvAM7DvdIA7AXGMnQwZJ6FfaWh2Op D6QkRt8jeMqfQq1tAYYj25qnNtWT7ieM+/PZtpzHzw== X-Received: by 2002:a7b:cc99:0:b0:3fe:1f98:deb7 with SMTP id p25-20020a7bcc99000000b003fe1f98deb7mr6435305wma.35.1691407000641; Mon, 07 Aug 2023 04:16:40 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id i11-20020a05600c2d8b00b003fe5228b78dsm2843666wmg.1.2023.08.07.04.16.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 04:16:40 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Extend precondition of Interfaces.C.String.Value with Length Date: Mon, 7 Aug 2023 13:16:39 +0200 Message-Id: <20230807111639.2855057-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773568870365965938 X-GMAIL-MSGID: 1773568870365965938 From: Piotr Trojanek The existing precondition guarded against exception Dereference_Error, but not against Constraint_Error. The RM rule B.3.1(36/3) only mentions Constraint_Error for the Value function which returns char_array, but the one which returns String has the same restriction, because it is equivalent to calling the variant which returns char_array and then converted. gcc/ada/ * libgnat/i-cstrin.ads (Value): Extend preconditions; adapt comment for the package. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnat/i-cstrin.ads | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/ada/libgnat/i-cstrin.ads b/gcc/ada/libgnat/i-cstrin.ads index e486f03a585..9f1577f5e14 100644 --- a/gcc/ada/libgnat/i-cstrin.ads +++ b/gcc/ada/libgnat/i-cstrin.ads @@ -36,8 +36,8 @@ -- Preconditions in this unit are meant for analysis only, not for run-time -- checking, so that the expected exceptions are raised. This is enforced by -- setting the corresponding assertion policy to Ignore. These preconditions --- protect from Dereference_Error and Update_Error, but not from --- Storage_Error. +-- protect from Constraint_Error, Dereference_Error and Update_Error, but not +-- from Storage_Error. pragma Assertion_Policy (Pre => Ignore); @@ -95,7 +95,7 @@ is (Item : chars_ptr; Length : size_t) return char_array with - Pre => Item /= Null_Ptr, + Pre => Item /= Null_Ptr and then Length /= 0, Global => (Input => C_Memory); function Value (Item : chars_ptr) return String with @@ -106,7 +106,7 @@ is (Item : chars_ptr; Length : size_t) return String with - Pre => Item /= Null_Ptr, + Pre => Item /= Null_Ptr and then Length /= 0, Global => (Input => C_Memory); function Strlen (Item : chars_ptr) return size_t with