summaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2014-02-19 10:42:16 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2014-02-19 10:42:16 +0000
commit1a10e335567dbac8d8c4c73a5c88bc83b02bcd85 (patch)
treea6b4caf26c785d13a10d0102a637af0cb1dbbc34 /gcc/ada
parentbde034549df85eb6231edea5a9d0c4f26969ec98 (diff)
downloadgcc-1a10e335567dbac8d8c4c73a5c88bc83b02bcd85.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207883 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/exp_ch4.adb32
-rw-r--r--gcc/ada/sinfo.ads4
3 files changed, 41 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 478b5fffd8d..1892dbf10f6 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 43dc9916ed6..b9ff98c8886 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 4feed599c5d..ee3596545d7 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 --
--------------------------------------