diff mbox series

[Ada] Remove shadowing by a nested subprogram parameter

Message ID 20201125132724.GA116019@adacore.com
State New
Headers show
Series [Ada] Remove shadowing by a nested subprogram parameter | expand

Commit Message

Pierre-Marie de Rodat Nov. 25, 2020, 1:27 p.m. UTC
In Expand_N_Exception_Renaming_Declaration we had a local constant "Nam"
which was then shadowed by a parameter "Nam" in a nested function
Evaluation_Required. Cleanup only; semantics is unaffected.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* exp_ch8.adb (Expand_N_Exception_Renaming_Declaration): Move
	"Nam" constant after the body of a nested subprogram; change "T"
	from variable to constant.
diff mbox series

Patch

diff --git a/gcc/ada/exp_ch8.adb b/gcc/ada/exp_ch8.adb
--- a/gcc/ada/exp_ch8.adb
+++ b/gcc/ada/exp_ch8.adb
@@ -101,10 +101,6 @@  package body Exp_Ch8 is
    --  More comments needed for this para ???
 
    procedure Expand_N_Object_Renaming_Declaration (N : Node_Id) is
-      Nam  : constant Node_Id := Name (N);
-      Decl : Node_Id;
-      T    : Entity_Id;
-
       function Evaluation_Required (Nam : Node_Id) return Boolean;
       --  Determines whether it is necessary to do static name evaluation for
       --  renaming of Nam. It is considered necessary if evaluating the name
@@ -165,6 +161,12 @@  package body Exp_Ch8 is
          end if;
       end Evaluation_Required;
 
+      --  Local variables
+
+      Decl : Node_Id;
+      Nam  : constant Node_Id   := Name (N);
+      T    : constant Entity_Id := Etype (Defining_Identifier (N));
+
    --  Start of processing for Expand_N_Object_Renaming_Declaration
 
    begin
@@ -177,8 +179,6 @@  package body Exp_Ch8 is
 
       --  Deal with construction of subtype in class-wide case
 
-      T := Etype (Defining_Identifier (N));
-
       if Is_Class_Wide_Type (T) then
          Expand_Subtype_From_Expr (N, T, Subtype_Mark (N), Name (N));
          Find_Type (Subtype_Mark (N));