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: 26714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5611965wrr; Mon, 28 Nov 2022 04:06:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf67BCzUaX9eMXdg6nV6fBpFSF1B57KCURzICyotkdr8WBzVjrDRjRq4BUttScOI6rC+6d4g X-Received: by 2002:a19:4319:0:b0:499:b108:947e with SMTP id q25-20020a194319000000b00499b108947emr16342372lfa.143.1669637197505; Mon, 28 Nov 2022 04:06:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669637197; cv=none; d=google.com; s=arc-20160816; b=tewWjBo2CYu2M28OzJAy/SwAJ0S9+o3LdGtajQqtzS2HKt0iXWySQyMNvHKw2MwZSh vQhMJHGxVwgQIG3mZsISDjjViVOxeS3IuPXpq3XHLgOUGMQNoV8I5shkWmU/fxTEfk7I MQtAm+8tZ/dPaBpVi1/MUfhcr66CyAnq90oC+w4GhjrC5h1w09dvaECn2DJxIDNi9tSJ IDO6C1K4mrFWO1u9o+n/8k1Jfix4guxXG284iVeAO4ozFTmwt4OUSmwL0r1Vg2Jr/Ki4 UDRzQMpRD635eKSQkapE2yop0QNoVyWmq/N/M6s51wwv19JZXXAsIBiR5wEJg3YlxIhL mAMA== 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=nMxSk7WT0XNOU4ahN1Bq3xDqp7N3WOesIPT3IvQZzfc=; b=EBigJNHky/WFG1I5eD4rgySMJZvxCtgofMfSM46f/kGt5AGNJrvTPdeqdF4CgD2fTs fPfv43dduVh/KOrNt0NA5yCVbSzEKuc659ntczQK/c9dOQoOUJXtuuZ3x4nP6p55lAeA 59T3Ktx7MnmbL9PudnW30+byQOd+6yhJusUFGylrEgEmmAldXqM65MjqzHohlOvbj7q9 UQ22Pk8dWGb9SdVsYfhI74i7o1EBp36tLMknwzjB8dmjHVYMktMNJZsD7NS5nKMCMoDC ksWV7gI/hlmCgqns+Pgu65DRBRFAZ4MnnDL7/FZs6Tk61PXcAYvPEInKhW3i2t+cU938 Yw+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Prj9jdtx; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id x88-20020a50bae1000000b004699f2ef797si8125845ede.73.2022.11.28.04.06.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 04:06:37 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Prj9jdtx; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 48CC238532FC for ; Mon, 28 Nov 2022 12:05:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 48CC238532FC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669637153; bh=nMxSk7WT0XNOU4ahN1Bq3xDqp7N3WOesIPT3IvQZzfc=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Prj9jdtxJ7LkKkeS6Ds+WKqUS6XhuuFT1aPqi04gymF8Laja6IyyX710DxTfMdkxR e0twpWjTPApbmTR3503kdG1MSFXLBOpL89XmkxKlbvWOVTgIIyM/4nvDsMVXeLBFyo IVrzpm6L6wb10DXzw2mC2fq8Xln7ch1+QXYF4HsQ= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750741493838349432?= X-GMAIL-MSGID: =?utf-8?q?1750741493838349432?= 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__.