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

commit r16-1168-gabc2efc4fba94bc4043031dc891d45ba9ad10919
Author: squirek <squi...@adacore.com>
Date:   Mon Jan 13 21:04:51 2025 +0000

    ada: Confusing "modified by call, but value overwritten" warning
    
    The patch fixes an issue in the compiler whereby not referencing a local
    variable used in multiple procedure calls as an "out" actual in between
    calls would lead to a warning despite "-gnatw.o" not being present.
    Additionally, this meant that using pragma Unreferenced on such variables
    would not be able to silence such warnings.
    
    gcc/ada/ChangeLog:
    
            * sem_warn.adb
            (Warn_On_Useless_Assignment): Disable out value "overwritten" 
warning
            when we are not warning on unread out parameters (e.g. "-gnatw.o").

Diff:
---
 gcc/ada/sem_warn.adb | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index 35ef61664723..1bc97a851039 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -4670,9 +4670,11 @@ package body Sem_Warn is
                      if Nkind (Parent (LA)) in N_Procedure_Call_Statement
                                              | N_Parameter_Association
                      then
-                        Error_Msg_NE
-                          ("?m?& modified by call, but value overwritten #!",
-                           LA, Ent);
+                        if Warn_On_All_Unread_Out_Parameters then
+                           Error_Msg_NE
+                            ("?m?& modified by call, but value overwritten #!",
+                             LA, Ent);
+                        end if;
                      else
                         Error_Msg_NE -- CODEFIX
                           ("?m?useless assignment to&, value overwritten #!",

Reply via email to