[Ada] Remove shadowing by a nested subprogram parameter
authorPiotr Trojanek <trojanek@adacore.com>
Thu, 15 Oct 2020 08:45:28 +0000 (10:45 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 25 Nov 2020 13:22:44 +0000 (08:22 -0500)
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.

gcc/ada/exp_ch8.adb

index 9f4c65c89bad65ff236fcb07e5e5bfcb5fa8d7be..facd12e0cbe3bedfda065d82763698f281dad1fc 100644 (file)
@@ -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));