Patchwork [Ada] Internal fix to Insert_Actions routine in compiler

login
register
mail settings
Submitter Arnaud Charlet
Date Jan. 4, 2013, 9:29 a.m.
Message ID <20130104092900.GA32701@adacore.com>
Download mbox | patch
Permalink /patch/209420/
State New
Headers show

Comments

Arnaud Charlet - Jan. 4, 2013, 9:29 a.m.
This patch corrects an obvious latent bug in Insert_Actions, namely
that in the case of an expression with actions node, the actions
were inserted in reverse order from the calls. As far as we know,
this bug is only latent (found from code reading), so no test is
required for this fix.

Tested on x86_64-pc-linux-gnu, committed on trunk

2013-01-04  Robert Dewar  <dewar@adacore.com>

	* exp_util.ads, exp_util.adb (Insert_Actions): In expression with
	actions case, new actions are appended to the sequence rather than
	prepended.

Patch

Index: exp_util.adb
===================================================================
--- exp_util.adb	(revision 194894)
+++ exp_util.adb	(working copy)
@@ -3138,7 +3138,7 @@ 
         and then not Is_Frozen (Current_Scope)
       then
          if No (Scope_Stack.Table
-           (Scope_Stack.Last).Pending_Freeze_Actions)
+                  (Scope_Stack.Last).Pending_Freeze_Actions)
          then
             Scope_Stack.Table (Scope_Stack.Last).Pending_Freeze_Actions :=
               Ins_Actions;
@@ -3306,13 +3306,13 @@ 
                return;
 
             --  Case of appearing within an Expressions_With_Actions node. We
-            --  prepend the actions to the list of actions already there, if
+            --  append the actions to the list of actions already there, if
             --  the node has not been analyzed yet. Otherwise find insertion
             --  location further up the tree.
 
             when N_Expression_With_Actions =>
                if not Analyzed (P) then
-                  Prepend_List (Ins_Actions, Actions (P));
+                  Append_List (Ins_Actions, Actions (P));
                   return;
                end if;
 
Index: exp_util.ads
===================================================================
--- exp_util.ads	(revision 194887)
+++ exp_util.ads	(working copy)
@@ -75,6 +75,9 @@ 
    --    expansion of the N_If_Expression node rewrites the node so that the
    --    actions can be positioned normally.
 
+   --    For actions coming from expansion of the expression in an expression
+   --    with actions node, the action is appended to the list of actions.
+
    --  Basically what we do is to climb up to the tree looking for the
    --  proper insertion point, as described by one of the above cases,
    --  and then insert the appropriate action or actions.