diff options
author | Robert Dewar <dewar@adacore.com> | 2014-02-19 10:42:16 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-02-19 11:42:16 +0100 |
commit | 3a845e077b5cafd292efa58e859c10546e399603 (patch) | |
tree | a6b4caf26c785d13a10d0102a637af0cb1dbbc34 /gcc | |
parent | 82d4f39092f2326e7097edff2ddbfb3a4516c86e (diff) | |
download | gcc-3a845e077b5cafd292efa58e859c10546e399603.zip gcc-3a845e077b5cafd292efa58e859c10546e399603.tar.gz gcc-3a845e077b5cafd292efa58e859c10546e399603.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/exp_ch4.adb | 32 | ||||
-rw-r--r-- | gcc/ada/sinfo.ads | 4 |
3 files changed, 41 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 478b5ff..1892dbf 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,11 @@ 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. diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 43dc991..b9ff98c 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -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); diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index 4feed59..ee35965 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -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 -- -------------------------------------- |