From patchwork Thu Oct 6 09:25:44 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: 1759 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp217788wrs; Thu, 6 Oct 2022 02:26:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5KpTAN/859CJj1zELC9UA9LFdUkf21VMNU5+RDEt2ukxTonLCwZ1a9R/JS5iuekF4xGvLS X-Received: by 2002:a05:6402:b3c:b0:458:f680:6ab8 with SMTP id bo28-20020a0564020b3c00b00458f6806ab8mr3695849edb.267.1665048418148; Thu, 06 Oct 2022 02:26:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665048418; cv=none; d=google.com; s=arc-20160816; b=PQc535Zu6gYdV1ait+Px/SGl+lSPt1pWGtxvrhHdlnRfc9rVL48zmGDP/FZrBVbm5m qw07fOa5MuhhZi7mlYELXu95e+dNk/eUpi4rnpxUfWBtTSbvKWfJRiuZeLncxxSMVgrZ orP7v03bfPnxywosZlW8XDi8Yrhs/v3y9DNyMuZI8SPfI3tZVvUTBfKcaa6/mM3bRhjd xUb4j/WPI68P6QQ5AF1zYrTn6RUCDT0Ij2rZn+xqdaSADg0tvGk+Qwz2Wze9r2lXuT5g lwMI95PG9OiGCgZg6o1Xeoy6lMPkRjAQ87deMWJxmAUrLEs55TwHZMYuhQZVOjBTGcHO LEzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=qbQ1Nh18J60eXQd2hMnDs/QsEB34EPNV1lm14gRvL58=; b=iDqET8eYQ/4SATLRhBElQWQlxG4K/Lawb8pSm8rMcyyOlIAtYeVXBorCJcl0iNNG33 mIAm4D4KL6Q4m2nhmtCCbVheFQPST02wIjYX7gqlPmYxsV44fVUh9s4N1oBJ95Zh0jz0 ipfLumoO5kIPdh/owtcli0TjqPU+jtAtwonaNKnIPQSUmIAfxR2oypp3FNywF3F4ZBkz tcPwTRgT0NAXHK3eDWIRMnlLH0ejsA4L1mRSO4AeZbhQ+wgIvtVqxpHf/hfHRQqY1IKu tMZubhppiZuGuG7onal70qsDOm8N+UnUgRvzG2WoVgAxjVyp47ZK6H5qiILD2L9mZQ5V 1DMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=PnLFv61B; 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 xg7-20020a170907320700b0078873e4754dsi15199115ejb.774.2022.10.06.02.26.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 02:26:57 -0700 (PDT) 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=PnLFv61B; 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 1E4B3384B82F for ; Thu, 6 Oct 2022 09:26:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E4B3384B82F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665048416; bh=qbQ1Nh18J60eXQd2hMnDs/QsEB34EPNV1lm14gRvL58=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=PnLFv61BgjiVdlIskcPBZ+KQBy+mC9Guwvxsbvgi0S72LiBxy8HSwKECJIKylTOWe +FZEC8W1MsDPwYZFJv5p+KZChYib1/39Y5aytBFa48hTE11SpqRzfXPTDf2r4wTy8A 5ywAOaFyJ9C2Fd4x7gwL9dAJ9SNTkjB3HoGNzvMM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 38618384D1BF for ; Thu, 6 Oct 2022 09:26:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 38618384D1BF Received: by mail-wr1-x42a.google.com with SMTP id r13so1726349wrj.11 for ; Thu, 06 Oct 2022 02:26:12 -0700 (PDT) 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=qbQ1Nh18J60eXQd2hMnDs/QsEB34EPNV1lm14gRvL58=; b=aJ4rvEqzDg6yWQh5oV3mDFSYmTLaTSOLv5IH/cs/EdjP+FwUCokF91rqi+Cvhi1CmX FMni5IVWG3c0K8wY1B42DJYhvJjg1p/i0+9JNzmy590vOh+aLKR9gf+4SWeBfF51faN/ FEzWcPV3lW/Q2bXfSN77hKzjlGiYR0zVl2kWXViWcshuQMRJUGylzSU0WmNsQng0Yco/ xo6lpVOxPqdBXiZZgXCiMBzYe074lGVC/TlnZvsndT6HdQntwOccLaBTL+iRru4foZyL ePSkJMdvIVhRBhyWA0nUW8XNGYG//6r2ws2TlZlA9YcJFwvWx7l+TNvFJ//qZqQiVuTx hK1A== X-Gm-Message-State: ACrzQf3ArV9YzwVK9/beKxHElMOww1ce3gcExr3Kt/dcZyMFEpEoxomq 8QdCy941isSKgcH+kWHLH6XJETQnVBQKCzC3 X-Received: by 2002:adf:fc4e:0:b0:22e:2fd4:1b31 with SMTP id e14-20020adffc4e000000b0022e2fd41b31mr2455553wrs.29.1665048370861; Thu, 06 Oct 2022 02:26:10 -0700 (PDT) Received: from poulhies-Precision-5550.lan (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id f13-20020a5d568d000000b0022584c82c80sm17516412wrv.19.2022.10.06.02.26.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 02:26:10 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [COMMITED] ada: Fix spurious warning on unreferenced refinement constituents Date: Thu, 6 Oct 2022 11:25:44 +0200 Message-Id: <20221006092544.260196-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 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?= Cc: Piotr Trojanek 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?1745929809236971402?= X-GMAIL-MSGID: =?utf-8?q?1745929809236971402?= From: Piotr Trojanek Listing an object as a state refinement constituent shouldn't be considered to be a reference, at least from the point of view of the machinery for detecting objects that are never referenced or written without being referenced. This patch fixes a spurious warning that rarely occurred in practice but was annoyingly emitted for minimal reproducers for issues related to state abstractions. Note: there are other pragmas that should be similarly recognized (e.g. Depends, Global and their refined variants), but recognizing them efficiently probably requires a dedicated utility routine (i.e. to avoid traversal of the parent chain for every kind of pragma). gcc/ada/ * sem_prag.adb (Sig_Pragma): Change flag for pragma Refined_State to mean "not significant"; this is primarily for documentation, because the exact value of the flag is not really taken into account for Refined_State. (Is_Non_Significant_Pragma_Reference): Add special handling for pragma Refined_State. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_prag.adb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 77ff68e23cb..0c3dd815263 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -31608,7 +31608,7 @@ package body Sem_Prag is Pragma_Refined_Depends => -1, Pragma_Refined_Global => -1, Pragma_Refined_Post => -1, - Pragma_Refined_State => -1, + Pragma_Refined_State => 0, Pragma_Relative_Deadline => 0, Pragma_Remote_Access_Type => -1, Pragma_Remote_Call_Interface => -1, @@ -31713,6 +31713,15 @@ package body Sem_Prag is P := Parent (N); if Nkind (P) /= N_Pragma_Argument_Association then + + -- References within pragma Refined_State are not significant. They + -- can't be recognized using pragma argument number, because they + -- appear inside refinement clauses that rely on aggregate syntax. + + if In_Pragma_Expression (N, Name_Refined_State) then + return True; + end if; + return False; else