Commit 0e41a941 by Arnaud Charlet

[multiple changes]

2009-07-13  Emmanuel Briot  <briot@adacore.com>

	* prj-err.adb (Error_Msg): One more case where a message should be
	considered as a warning.

	* gnatcmd.adb (GNATCmd): Fix previous change, which negated a test.

2009-07-13  Thomas Quinot  <quinot@adacore.com>

	* exp_dist.adb (Expand_All_Calls_Remote_Subprogram_Call): Analyze
	calling stubs in the (library level) scope of the RCI locator, where it
	is attached, not in the caller's scope.

2009-07-13  Javier Miranda  <miranda@adacore.com>

	* sem_ch3.adb (Analyze_Object_Declaration): In case of class-wide
	interface object declarations we delay the generation of the equivalent
	record type declarations until its expansion because there are cases in
	which they are not required.            

	* sem_util.adb (Implements_Interface): Add missing support for subtypes.

	* sem_disp.adb (Check_Controlling_Formals): Minor code cleanup plus
	addition of assertion.

	* exp_util.adb (Expand_Subtype_From_Expr): Renamings of class-wide
	interface types require no equivalent constrained type declarations
	because the expanded code only references the tag component associated
	with the interface.
	(Find_Interface_Tag): Improve management of interfaces that are
	ancestors of tagged types.

	* exp_ch3.adb (Expand_N_Object_Declaration): Improve the expansion of
	class-wide object declarations to add missing support to statically
	displace the pointer to the object to reference the tag component
	associated with the interface.

	* exp_disp.adb (Make_Tags) Avoid generation of internally generated
	auxiliary types associated with user-defined dispatching calls if the
	type has no user-defined primitives.

From-SVN: r149574
parent 75069667
2009-07-13 Emmanuel Briot <briot@adacore.com>
* prj-err.adb (Error_Msg): One more case where a message should be
considered as a warning.
* gnatcmd.adb (GNATCmd): Fix previous change, which negated a test.
2009-07-13 Thomas Quinot <quinot@adacore.com>
* exp_dist.adb (Expand_All_Calls_Remote_Subprogram_Call): Analyze
calling stubs in the (library level) scope of the RCI locator, where it
is attached, not in the caller's scope.
2009-07-13 Javier Miranda <miranda@adacore.com>
* sem_ch3.adb (Analyze_Object_Declaration): In case of class-wide
interface object declarations we delay the generation of the equivalent
record type declarations until its expansion because there are cases in
which they are not required.
* sem_util.adb (Implements_Interface): Add missing support for subtypes.
* sem_disp.adb (Check_Controlling_Formals): Minor code cleanup plus
addition of assertion.
* exp_util.adb (Expand_Subtype_From_Expr): Renamings of class-wide
interface types require no equivalent constrained type declarations
because the expanded code only references the tag component associated
with the interface.
(Find_Interface_Tag): Improve management of interfaces that are
ancestors of tagged types.
* exp_ch3.adb (Expand_N_Object_Declaration): Improve the expansion of
class-wide object declarations to add missing support to statically
displace the pointer to the object to reference the tag component
associated with the interface.
* exp_disp.adb (Make_Tags) Avoid generation of internally generated
auxiliary types associated with user-defined dispatching calls if the
type has no user-defined primitives.
2009-07-13 Vasiliy Fofanov <fofanov@adacore.com> 2009-07-13 Vasiliy Fofanov <fofanov@adacore.com>
* mingw32.h: Make it explicit that we need XP or later. * mingw32.h: Make it explicit that we need XP or later.
......
...@@ -6118,21 +6118,27 @@ package body Exp_Disp is ...@@ -6118,21 +6118,27 @@ package body Exp_Disp is
end loop; end loop;
end if; end if;
-- 3) At the end of Access_Disp_Table we add the entity of an access -- 3) At the end of Access_Disp_Table, if the type has user-defined
-- type declaration. It is used by Build_Get_Prim_Op_Address to -- primitives, we add the entity of an access type declaration that
-- expand dispatching calls through the primary dispatch table. -- is used by Build_Get_Prim_Op_Address to expand dispatching calls
-- through the primary dispatch table.
if UI_To_Int (DT_Entry_Count (First_Tag_Component (Typ))) = 0 then
Analyze_List (Result);
-- Generate: -- Generate:
-- type Typ_DT is array (1 .. Nb_Prims) of Prim_Ptr; -- type Typ_DT is array (1 .. Nb_Prims) of Prim_Ptr;
-- type Typ_DT_Acc is access Typ_DT; -- type Typ_DT_Acc is access Typ_DT;
else
declare declare
Name_DT_Prims : constant Name_Id := Name_DT_Prims : constant Name_Id :=
New_External_Name (Tname, 'G'); New_External_Name (Tname, 'G');
Name_DT_Prims_Acc : constant Name_Id := Name_DT_Prims_Acc : constant Name_Id :=
New_External_Name (Tname, 'H'); New_External_Name (Tname, 'H');
DT_Prims : constant Entity_Id := DT_Prims : constant Entity_Id :=
Make_Defining_Identifier (Loc, Name_DT_Prims); Make_Defining_Identifier (Loc,
Name_DT_Prims);
DT_Prims_Acc : constant Entity_Id := DT_Prims_Acc : constant Entity_Id :=
Make_Defining_Identifier (Loc, Make_Defining_Identifier (Loc,
Name_DT_Prims_Acc); Name_DT_Prims_Acc);
...@@ -6165,17 +6171,18 @@ package body Exp_Disp is ...@@ -6165,17 +6171,18 @@ package body Exp_Disp is
-- Analyze the resulting list and suppress the generation of the -- Analyze the resulting list and suppress the generation of the
-- Init_Proc associated with the above array declaration because -- Init_Proc associated with the above array declaration because
-- we never use such type in object declarations; this type is only -- this type is never used in object declarations. It is only used
-- used to simplify the expansion associated with dispatching calls. -- to simplify the expansion associated with dispatching calls.
Analyze_List (Result); Analyze_List (Result);
Set_Suppress_Init_Proc (Base_Type (DT_Prims)); Set_Suppress_Init_Proc (Base_Type (DT_Prims));
-- Mark entity of dispatch table. Required by the backend to handle -- Mark entity of dispatch table. Required by the back end to
-- the properly. -- handle them properly.
Set_Is_Dispatch_Table_Entity (DT_Prims); Set_Is_Dispatch_Table_Entity (DT_Prims);
end; end;
end if;
Set_Ekind (DT_Ptr, E_Constant); Set_Ekind (DT_Ptr, E_Constant);
Set_Is_Tag (DT_Ptr); Set_Is_Tag (DT_Ptr);
......
...@@ -2755,11 +2755,11 @@ package body Exp_Dist is ...@@ -2755,11 +2755,11 @@ package body Exp_Dist is
--------------------------------------------- ---------------------------------------------
procedure Expand_All_Calls_Remote_Subprogram_Call (N : Node_Id) is procedure Expand_All_Calls_Remote_Subprogram_Call (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
Called_Subprogram : constant Entity_Id := Entity (Name (N)); Called_Subprogram : constant Entity_Id := Entity (Name (N));
RCI_Package : constant Entity_Id := Scope (Called_Subprogram); RCI_Package : constant Entity_Id := Scope (Called_Subprogram);
Loc : constant Source_Ptr := Sloc (N); RCI_Locator_Decl : Node_Id;
RCI_Locator : Node_Id; RCI_Locator : Entity_Id;
RCI_Cache : Entity_Id;
Calling_Stubs : Node_Id; Calling_Stubs : Node_Id;
E_Calling_Stubs : Entity_Id; E_Calling_Stubs : Entity_Id;
...@@ -2767,41 +2767,35 @@ package body Exp_Dist is ...@@ -2767,41 +2767,35 @@ package body Exp_Dist is
E_Calling_Stubs := RCI_Calling_Stubs_Table.Get (Called_Subprogram); E_Calling_Stubs := RCI_Calling_Stubs_Table.Get (Called_Subprogram);
if E_Calling_Stubs = Empty then if E_Calling_Stubs = Empty then
RCI_Cache := RCI_Locator_Table.Get (RCI_Package); RCI_Locator := RCI_Locator_Table.Get (RCI_Package);
if RCI_Cache = Empty then
RCI_Locator :=
RCI_Package_Locator
(Loc, Specification (Unit_Declaration_Node (RCI_Package)));
Prepend_To (Current_Sem_Unit_Declarations, RCI_Locator);
-- The RCI_Locator package is inserted at the top level in the -- The RCI_Locator package and calling stub are is inserted at the
-- current unit, and must appear in the proper scope, so that it -- top level in the current unit, and must appear in the proper scope
-- is not prematurely removed by the GCC back-end. -- so that it is not prematurely removed by the GCC back end.
declare declare
Scop : constant Entity_Id := Cunit_Entity (Current_Sem_Unit); Scop : constant Entity_Id := Cunit_Entity (Current_Sem_Unit);
begin begin
if Ekind (Scop) = E_Package_Body then if Ekind (Scop) = E_Package_Body then
Push_Scope (Spec_Entity (Scop)); Push_Scope (Spec_Entity (Scop));
elsif Ekind (Scop) = E_Subprogram_Body then elsif Ekind (Scop) = E_Subprogram_Body then
Push_Scope Push_Scope
(Corresponding_Spec (Unit_Declaration_Node (Scop))); (Corresponding_Spec (Unit_Declaration_Node (Scop)));
else else
Push_Scope (Scop); Push_Scope (Scop);
end if; end if;
Analyze (RCI_Locator);
Pop_Scope;
end; end;
RCI_Cache := Defining_Unit_Name (RCI_Locator); if RCI_Locator = Empty then
RCI_Locator_Decl :=
RCI_Package_Locator
(Loc, Specification (Unit_Declaration_Node (RCI_Package)));
Prepend_To (Current_Sem_Unit_Declarations, RCI_Locator_Decl);
Analyze (RCI_Locator_Decl);
RCI_Locator := Defining_Unit_Name (RCI_Locator_Decl);
else else
RCI_Locator := Parent (RCI_Cache); RCI_Locator_Decl := Parent (RCI_Locator);
end if; end if;
Calling_Stubs := Build_Subprogram_Calling_Stubs Calling_Stubs := Build_Subprogram_Calling_Stubs
...@@ -2811,10 +2805,12 @@ package body Exp_Dist is ...@@ -2811,10 +2805,12 @@ package body Exp_Dist is
Asynchronous => Nkind (N) = N_Procedure_Call_Statement Asynchronous => Nkind (N) = N_Procedure_Call_Statement
and then and then
Is_Asynchronous (Called_Subprogram), Is_Asynchronous (Called_Subprogram),
Locator => RCI_Cache, Locator => RCI_Locator,
New_Name => New_Internal_Name ('S')); New_Name => New_Internal_Name ('S'));
Insert_After (RCI_Locator, Calling_Stubs); Insert_After (RCI_Locator_Decl, Calling_Stubs);
Analyze (Calling_Stubs); Analyze (Calling_Stubs);
Pop_Scope;
E_Calling_Stubs := Defining_Unit_Name (Specification (Calling_Stubs)); E_Calling_Stubs := Defining_Unit_Name (Specification (Calling_Stubs));
end if; end if;
......
...@@ -1350,6 +1350,17 @@ package body Exp_Util is ...@@ -1350,6 +1350,17 @@ package body Exp_Util is
Make_Subtype_From_Expr (Exp, Underlying_Record_View (Unc_Type))); Make_Subtype_From_Expr (Exp, Underlying_Record_View (Unc_Type)));
end if; end if;
-- Renamings of class-wide interface types require no equivalent
-- constrained type declarations because we only need to reference
-- the tag component associated with the interface.
elsif Present (N)
and then Nkind (N) = N_Object_Renaming_Declaration
and then Is_Interface (Unc_Type)
then
pragma Assert (Is_Class_Wide_Type (Unc_Type));
null;
-- In Ada95, nothing to be done if the type of the expression is -- In Ada95, nothing to be done if the type of the expression is
-- limited, because in this case the expression cannot be copied, -- limited, because in this case the expression cannot be copied,
-- and its use can only be by reference. -- and its use can only be by reference.
...@@ -1371,16 +1382,6 @@ package body Exp_Util is ...@@ -1371,16 +1382,6 @@ package body Exp_Util is
then then
null; null;
-- For limited interfaces, nothing to be done
-- This branch may be redundant once the limited interface issue is
-- sorted out???
elsif Is_Interface (Exp_Typ)
and then Is_Limited_Interface (Exp_Typ)
then
null;
-- For limited objects initialized with build in place function calls, -- For limited objects initialized with build in place function calls,
-- nothing to be done; otherwise we prematurely introduce an N_Reference -- nothing to be done; otherwise we prematurely introduce an N_Reference
-- node in the expression initializing the object, which breaks the -- node in the expression initializing the object, which breaks the
...@@ -1546,15 +1547,10 @@ package body Exp_Util is ...@@ -1546,15 +1547,10 @@ package body Exp_Util is
AI : Node_Id; AI : Node_Id;
begin begin
-- Check if the interface is an immediate ancestor of the type and -- This routine does not handle the case in which the interface is an
-- therefore shares the main tag. -- ancestor of Typ. That case is handled by the enclosing subprogram.
if Typ = Iface then pragma Assert (Typ /= Iface);
pragma Assert (Etype (First_Tag_Component (Typ)) = RTE (RE_Tag));
AI_Tag := First_Tag_Component (Typ);
Found := True;
return;
end if;
-- Climb to the root type handling private types -- Climb to the root type handling private types
...@@ -1632,9 +1628,20 @@ package body Exp_Util is ...@@ -1632,9 +1628,20 @@ package body Exp_Util is
Typ := Corresponding_Record_Type (Typ); Typ := Corresponding_Record_Type (Typ);
end if; end if;
-- If the interface is an ancestor of the type, then it shared the
-- primary dispatch table.
if Is_Ancestor (Iface, Typ) 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); Find_Tag (Typ);
pragma Assert (Found); pragma Assert (Found);
return AI_Tag; return AI_Tag;
end if;
end Find_Interface_Tag; end Find_Interface_Tag;
------------------ ------------------
......
...@@ -2117,16 +2117,16 @@ begin ...@@ -2117,16 +2117,16 @@ begin
end if; end if;
end loop; end loop;
-- If the naming scheme of the project file is not standard, -- If the project file naming scheme is not standard, and if
-- and if the file name ends with the spec suffix, then -- the file name ends with the spec suffix, then indicate to
-- indicate to gnatstub the name of the body file with -- gnatstub the name of the body file with a -o switch.
-- a -o switch.
if Is_Standard_GNAT_Naming (Lang.Config.Naming_Data) then if not Is_Standard_GNAT_Naming (Lang.Config.Naming_Data) then
if File_Index /= 0 then if File_Index /= 0 then
declare declare
Spec : constant String := Spec : constant String :=
Base_Name (Last_Switches.Table (File_Index).all); Base_Name
(Last_Switches.Table (File_Index).all);
Last : Natural := Spec'Last; Last : Natural := Spec'Last;
begin begin
...@@ -2193,8 +2193,7 @@ begin ...@@ -2193,8 +2193,7 @@ begin
end if; end if;
-- For gnat check, -rules and the following switches need to be the -- For gnat check, -rules and the following switches need to be the
-- last options. So, we move all these switches to table -- last options, so move all these switches to table Rules_Switches.
-- Rules_Switches.
if The_Command = Check then if The_Command = Check then
declare declare
......
...@@ -113,7 +113,9 @@ package body Prj.Err is ...@@ -113,7 +113,9 @@ package body Prj.Err is
-- Let the application know there was an error -- Let the application know there was an error
if Flags.Report_Error /= null then if Flags.Report_Error /= null then
Flags.Report_Error (Project, Is_Warning => Msg (Msg'First) = '?'); Flags.Report_Error
(Project,
Is_Warning => Msg (Msg'First) = '?' or Msg (Msg'First) = '<');
end if; end if;
end Error_Msg; end Error_Msg;
......
...@@ -591,7 +591,7 @@ package body Sem_Ch3 is ...@@ -591,7 +591,7 @@ package body Sem_Ch3 is
function Is_Progenitor function Is_Progenitor
(Iface : Entity_Id; (Iface : Entity_Id;
Typ : Entity_Id) return Boolean; Typ : Entity_Id) return Boolean;
-- Determine whether type Typ implements interface Iface. This requires -- Determine whether the interface Iface is implemented by Typ. It requires
-- traversing the list of abstract interfaces of the type, as well as that -- traversing the list of abstract interfaces of the type, as well as that
-- of the ancestor types. The predicate is used to determine when a formal -- of the ancestor types. The predicate is used to determine when a formal
-- in the signature of an inherited operation must carry the derived type. -- in the signature of an inherited operation must carry the derived type.
...@@ -2725,6 +2725,13 @@ package body Sem_Ch3 is ...@@ -2725,6 +2725,13 @@ package body Sem_Ch3 is
then then
Act_T := Etype (E); Act_T := Etype (E);
-- In case of class-wide interface object declarations we delay
-- the generation of the equivalent record type declarations until
-- its expansion because there are cases in they are not required.
elsif Is_Interface (T) then
null;
else else
Expand_Subtype_From_Expr (N, T, Object_Definition (N), E); Expand_Subtype_From_Expr (N, T, Object_Definition (N), E);
Act_T := Find_Type_Of_Object (Object_Definition (N), N); Act_T := Find_Type_Of_Object (Object_Definition (N), N);
......
...@@ -4937,26 +4937,22 @@ package body Sem_Util is ...@@ -4937,26 +4937,22 @@ package body Sem_Util is
is is
Ifaces_List : Elist_Id; Ifaces_List : Elist_Id;
Elmt : Elmt_Id; Elmt : Elmt_Id;
Iface : Entity_Id; Iface : Entity_Id := Base_Type (Iface_Ent);
Typ : Entity_Id; Typ : Entity_Id := Base_Type (Typ_Ent);
begin begin
if Is_Class_Wide_Type (Typ_Ent) then if Is_Class_Wide_Type (Typ) then
Typ := Etype (Typ_Ent); Typ := Root_Type (Typ);
else
Typ := Typ_Ent;
end if;
if Is_Class_Wide_Type (Iface_Ent) then
Iface := Etype (Iface_Ent);
else
Iface := Iface_Ent;
end if; end if;
if not Has_Interfaces (Typ) then if not Has_Interfaces (Typ) then
return False; return False;
end if; end if;
if Is_Class_Wide_Type (Iface) then
Iface := Root_Type (Iface);
end if;
Collect_Interfaces (Typ, Ifaces_List); Collect_Interfaces (Typ, Ifaces_List);
Elmt := First_Elmt (Ifaces_List); Elmt := First_Elmt (Ifaces_List);
......
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