Commit 361effb1 by Arnaud Charlet

[multiple changes]

2009-04-15  Robert Dewar  <dewar@adacore.com>

	* sem_prag.adb: Minor reformatting.

	* sem_type.adb: Minor reformatting

2009-04-15  Javier Miranda  <miranda@adacore.com>

	* sem_ch6.adb (Analyze_Abstract_Subprogram_Declaration): Add missing
	support to check eliminated subprograms.

	* sem_elim.ads (Eliminate_Error_Msg): Update documentation.

	* sem_elim.adb (Set_Eliminated): Add support for elimination of
	dispatching subprograms.

	* exp_disp.adb (Make_DT): Minor code cleanup when freezing primitive
	operations. Initialize with "null" the slots of eliminated dispaching
	primitives.
	(Write_DT): Add output for eliminated primitives.

	* sem_disp.adb (Check_Dispatching_Call): Check eliminated primitives.

From-SVN: r146093
parent 5afaa917
2009-04-15 Robert Dewar <dewar@adacore.com>
* sem_prag.adb: Minor reformatting.
* sem_type.adb: Minor reformatting
2009-04-15 Javier Miranda <miranda@adacore.com>
* sem_ch6.adb (Analyze_Abstract_Subprogram_Declaration): Add missing
support to check eliminated subprograms.
* sem_elim.ads (Eliminate_Error_Msg): Update documentation.
* sem_elim.adb (Set_Eliminated): Add support for elimination of
dispatching subprograms.
* exp_disp.adb (Make_DT): Minor code cleanup when freezing primitive
operations. Initialize with "null" the slots of eliminated dispaching
primitives.
(Write_DT): Add output for eliminated primitives.
* sem_disp.adb (Check_Dispatching_Call): Check eliminated primitives.
2009-04-15 Ed Schonberg <schonberg@adacore.com> 2009-04-15 Ed Schonberg <schonberg@adacore.com>
* sem_ch8.adb (Use_One_Type): If both clauses appear on the same unit, * sem_ch8.adb (Use_One_Type): If both clauses appear on the same unit,
...@@ -3941,27 +3941,29 @@ package body Exp_Disp is ...@@ -3941,27 +3941,29 @@ package body Exp_Disp is
then then
declare declare
Save : constant Boolean := Freezing_Library_Level_Tagged_Type; Save : constant Boolean := Freezing_Library_Level_Tagged_Type;
Prim : Entity_Id;
Prim_Elmt : Elmt_Id; Prim_Elmt : Elmt_Id;
Frnodes : List_Id; Frnodes : List_Id;
begin begin
Freezing_Library_Level_Tagged_Type := True; Freezing_Library_Level_Tagged_Type := True;
Prim_Elmt := First_Elmt (Primitive_Operations (Typ)); Prim_Elmt := First_Elmt (Primitive_Operations (Typ));
while Present (Prim_Elmt) loop while Present (Prim_Elmt) loop
Frnodes := Freeze_Entity (Node (Prim_Elmt), Loc); Prim := Node (Prim_Elmt);
Frnodes := Freeze_Entity (Prim, Loc);
declare declare
Subp : constant Entity_Id := Node (Prim_Elmt);
F : Entity_Id; F : Entity_Id;
begin begin
F := First_Formal (Subp); F := First_Formal (Prim);
while Present (F) loop while Present (F) loop
Check_Premature_Freezing (Subp, Etype (F)); Check_Premature_Freezing (Prim, Etype (F));
Next_Formal (F); Next_Formal (F);
end loop; end loop;
Check_Premature_Freezing (Subp, Etype (Subp)); Check_Premature_Freezing (Prim, Etype (Prim));
end; end;
if Present (Frnodes) then if Present (Frnodes) then
...@@ -3970,6 +3972,7 @@ package body Exp_Disp is ...@@ -3970,6 +3972,7 @@ package body Exp_Disp is
Next_Elmt (Prim_Elmt); Next_Elmt (Prim_Elmt);
end loop; end loop;
Freezing_Library_Level_Tagged_Type := Save; Freezing_Library_Level_Tagged_Type := Save;
end; end;
end if; end if;
...@@ -5145,6 +5148,7 @@ package body Exp_Disp is ...@@ -5145,6 +5148,7 @@ package body Exp_Disp is
if Is_Imported (Prim) if Is_Imported (Prim)
or else Present (Interface_Alias (Prim)) or else Present (Interface_Alias (Prim))
or else Is_Predefined_Dispatching_Operation (Prim) or else Is_Predefined_Dispatching_Operation (Prim)
or else Is_Eliminated (Prim)
then then
null; null;
...@@ -7180,6 +7184,10 @@ package body Exp_Disp is ...@@ -7180,6 +7184,10 @@ package body Exp_Disp is
Write_Str (" is null;"); Write_Str (" is null;");
end if; end if;
if Is_Eliminated (Ultimate_Alias (Prim)) then
Write_Str (" (eliminated)");
end if;
Write_Eol; Write_Eol;
Next_Elmt (Elmt); Next_Elmt (Elmt);
......
...@@ -367,6 +367,7 @@ package body Sem_Ch6 is ...@@ -367,6 +367,7 @@ package body Sem_Ch6 is
end if; end if;
Generate_Reference_To_Formals (Designator); Generate_Reference_To_Formals (Designator);
Check_Eliminated (Designator);
end Analyze_Abstract_Subprogram_Declaration; end Analyze_Abstract_Subprogram_Declaration;
---------------------------------------- ----------------------------------------
......
...@@ -42,6 +42,7 @@ with Rident; use Rident; ...@@ -42,6 +42,7 @@ with Rident; use Rident;
with Sem; use Sem; with Sem; use Sem;
with Sem_Aux; use Sem_Aux; with Sem_Aux; use Sem_Aux;
with Sem_Ch6; use Sem_Ch6; with Sem_Ch6; use Sem_Ch6;
with Sem_Elim; use Sem_Elim;
with Sem_Eval; use Sem_Eval; with Sem_Eval; use Sem_Eval;
with Sem_Type; use Sem_Type; with Sem_Type; use Sem_Type;
with Sem_Util; use Sem_Util; with Sem_Util; use Sem_Util;
...@@ -483,6 +484,10 @@ package body Sem_Disp is ...@@ -483,6 +484,10 @@ package body Sem_Disp is
Set_Controlling_Argument (N, Control); Set_Controlling_Argument (N, Control);
Check_Restriction (No_Dispatching_Calls, N); Check_Restriction (No_Dispatching_Calls, N);
if Is_Eliminated (Ultimate_Alias (Subp_Entity)) then
Eliminate_Error_Msg (N, Ultimate_Alias (Subp_Entity));
end if;
-- If there is a statically tagged actual and a tag-indeterminate -- If there is a statically tagged actual and a tag-indeterminate
-- call to a function of the ancestor (such as that provided by a -- call to a function of the ancestor (such as that provided by a
-- default), then treat this as a dispatching call and propagate -- default), then treat this as a dispatching call and propagate
......
...@@ -269,7 +269,7 @@ package body Sem_Elim is ...@@ -269,7 +269,7 @@ package body Sem_Elim is
Elmt := Elim_Hash_Table.Get (Chars (E)); Elmt := Elim_Hash_Table.Get (Chars (E));
while Elmt /= null loop while Elmt /= null loop
declare Check_Homonyms : declare
procedure Set_Eliminated; procedure Set_Eliminated;
-- Set current subprogram entity as eliminated -- Set current subprogram entity as eliminated
...@@ -279,16 +279,26 @@ package body Sem_Elim is ...@@ -279,16 +279,26 @@ package body Sem_Elim is
procedure Set_Eliminated is procedure Set_Eliminated is
begin begin
-- Never try to eliminate dispatching operation, since we if Is_Dispatching_Operation (E) then
-- can't properly process the eliminated result. This could
-- be fixed, but is not worth it.
if not Is_Dispatching_Operation (E) then -- If an overriding dispatching primitive is eliminated then
Set_Is_Eliminated (E); -- its parent must have been eliminated
Elim_Entities.Append ((Prag => Elmt.Prag, Subp => E));
if Is_Overriding_Operation (E)
and then not Is_Eliminated (Overridden_Operation (E))
then
Error_Msg_Name_1 := Chars (E);
Error_Msg_N ("cannot eliminate subprogram %", E);
return;
end if;
end if; end if;
Set_Is_Eliminated (E);
Elim_Entities.Append ((Prag => Elmt.Prag, Subp => E));
end Set_Eliminated; end Set_Eliminated;
-- Start of processing for Check_Homonyms
begin begin
-- First we check that the name of the entity matches -- First we check that the name of the entity matches
...@@ -643,7 +653,7 @@ package body Sem_Elim is ...@@ -643,7 +653,7 @@ package body Sem_Elim is
Set_Eliminated; Set_Eliminated;
return; return;
end if; end if;
end; end Check_Homonyms;
<<Continue>> <<Continue>>
Elmt := Elmt.Homonym; Elmt := Elmt.Homonym;
......
...@@ -53,8 +53,8 @@ package Sem_Elim is ...@@ -53,8 +53,8 @@ package Sem_Elim is
-- flag on the given entity. -- flag on the given entity.
procedure Eliminate_Error_Msg (N : Node_Id; E : Entity_Id); procedure Eliminate_Error_Msg (N : Node_Id; E : Entity_Id);
-- Called by the back end on encountering a call to an eliminated -- Called by the front-end and back-end on encountering a call to an
-- subprogram. N is the node for the call, and E is the entity of -- eliminated subprogram. N is the node for the call, and E is the
-- the subprogram being eliminated. -- entity of the subprogram being eliminated.
end Sem_Elim; end Sem_Elim;
...@@ -9226,7 +9226,7 @@ package body Sem_Prag is ...@@ -9226,7 +9226,7 @@ package body Sem_Prag is
-- Cases where we must follow a declaration -- Cases where we must follow a declaration
else else
if Nkind (Decl) not in N_Declaration if Nkind (Decl) not in N_Declaration
and then Nkind (Decl) not in N_Later_Decl_Item and then Nkind (Decl) not in N_Later_Decl_Item
and then Nkind (Decl) not in N_Generic_Declaration and then Nkind (Decl) not in N_Generic_Declaration
and then Nkind (Decl) not in N_Renaming_Declaration and then Nkind (Decl) not in N_Renaming_Declaration
......
...@@ -1425,30 +1425,29 @@ package body Sem_Type is ...@@ -1425,30 +1425,29 @@ package body Sem_Type is
elsif Is_Numeric_Type (Etype (F1)) elsif Is_Numeric_Type (Etype (F1))
and then Has_Abstract_Interpretation (Act1) and then Has_Abstract_Interpretation (Act1)
then then
-- Current interpretation is not the right one because it
-- Current interpretation is not the right one because -- expects a numeric operand. Examine all the other ones.
-- it expects a numeric operand. Examine all the other
-- ones.
declare declare
I : Interp_Index; I : Interp_Index;
It : Interp; It : Interp;
begin begin
Get_First_Interp (N, I, It); Get_First_Interp (N, I, It);
while Present (It.Typ) loop while Present (It.Typ) loop
if if
not Is_Numeric_Type (Etype (First_Formal (It.Nam))) not Is_Numeric_Type (Etype (First_Formal (It.Nam)))
then then
if No (Act2) if No (Act2)
or else not Has_Abstract_Interpretation (Act2) or else not Has_Abstract_Interpretation (Act2)
or else not Is_Numeric_Type or else not
(Etype (Next_Formal (First_Formal (It.Nam)))) Is_Numeric_Type
(Etype (Next_Formal (First_Formal (It.Nam))))
then then
return It; return It;
end if; end if;
end if; end if;
Get_Next_Interp (I, It); Get_Next_Interp (I, It);
end loop; end loop;
......
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