[gcc r14-7042] ada: Avoid xref on out params of TSS

Marc Poulhi?s dkm@gcc.gnu.org
Tue Jan 9 13:14:56 GMT 2024


https://gcc.gnu.org/g:3b9d4258ea755c04f7a7ac1c5e054c098f4bbc93

commit r14-7042-g3b9d4258ea755c04f7a7ac1c5e054c098f4bbc93
Author: Bob Duff <duff@adacore.com>
Date:   Tue Nov 7 07:37:51 2023 -0500

    ada: Avoid xref on out params of TSS
    
    For an actual passed as an 'in out' parameter of a type support
    subprogram such as deep finalize, do not count it as a read
    reference of the actual. Clearly these should not count.
    Furthermore, counting them causes different warnings in -gnatc
    mode compared to normal mode, because the calls only exist in
    normal mode, which would disable the warnings. Such warnings now
    occur in both modes, instead of just with -gnatc.
    
    gcc/ada/
    
            * lib-xref.adb (Generate_Reference): Do not count it as a read
            reference if we're calling a TSS.

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

diff --git a/gcc/ada/lib-xref.adb b/gcc/ada/lib-xref.adb
index 3d6b29862b3..340f5ca73ae 100644
--- a/gcc/ada/lib-xref.adb
+++ b/gcc/ada/lib-xref.adb
@@ -29,6 +29,7 @@ with Einfo;          use Einfo;
 with Einfo.Utils;    use Einfo.Utils;
 with Elists;         use Elists;
 with Errout;         use Errout;
+with Exp_Tss;        use Exp_Tss;
 with Lib.Util;       use Lib.Util;
 with Nlists;         use Nlists;
 with Opt;            use Opt;
@@ -789,10 +790,15 @@ package body Lib.Xref is
          elsif Kind = E_In_Out_Parameter
            and then Is_Assignable (E)
          then
-            --  For sure this counts as a normal read reference
+            --  We count it as a read reference unless we're calling a
+            --  type support subprogram such as deep finalize.
 
-            Set_Referenced (E);
-            Set_Last_Assignment (E, Empty);
+            if not Is_Entity_Name (Name (Call))
+              or else Get_TSS_Name (Entity (Name (Call))) = TSS_Null
+            then
+               Set_Referenced (E);
+               Set_Last_Assignment (E, Empty);
+            end if;
 
             --  We count it as being referenced as an out parameter if the
             --  option is set to warn on all out parameters, except that we


More information about the Gcc-cvs mailing list