From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7871) id 8C94A3857BA6; Thu, 6 Oct 2022 09:24:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C94A3857BA6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665048283; bh=3mqZCjNWHEo1t1PMWGkgsGBQuCZ9thiRwLvrxYhSwe0=; h=From:To:Subject:Date:From; b=QePpBcgJunm6SjBiNOKjmHERQV0DKtlx0MGL8OgJWxmCx1ra7kZ2g90LjAx3hYl4f 7lk3Eh9PM58SDq8erjWPvmY9d0a+T/k0e6Nyyzs0XaNyZDQhTrinqQsn7gz4mCu43Y nwtI1G94kv1zDDPfjmp95aE9NB526xexilJa2tt4= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: =?iso-8859-1?q?Marc_Poulhi=E8s?= To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3111] ada: Fix spurious warning on unreferenced refinement constituents X-Act-Checkin: gcc X-Git-Author: Piotr Trojanek X-Git-Refname: refs/heads/master X-Git-Oldrev: ed7278d98e4727a7def30ab91fcef4658e34baa4 X-Git-Newrev: 86b786dc7295f6288296abb38d05572c3f98a758 Message-Id: <20221006092443.8C94A3857BA6@sourceware.org> Date: Thu, 6 Oct 2022 09:24:43 +0000 (GMT) List-Id: https://gcc.gnu.org/g:86b786dc7295f6288296abb38d05572c3f98a758 commit r13-3111-g86b786dc7295f6288296abb38d05572c3f98a758 Author: Piotr Trojanek Date: Mon Sep 26 12:51:41 2022 +0200 ada: Fix spurious warning on unreferenced refinement constituents 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. Diff: --- 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