Commit 62548837 by Robert Dewar Committed by Arnaud Charlet

exp_intr.adb (Expand_Exception_Call): Calls to subprograms in…

exp_intr.adb (Expand_Exception_Call): Calls to subprograms in GNAT.Current_Exception are not allowed if...

2007-04-06  Robert Dewar  <dewar@adacore.com>
	    Ed Schonberg  <schonberg@adacore.com>

	* exp_intr.adb (Expand_Exception_Call): Calls to subprograms in
	GNAT.Current_Exception are not allowed if pragma Restrictions
	(No_Exception_Propagation) is set and in any case make the associated
	handler unsuitable as a target for a local raise statement.
	(Expand_Dispatching_Constructor_Call): Replace generation of call to the
	run-time subprogram CW_Membership by call to Build_CW_Membership.
	(Expand_Dispatching_Constructor_Call): If the dispatching tag is given
	by a function call, a temporary must be created before expanding the
	Constructor_Call itself, to prevent out-of-order elaboration in the
	back-end when stack checking is enabled..

From-SVN: r123566
parent 8aa23fe3
...@@ -29,6 +29,7 @@ with Checks; use Checks; ...@@ -29,6 +29,7 @@ with Checks; use Checks;
with Einfo; use Einfo; with Einfo; use Einfo;
with Elists; use Elists; with Elists; use Elists;
with Errout; use Errout; with Errout; use Errout;
with Exp_Atag; use Exp_Atag;
with Exp_Ch4; use Exp_Ch4; with Exp_Ch4; use Exp_Ch4;
with Exp_Ch7; use Exp_Ch7; with Exp_Ch7; use Exp_Ch7;
with Exp_Ch11; use Exp_Ch11; with Exp_Ch11; use Exp_Ch11;
...@@ -41,6 +42,7 @@ with Namet; use Namet; ...@@ -41,6 +42,7 @@ with Namet; use Namet;
with Nmake; use Nmake; with Nmake; use Nmake;
with Nlists; use Nlists; with Nlists; use Nlists;
with Restrict; use Restrict; with Restrict; use Restrict;
with Rident; use Rident;
with Rtsfind; use Rtsfind; with Rtsfind; use Rtsfind;
with Sem; use Sem; with Sem; use Sem;
with Sem_Eval; use Sem_Eval; with Sem_Eval; use Sem_Eval;
...@@ -161,7 +163,11 @@ package body Exp_Intr is ...@@ -161,7 +163,11 @@ package body Exp_Intr is
Parameter_Associations => New_List (Relocate_Node (Param_Arg))); Parameter_Associations => New_List (Relocate_Node (Param_Arg)));
-- Establish its controlling tag from the tag passed to the instance -- Establish its controlling tag from the tag passed to the instance
-- The tag may be given by a function call, in which case a temporary
-- should be generated now, to prevent out-of-order insertions during
-- the expansion of that call when stack-checking is enabled.
Remove_Side_Effects (Tag_Arg);
Set_Controlling_Argument (Cnstr_Call, Relocate_Node (Tag_Arg)); Set_Controlling_Argument (Cnstr_Call, Relocate_Node (Tag_Arg));
-- Rewrite and analyze the call to the instance as a class-wide -- Rewrite and analyze the call to the instance as a class-wide
...@@ -171,7 +177,7 @@ package body Exp_Intr is ...@@ -171,7 +177,7 @@ package body Exp_Intr is
Analyze_And_Resolve (N, Etype (Act_Constr)); Analyze_And_Resolve (N, Etype (Act_Constr));
-- Do not generate a run-time check on the built object if tag -- Do not generate a run-time check on the built object if tag
-- checks is suppressed for the result type. -- checks are suppressed for the result type.
if Tag_Checks_Suppressed (Etype (Result_Typ)) then if Tag_Checks_Suppressed (Etype (Result_Typ)) then
null; null;
...@@ -191,13 +197,12 @@ package body Exp_Intr is ...@@ -191,13 +197,12 @@ package body Exp_Intr is
Make_Implicit_If_Statement (N, Make_Implicit_If_Statement (N,
Condition => Condition =>
Make_Op_Not (Loc, Make_Op_Not (Loc,
Make_DT_Access_Action (Result_Typ, Build_CW_Membership (Loc,
Action => CW_Membership, Obj_Tag_Node => Duplicate_Subexpr (Tag_Arg),
Args => New_List ( Typ_Tag_Node =>
Duplicate_Subexpr (Tag_Arg),
New_Reference_To ( New_Reference_To (
Node (First_Elmt (Access_Disp_Table ( Node (First_Elmt (Access_Disp_Table (
Root_Type (Result_Typ)))), Loc)))), Root_Type (Result_Typ)))), Loc))),
Then_Statements => Then_Statements =>
New_List (Make_Raise_Statement (Loc, New_List (Make_Raise_Statement (Loc,
New_Occurrence_Of (RTE (RE_Tag_Error), Loc))))); New_Occurrence_Of (RTE (RE_Tag_Error), Loc)))));
...@@ -231,9 +236,9 @@ package body Exp_Intr is ...@@ -231,9 +236,9 @@ package body Exp_Intr is
-- Expand_Exception_Call -- -- Expand_Exception_Call --
--------------------------- ---------------------------
-- If the function call is not within an exception handler, then the -- If the function call is not within an exception handler, then the call
-- call is replaced by a null string. Otherwise the appropriate routine -- is replaced by a null string. Otherwise the appropriate routine in
-- in Ada.Exceptions is called passing the choice parameter specification -- Ada.Exceptions is called passing the choice parameter specification
-- from the enclosing handler. If the enclosing handler lacks a choice -- from the enclosing handler. If the enclosing handler lacks a choice
-- parameter, then one is supplied. -- parameter, then one is supplied.
...@@ -258,12 +263,18 @@ package body Exp_Intr is ...@@ -258,12 +263,18 @@ package body Exp_Intr is
-- Case of in exception handler -- Case of in exception handler
elsif Nkind (P) = N_Exception_Handler then elsif Nkind (P) = N_Exception_Handler then
if No (Choice_Parameter (P)) then
-- If no choice parameter present, then put one there. Note -- Handler cannot be used for a local raise, and furthermore, this
-- that we do not need to put it on the entity chain, since -- is a violation of the No_Exception_Propagation restriction.
-- no one will be referencing it by normal visibility methods.
Set_Local_Raise_Not_OK (P);
Check_Restriction (No_Exception_Propagation, N);
-- If no choice parameter present, then put one there. Note that
-- we do not need to put it on the entity chain, since no one will
-- be referencing it by normal visibility methods.
if No (Choice_Parameter (P)) then
E := Make_Defining_Identifier (Loc, New_Internal_Name ('E')); E := Make_Defining_Identifier (Loc, New_Internal_Name ('E'));
Set_Choice_Parameter (P, E); Set_Choice_Parameter (P, E);
Set_Ekind (E, E_Variable); Set_Ekind (E, E_Variable);
......
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