From patchwork Mon Nov 28 12:05:06 2022 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: 61156 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 64F47384F6DF for ; Mon, 28 Nov 2022 12:05:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 64F47384F6DF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669637138; bh=nMxSk7WT0XNOU4ahN1Bq3xDqp7N3WOesIPT3IvQZzfc=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=v60hrqWaIjuxb3DZNTWooi0ozBXtx3Au7vF983i7zUvTmPdAh4naQW2CvUYCOxyuM RvLGEAUo0l3jL+gIZ/gDds6okGWrwCeALkHDETveLwf8kLL+VsxEyhbY22FmZnytSB 7Jh8C8dKre0a3uZTT007vG4POawd44X6JEjEwBNs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 735EE385B526 for ; Mon, 28 Nov 2022 12:05:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 735EE385B526 Received: by mail-wr1-x42d.google.com with SMTP id v1so16402647wrt.11 for ; Mon, 28 Nov 2022 04:05:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=nMxSk7WT0XNOU4ahN1Bq3xDqp7N3WOesIPT3IvQZzfc=; b=qyUL88+EZHEyh3aVR6MmhipYDsMqLf7s7M4Xxm7oV8DdrtnNM86MaRIxhKpkcVF/lZ YEotIT40PqnhgYsaQ26Fv7byDPXSMGgb3lH7++Mmr1By0Tdib9xXx/rHxCnMp7Wo7mWb pAatpXh8CiXHHPS4dMpziHCfUCoQIuVmNSM+X6CfEm0eLHtxw0nwLzl2dDlPDM0sqILz fb8aSqL8dePaCc/qQxOgg7gWn8Dz5gNNIaHS5rGm22aIqZ1HjLZB1v8M31gHAIk6Kt/5 iv7UnrEBgJ92wzJtE58lngds/5QM75OOfa5n4MggFSJaRkidKGO016vloLTW7VJ3azbP 9Vtw== X-Gm-Message-State: ANoB5pm9AhxaHr/Zl7SM2EcgvvJIrTstNHHcxIsEOdsbKTRJt3a+txmf uMbsMhr1gjC2fXnXlnSc+tI6fc1mFGC/Vw== X-Google-Smtp-Source: AA0mqf4v4/Ogs1MUZiqulAz/p8ueGgvTuVowFI86SpLBCfCMGrnK1LZSRRK0hCWCvZT/PTKsJQy3rA== X-Received: by 2002:a05:6000:989:b0:236:91d0:1f with SMTP id by9-20020a056000098900b0023691d0001fmr23318051wrb.33.1669637109145; Mon, 28 Nov 2022 04:05:09 -0800 (PST) Received: from localhost.localdomain (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id t187-20020a1c46c4000000b003cfa622a18asm18733282wma.3.2022.11.28.04.05.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 04:05:08 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: Claire Dross Subject: [COMMITTED] ada: Annotate GNAT.Source_Info with an abstract state Date: Mon, 28 Nov 2022 13:05:06 +0100 Message-Id: <20221128120506.171614-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Claire Dross So it can be used safely from SPARK code. The abstract state represents the source code information that is accessed by the functions defined in Source_Info. It is volatile as it is updated asyncronously when moving in the code. gcc/ada/ * libgnat/g-souinf.ads (Source_Code_Information): Add a new volatile abstract state and add it in the global contract of all functions defined in Source_Info. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnat/g-souinf.ads | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/gcc/ada/libgnat/g-souinf.ads b/gcc/ada/libgnat/g-souinf.ads index 700f5180c82..6b72a6497f1 100644 --- a/gcc/ada/libgnat/g-souinf.ads +++ b/gcc/ada/libgnat/g-souinf.ads @@ -36,7 +36,13 @@ -- and logging purposes. For example, an exception handler can print out -- the name of the source file in which the exception is handled. -package GNAT.Source_Info is +package GNAT.Source_Info with + SPARK_Mode, + Abstract_State => + (Source_Code_Information with + External => (Async_Writers, Async_Readers)), + Annotate => (GNATprove, Always_Return) +is pragma Preelaborate; -- Note that this unit is Preelaborate, but not Pure, that's because the -- functions here such as Line are clearly not pure functions, and normally @@ -47,6 +53,8 @@ package GNAT.Source_Info is -- intrinsics as not Pure, even in Pure units, so no problems arose. function File return String with + Volatile_Function, + Global => Source_Code_Information, Import, Convention => Intrinsic; -- Return the name of the current file, not including the path information. -- The result is considered to be a static string constant. @@ -57,6 +65,8 @@ package GNAT.Source_Info is -- static expression. function Source_Location return String with + Volatile_Function, + Global => Source_Code_Information, Import, Convention => Intrinsic; -- Return a string literal of the form "name:line", where name is the -- current source file name without path information, and line is the @@ -66,6 +76,8 @@ package GNAT.Source_Info is -- string constant. function Enclosing_Entity return String with + Volatile_Function, + Global => Source_Code_Information, Import, Convention => Intrinsic; -- Return the name of the current subprogram, package, task, entry or -- protected subprogram. The string is in exactly the form used for the @@ -80,15 +92,21 @@ package GNAT.Source_Info is -- from within generic templates. function Compilation_ISO_Date return String with + Volatile_Function, + Global => Source_Code_Information, Import, Convention => Intrinsic; -- Returns date of compilation as a static string "yyyy-mm-dd". function Compilation_Date return String with + Volatile_Function, + Global => Source_Code_Information, Import, Convention => Intrinsic; -- Returns date of compilation as a static string "mmm dd yyyy". This is -- in local time form, and is exactly compatible with C macro __DATE__. function Compilation_Time return String with + Volatile_Function, + Global => Source_Code_Information, Import, Convention => Intrinsic; -- Returns GMT time of compilation as a static string "hh:mm:ss". This is -- in local time form, and is exactly compatible with C macro __TIME__.