Commit d58008d2 by Eric Botcazou Committed by Pierre-Marie de Rodat

[Ada] Preparation for new description of interface thunks

This adjusts and exposes a couple of functions of the front-end used for the
generation of interface thunks so as to make them callable from gigi.  This
also propagates the debug info setting from the targets to the thunks so as
to make stepping into primitives work better in the debugger.

2018-09-26  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* exp_disp.adb (Expand_Interface_Conversion): Use Present test.
	(Expand_Interface_Thunk): Propagate debug info setting from
	target.
	* exp_util.ads (Find_Interface_Tag): Adjust comment.
	* exp_util.adb (Find_Interface_Tag): Remove assertions of
	success.
	* sem_util.adb (Is_Variable_Size_Record): Only look at
	components and robustify the implementation.
	* fe.h (Find_Interface_Tag): Declare.
	(Is_Variable_Size_Record): Likewise.

From-SVN: r264614
parent 52ba224d
2018-09-26 Eric Botcazou <ebotcazou@adacore.com>
* exp_disp.adb (Expand_Interface_Conversion): Use Present test.
(Expand_Interface_Thunk): Propagate debug info setting from
target.
* exp_util.ads (Find_Interface_Tag): Adjust comment.
* exp_util.adb (Find_Interface_Tag): Remove assertions of
success.
* sem_util.adb (Is_Variable_Size_Record): Only look at
components and robustify the implementation.
* fe.h (Find_Interface_Tag): Declare.
(Is_Variable_Size_Record): Likewise.
2018-09-26 Thomas Quinot <quinot@adacore.com>
* exp_util.adb (Make_CW_Equivalent_Type): Propagate bit order
......
......@@ -1454,7 +1454,7 @@ package body Exp_Disp is
end if;
Iface_Tag := Find_Interface_Tag (Operand_Typ, Iface_Typ);
pragma Assert (Iface_Tag /= Empty);
pragma Assert (Present (Iface_Tag));
-- Keep separate access types to interfaces because one internal
-- function is used to handle the null value (see following comments)
......@@ -2046,6 +2046,7 @@ package body Exp_Disp is
Set_Ekind (Thunk_Id, Ekind (Prim));
Set_Is_Thunk (Thunk_Id);
Set_Convention (Thunk_Id, Convention (Prim));
Set_Needs_Debug_Info (Thunk_Id, Needs_Debug_Info (Target));
Set_Thunk_Entity (Thunk_Id, Target);
-- Procedure case
......
......@@ -5529,7 +5529,6 @@ package body Exp_Util is
then
-- Skip the tag associated with the primary table
pragma Assert (Etype (First_Tag_Component (Typ)) = RTE (RE_Tag));
AI_Tag := Next_Tag_Component (First_Tag_Component (Typ));
pragma Assert (Present (AI_Tag));
......@@ -5590,14 +5589,12 @@ package body Exp_Util is
-- primary dispatch table.
if Is_Ancestor (Iface, Typ, Use_Full_View => True) then
pragma Assert (Etype (First_Tag_Component (Typ)) = RTE (RE_Tag));
return First_Tag_Component (Typ);
-- Otherwise we need to search for its associated tag component
else
Find_Tag (Typ);
pragma Assert (Found);
return AI_Tag;
end if;
end Find_Interface_Tag;
......
......@@ -585,8 +585,9 @@ package Exp_Util is
function Find_Interface_Tag
(T : Entity_Id;
Iface : Entity_Id) return Entity_Id;
-- Ada 2005 (AI-251): Given a type T implementing the interface Iface,
-- return the record component containing the tag of Iface.
-- Ada 2005 (AI-251): Given a type T and an interface Iface, return the
-- record component containing the tag of Iface if T implements Iface or
-- Empty if it does not.
function Find_Prim_Op (T : Entity_Id; Name : Name_Id) return Entity_Id;
-- Find the first primitive operation of a tagged type T with name Name.
......
......@@ -159,8 +159,10 @@ extern void Get_External_Name (Entity_Id, Boolean, String_Pointer);
/* exp_util: */
#define Is_Fully_Repped_Tagged_Type exp_util__is_fully_repped_tagged_type
#define Find_Interface_Tag exp_util__find_interface_tag
extern Boolean Is_Fully_Repped_Tagged_Type (Entity_Id);
extern Entity_Id Find_Interface_Tag (Entity_Id, Entity_Id);
/* lib: */
......@@ -269,12 +271,14 @@ extern Boolean Is_OK_Static_Subtype (Entity_Id);
#define Defining_Entity sem_util__defining_entity
#define First_Actual sem_util__first_actual
#define Next_Actual sem_util__next_actual
#define Is_Variable_Size_Record sem_util__is_variable_size_record
#define Requires_Transient_Scope sem_util__requires_transient_scope
extern Entity_Id Defining_Entity (Node_Id);
extern Node_Id First_Actual (Node_Id);
extern Node_Id Next_Actual (Node_Id);
extern Boolean Requires_Transient_Scope (Entity_Id);
extern Boolean Is_Variable_Size_Record (Entity_Id Id);
extern Boolean Requires_Transient_Scope (Entity_Id);
/* sinfo: */
......
......@@ -17714,9 +17714,9 @@ package body Sem_Util is
begin
pragma Assert (Is_Record_Type (E));
Comp := First_Entity (E);
Comp := First_Component (E);
while Present (Comp) loop
Comp_Typ := Etype (Comp);
Comp_Typ := Underlying_Type (Etype (Comp));
-- Recursive call if the record type has discriminants
......@@ -17732,7 +17732,7 @@ package body Sem_Util is
return True;
end if;
Next_Entity (Comp);
Next_Component (Comp);
end loop;
return False;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment