https://gcc.gnu.org/g:625c4ec2b3d3a59138a0a00178307ecba916aeea

commit r15-4893-g625c4ec2b3d3a59138a0a00178307ecba916aeea
Author: Piotr Trojanek <troja...@adacore.com>
Date:   Fri Sep 27 16:56:52 2024 +0200

    ada: Assignment local variable only when it is used
    
    Code cleanup; semantics is unaffected.
    
    gcc/ada/ChangeLog:
    
            * sem_res.adb (In_Decl): Rename and move local variable where
            it is used.

Diff:
---
 gcc/ada/sem_res.adb | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 4c92b5629442..d28e724e8829 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -1637,11 +1637,9 @@ package body Sem_Res is
 
          function In_Decl return Boolean is
             Decl_Node : constant Node_Id := Parent (E);
-            N2        : Node_Id;
+            Context   : Node_Id;
 
          begin
-            N2 := N;
-
             if Etype (E) = Any_Type then
                return True;
 
@@ -1649,13 +1647,15 @@ package body Sem_Res is
                return False;
 
             else
-               while Present (N2)
-                 and then Nkind (N2) /= N_Compilation_Unit
+               Context := N;
+
+               while Present (Context)
+                 and then Nkind (Context) /= N_Compilation_Unit
                loop
-                  if N2 = Decl_Node then
+                  if Context = Decl_Node then
                      return True;
                   else
-                     N2 := Parent (N2);
+                     Context := Parent (Context);
                   end if;
                end loop;
 
@@ -1912,7 +1912,7 @@ package body Sem_Res is
          end if;
       end if;
 
-      Set_Chars  (Op_Node, Op_Name);
+      Set_Chars (Op_Node, Op_Name);
 
       if not Is_Private_Type (Etype (N)) then
          Set_Etype (Op_Node, Base_Type (Etype (N)));

Reply via email to