summaryrefslogtreecommitdiff
path: root/gcc/ada/sem_util.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-20 12:18:09 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-20 12:18:09 +0000
commitf1cabbf47b50e8c6228ab05a8392e001a58dd7d4 (patch)
tree71bceedb186341d23abe6ec26381f6a4827c7043 /gcc/ada/sem_util.adb
parent7e2d3667c4bd5eb0d804839bfc861a71a8f66b03 (diff)
downloadgcc-f1cabbf47b50e8c6228ab05a8392e001a58dd7d4.tar.gz
2015-10-20 Ed Schonberg <schonberg@adacore.com>
* sem_prag.adb: Code clean up. 2015-10-20 Hristian Kirtchev <kirtchev@adacore.com> * exp_ch6.adb (Expand_N_Extended_Return_Statement): Code cleanup. (Make_Build_In_Place_Call_In_Object_Declaration): Update the parameter profile. Code cleanup. Request debug info for the object renaming declaration. (Move_Activation_Chain): Add new formal parameter and update the comment on usage. * exp_ch6.ads (Make_Build_In_Place_Call_In_Object_Declaration): Update the parameter profile and comment on usage. * sem_util.ads, sem_util.adb (Remove_Overloaded_Entity): New routine, currently unused. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229067 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sem_util.adb')
-rw-r--r--gcc/ada/sem_util.adb100
1 files changed, 100 insertions, 0 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index e0c857b1177..a6eb50c52b7 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -16961,6 +16961,106 @@ package body Sem_Util is
end if;
end Remove_Homonym;
+ ------------------------------
+ -- Remove_Overloaded_Entity --
+ ------------------------------
+
+ procedure Remove_Overloaded_Entity (Id : Entity_Id) is
+ procedure Remove_Primitive_Of (Typ : Entity_Id);
+ -- Remove primitive subprogram Id from the list of primitives that
+ -- belong to type Typ.
+
+ -------------------------
+ -- Remove_Primitive_Of --
+ -------------------------
+
+ procedure Remove_Primitive_Of (Typ : Entity_Id) is
+ Prims : Elist_Id;
+
+ begin
+ if Is_Tagged_Type (Typ) then
+ Prims := Direct_Primitive_Operations (Typ);
+
+ if Present (Prims) then
+ Remove (Prims, Id);
+ end if;
+ end if;
+ end Remove_Primitive_Of;
+
+ -- Local variables
+
+ Scop : constant Entity_Id := Scope (Id);
+ Formal : Entity_Id;
+ Prev_Id : Entity_Id;
+
+ -- Start of processing for Remove_Overloaded_Entity
+
+ begin
+ -- Remove the entity from the homonym chain. When the entity is the
+ -- head of the chain, associate the entry in the name table with its
+ -- homonym effectively making it the new head of the chain.
+
+ if Current_Entity (Id) = Id then
+ Set_Name_Entity_Id (Chars (Id), Homonym (Id));
+
+ -- Otherwise link the previous and next homonyms
+
+ else
+ Prev_Id := Current_Entity (Id);
+ while Present (Prev_Id) and then Homonym (Prev_Id) /= Id loop
+ Prev_Id := Homonym (Prev_Id);
+ end loop;
+
+ Set_Homonym (Prev_Id, Homonym (Id));
+ end if;
+
+ -- Remove the entity from the scope entity chain. When the entity is
+ -- the head of the chain, set the next entity as the new head of the
+ -- chain.
+
+ if First_Entity (Scop) = Id then
+ Prev_Id := Empty;
+ Set_First_Entity (Scop, Next_Entity (Id));
+
+ -- Otherwise the entity is either in the middle of the chain or it acts
+ -- as its tail. Traverse and link the previous and next entities.
+
+ else
+ Prev_Id := First_Entity (Scop);
+ while Present (Prev_Id) and then Next_Entity (Prev_Id) /= Id loop
+ Next_Entity (Prev_Id);
+ end loop;
+
+ Set_Next_Entity (Prev_Id, Next_Entity (Id));
+ end if;
+
+ -- Handle the case where the entity acts as the tail of the scope entity
+ -- chain.
+
+ if Last_Entity (Scop) = Id then
+ Set_Last_Entity (Scop, Prev_Id);
+ end if;
+
+ -- The entity denotes a primitive subprogram. Remove it from the list of
+ -- primitives of the associated controlling type.
+
+ if Ekind_In (Id, E_Function, E_Procedure) and then Is_Primitive (Id) then
+ Formal := First_Formal (Id);
+ while Present (Formal) loop
+ if Is_Controlling_Formal (Formal) then
+ Remove_Primitive_Of (Etype (Formal));
+ exit;
+ end if;
+
+ Next_Formal (Formal);
+ end loop;
+
+ if Ekind (Id) = E_Function and then Has_Controlling_Result (Id) then
+ Remove_Primitive_Of (Etype (Id));
+ end if;
+ end if;
+ end Remove_Overloaded_Entity;
+
---------------------
-- Rep_To_Pos_Flag --
---------------------