From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x42a.google.com with SMTP id r13so1726349wrj.11 for ; Thu, 06 Oct 2022 02:26:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qbQ1Nh18J60eXQd2hMnDs/QsEB34EPNV1lm14gRvL58=; b=TVWxKOaVCEeoNCj+wpYP60kWppcu0zwhbx5QwQ4cIcXFCs81phTMFFgoW5puLk5W6x FIpbObFFIO8G13CNHdTuguGbJ6q24pujVz/JaUOQpCITuzFRwqa82ydMCqx+wt+kAs3d j/AfUvekqXNVvcSXp7wN77EHyesem7GikBS/VYt5Vo/3jg9y3GXJV0N4RD1GMULyhZSN +3nMioLPWJlU+pYduS2JsfKfsozUBr/RHBhp5cvk0GS3eP4enObE7kjlMjcqpH6c8iKb 4dARMzF8XupITOPi07Sxh/UE3J/kGTsk4jh/lJCjtKJMqifK+jVdTrTIJ4CLkIgfl4hH JCKg== 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-Google-Smtp-Source: AMsMyM7YKQjReQH+y4CnZkbt3oXSgF25dsBkHozu9wx4zX889inZtoFdtKM+A38M/BD2nwRs8dgt9Q== 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) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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 -- 2.34.1