From 320eb42df09f3cb96fea9a7b090ae61d9edb20b6 Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Mon, 10 Jan 2022 10:29:40 -0500 Subject: [Ada] Use "aspect" instead of "pragma" in warnings For warnings related to the Unreferenced, Unmodified, and Unused aspects, refer to the "aspect", not the "pragma". Note that the aspect can be set by an aspect_specification or a pragma, so the term "aspect" is correct even in the pragma case. However, messages in sem_prag.adb use Fix_Error, so they refer to "aspect" or "pragma". It's not clear that we really ought to refer to "pragma", now that those are obsolete, but de call Fix_Error for uniformity. We do not attempt to make Fix_Error available outside sem_prag.adb -- too much trouble for something that perhaps ought to be removed. gcc/ada/ * lib-xref.adb, sem_util.adb: Change wording of warning messages to use "aspect". * sem_prag.adb: Use Fix_Error to change wording of warnings. * doc/gnat_rm/implementation_defined_pragmas.rst: Minor: fix cut&paste error. * gnat_rm.texi: Regenerate. --- gcc/ada/lib-xref.adb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gcc/ada/lib-xref.adb') diff --git a/gcc/ada/lib-xref.adb b/gcc/ada/lib-xref.adb index 359e006..610a4bd 100644 --- a/gcc/ada/lib-xref.adb +++ b/gcc/ada/lib-xref.adb @@ -936,10 +936,10 @@ package body Lib.Xref is if Chars (BE) = Chars (E) then if Has_Pragma_Unused (E) then Error_Msg_NE -- CODEFIX - ("??pragma Unused given for&!", N, BE); + ("??aspect Unused specified for&!", N, BE); else Error_Msg_NE -- CODEFIX - ("??pragma Unreferenced given for&!", N, BE); + ("??aspect Unreferenced specified for&!", N, BE); end if; exit; end if; @@ -952,10 +952,10 @@ package body Lib.Xref is elsif Has_Pragma_Unused (E) then Error_Msg_NE -- CODEFIX - ("??pragma Unused given for&!", N, E); + ("??aspect Unused specified for&!", N, E); else Error_Msg_NE -- CODEFIX - ("??pragma Unreferenced given for&!", N, E); + ("??aspect Unreferenced specified for&!", N, E); end if; end if; -- cgit v1.1 From ec0f9f7d88861198d9a94b51eb301567b6752fc5 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Fri, 11 Feb 2022 14:31:39 +0100 Subject: [Ada] Fix warning about generic subprograms withed but not referenced For warnings about unreferenced entities and unused WITH clauses we typically exclude references outside of the extended main source unit. However, we include references to variables of formal private types to warn in the instance if the corresponding type is not a fully initialized type. This special case was unnecessarily applied to references to other entities of formal private types. In particular, we applied it to the references to generic functions, where the full initialization of the formal private type doesn't matter. As an extreme example, this special case was unnecessarily applied to "pragma Pure (Unchecked_Conversion)" in the runtime unit. gcc/ada/ * lib-xref.adb (Generate_Reference): Fix comment and implement it precisely. --- gcc/ada/lib-xref.adb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/ada/lib-xref.adb') diff --git a/gcc/ada/lib-xref.adb b/gcc/ada/lib-xref.adb index 610a4bd..919e41f 100644 --- a/gcc/ada/lib-xref.adb +++ b/gcc/ada/lib-xref.adb @@ -664,7 +664,7 @@ package body Lib.Xref is -- a default in an instance. -- We also set the referenced flag in a generic package that is not in - -- then main source unit, when the variable is of a formal private type, + -- the main source unit, when the object is of a formal private type, -- to warn in the instance if the corresponding type is not a fully -- initialized type. @@ -694,6 +694,7 @@ package body Lib.Xref is return; elsif Inside_A_Generic + and then Is_Object (E) and then Is_Generic_Type (Etype (E)) then Set_Referenced (E); -- cgit v1.1 From b341b8130f80c9acec384e7acc98283bccd349d2 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Tue, 26 Apr 2022 15:21:00 +0200 Subject: [Ada] Deconstruct deferred references While cleaning up and modifying code for unreferenced warnings we removed all calls to Defer_Reference, which was the only routine that populated the Deferred_References table. Consequently, all the code related to this table became dead. gcc/ada/ * lib-xref.ads (Deferred_Reference_Entry, Defer_Reference, Process_Deferred_References, Has_Deferred_Reference): Remove client API. * lib-xref.adb (Deferred_References, Defer_Reference, Has_Deferred_Reference, Process_Deferred_References): Remove implementation. * frontend.adb, sem_ch11.adb, sem_ch5.adb, sem_res.adb, sem_util.adb, sem_warn.adb: Remove uses of Deferred_References. --- gcc/ada/lib-xref.adb | 65 ---------------------------------------------------- 1 file changed, 65 deletions(-) (limited to 'gcc/ada/lib-xref.adb') diff --git a/gcc/ada/lib-xref.adb b/gcc/ada/lib-xref.adb index 919e41f..a4ff69a 100644 --- a/gcc/ada/lib-xref.adb +++ b/gcc/ada/lib-xref.adb @@ -57,14 +57,6 @@ package body Lib.Xref is -- Declarations -- ------------------ - package Deferred_References is new Table.Table ( - Table_Component_Type => Deferred_Reference_Entry, - Table_Index_Type => Int, - Table_Low_Bound => 0, - Table_Initial => 512, - Table_Increment => 200, - Table_Name => "Name_Deferred_References"); - -- The Xref table is used to record references. The Loc field is set -- to No_Location for a definition entry. @@ -211,21 +203,6 @@ package body Lib.Xref is end if; end Add_Entry; - --------------------- - -- Defer_Reference -- - --------------------- - - procedure Defer_Reference (Deferred_Reference : Deferred_Reference_Entry) is - begin - -- If Get_Ignore_Errors, then we are in Preanalyze_Without_Errors, and - -- we should not record cross references, because that will cause - -- duplicates when we call Analyze. - - if not Get_Ignore_Errors then - Deferred_References.Append (Deferred_Reference); - end if; - end Defer_Reference; - ----------- -- Equal -- ----------- @@ -1291,21 +1268,6 @@ package body Lib.Xref is return E; end Get_Key; - ---------------------------- - -- Has_Deferred_Reference -- - ---------------------------- - - function Has_Deferred_Reference (Ent : Entity_Id) return Boolean is - begin - for J in Deferred_References.First .. Deferred_References.Last loop - if Deferred_References.Table (J).E = Ent then - return True; - end if; - end loop; - - return False; - end Has_Deferred_Reference; - ---------- -- Hash -- ---------- @@ -2753,33 +2715,6 @@ package body Lib.Xref is end Output_Refs; end Output_References; - --------------------------------- - -- Process_Deferred_References -- - --------------------------------- - - procedure Process_Deferred_References is - begin - for J in Deferred_References.First .. Deferred_References.Last loop - declare - D : Deferred_Reference_Entry renames Deferred_References.Table (J); - - begin - case Known_To_Be_Assigned (D.N) is - when True => - Generate_Reference (D.E, D.N, 'm'); - - when False => - Generate_Reference (D.E, D.N, 'r'); - - end case; - end; - end loop; - - -- Clear processed entries from table - - Deferred_References.Init; - end Process_Deferred_References; - -- Start of elaboration for Lib.Xref begin -- cgit v1.1