]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Simplify removal of formals from the scope
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 31 Mar 2023 12:40:10 +0000 (14:40 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 29 May 2023 08:23:18 +0000 (10:23 +0200)
Calls to Install_Formals are typically enclosed by Push_Scope/End_Scope.
There were just two such calls that instead used Pop_Scope, but most
likely that was by mistake.

Cleanup related to handling of class-wide contracts. Behavior appears to
be unaffected.

gcc/ada/

* contracts.adb (Remove_Formals): Remove.
(Preanalyze_Condition): Replace Pop_Scope with End_Scope.
* sem_ch13.adb (Build_Discrete_Static_Predicate): Replace
Pop_Scope with End_Scope; enclose Install_Formals within
Push_Scope/End_Scope.

gcc/ada/contracts.adb
gcc/ada/sem_ch13.adb

index 9d02887cfa12c146b11a01b71a9113fc1cbd3110..65f341abc8f20ebacb3a0875c9b38085eeb08826 100644 (file)
@@ -4846,9 +4846,6 @@ package body Contracts is
       --  Traverse Expr and clear the Controlling_Argument of calls to
       --  nonabstract functions.
 
-      procedure Remove_Formals (Id : Entity_Id);
-      --  Remove formals from homonym chains and make them not visible
-
       procedure Restore_Original_Selected_Component;
       --  Traverse Expr searching for dispatching calls to functions whose
       --  original node was a selected component, and replace them with
@@ -4898,21 +4895,6 @@ package body Contracts is
          Remove_Ctrl_Args (Expr);
       end Remove_Controlling_Arguments;
 
-      --------------------
-      -- Remove_Formals --
-      --------------------
-
-      procedure Remove_Formals (Id : Entity_Id) is
-         F : Entity_Id := First_Formal (Id);
-
-      begin
-         while Present (F) loop
-            Set_Is_Immediately_Visible (F, False);
-            Remove_Homonym (F);
-            Next_Formal (F);
-         end loop;
-      end Remove_Formals;
-
       -----------------------------------------
       -- Restore_Original_Selected_Component --
       -----------------------------------------
@@ -5032,8 +5014,7 @@ package body Contracts is
       Preanalyze_Spec_Expression (Expr, Standard_Boolean);
 
       Inside_Class_Condition_Preanalysis := False;
-      Remove_Formals (Subp);
-      Pop_Scope;
+      End_Scope;
 
       --  If this preanalyzed condition has occurrences of dispatching calls
       --  using the Object.Operation notation, during preanalysis such calls
index 958b26ebb0d2b9caee91b196e73779101b4d5120..85c9d92e6301168b9dd1bdff3629b1b140368e27 100644 (file)
@@ -9757,10 +9757,10 @@ package body Sem_Ch13 is
 
                --  Resolve new expression in function context
 
-               Install_Formals (Predicate_Function (Typ));
                Push_Scope (Predicate_Function (Typ));
+               Install_Formals (Predicate_Function (Typ));
                Analyze_And_Resolve (Expr, Standard_Boolean);
-               Pop_Scope;
+               End_Scope;
             end if;
          end;
       end;