Commit 3a845e07 by Robert Dewar Committed by Arnaud Charlet

exp_ch4.adb (Expand_N_Expression_With_Actions): Make sure declarations get…

exp_ch4.adb (Expand_N_Expression_With_Actions): Make sure declarations get properly inserted in Modify_Tree_For_C mode.

2014-02-19  Robert Dewar  <dewar@adacore.com>

	* exp_ch4.adb (Expand_N_Expression_With_Actions): Make sure
	declarations get properly inserted in Modify_Tree_For_C mode.
	* sinfo.ads: Minor comment addition.

From-SVN: r207883
parent 82d4f390
2014-02-19 Robert Dewar <dewar@adacore.com>
* exp_ch4.adb (Expand_N_Expression_With_Actions): Make sure
declarations get properly inserted in Modify_Tree_For_C mode.
* sinfo.ads: Minor comment addition.
2014-02-19 Robert Dewar <dewar@adacore.com>
* par-ch9.adb, exp_ch5.adb, sem_ch5.adb, exp_attr.adb, sem_util.adb,
sem_util.ads, sem_ch13.adb, sem_ch13.ads: Minor reformatting.
......
......@@ -5067,12 +5067,42 @@ package body Exp_Ch4 is
--------------------------------------
procedure Expand_N_Expression_With_Actions (N : Node_Id) is
procedure Insert_Declaration (Decl : Node_Id);
-- This is like Insert_Action, but inserts outside the expression in
-- which N appears. This is needed, because otherwise we can end up
-- inserting a declaration in the actions of a short circuit, and that
-- will not do, because that's likely where we (the expression with
-- actions) node came from the first place. We are only inserting a
-- declaration with no side effects, so it is harmless (and needed)
-- to insert at a higher point in the tree.
function Process_Action (Act : Node_Id) return Traverse_Result;
-- Inspect and process a single action of an expression_with_actions for
-- transient controlled objects. If such objects are found, the routine
-- generates code to clean them up when the context of the expression is
-- evaluated or elaborated.
------------------------
-- Insert_Declaration --
------------------------
procedure Insert_Declaration (Decl : Node_Id) is
P : Node_Id;
begin
-- Climb out of the current expression
P := Decl;
loop
exit when Nkind (Parent (P)) not in N_Subexpr;
P := Parent (P);
end loop;
-- Now do the insertion
Insert_Action (P, Decl);
end Insert_Declaration;
--------------------
-- Process_Action --
--------------------
......@@ -5135,7 +5165,7 @@ package body Exp_Ch4 is
Exp := Expression (Act);
Set_Constant_Present (Act, False);
Set_Expression (Act, Empty);
Insert_Action (N, Relocate_Node (Act));
Insert_Declaration (Relocate_Node (Act));
Loc := Sloc (Act);
......
......@@ -2925,6 +2925,10 @@ package Sinfo is
-- Discrete_Subtype_Definitions (List2)
-- Component_Definition (Node4)
-- Note: although the language allows the full syntax for discrete
-- subtype definitions (i.e. a discrete subtype indication or a range),
-- in the generated tree, we always rewrite these as N_Range nodes.
--------------------------------------
-- 3.6 Discrete Subtype Definition --
--------------------------------------
......
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