public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-366] [Ada] Fix warning about generic subprograms withed but not referenced
@ 2022-05-12 12:41 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-12 12:41 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:ec0f9f7d88861198d9a94b51eb301567b6752fc5

commit r13-366-gec0f9f7d88861198d9a94b51eb301567b6752fc5
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Fri Feb 11 14:31:39 2022 +0100

    [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.

Diff:
---
 gcc/ada/lib-xref.adb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/lib-xref.adb b/gcc/ada/lib-xref.adb
index 610a4bd17ad..919e41fd2c2 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);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-12 12:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12 12:41 [gcc r13-366] [Ada] Fix warning about generic subprograms withed but not referenced Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).