aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ada/ChangeLog34
-rw-r--r--gcc/ada/exp_aggr.adb12
-rw-r--r--gcc/ada/exp_ch13.adb17
-rw-r--r--gcc/ada/freeze.adb54
-rw-r--r--gcc/ada/freeze.ads4
-rw-r--r--gcc/ada/gnatls.adb4
-rw-r--r--gcc/ada/sem.adb5
-rw-r--r--gcc/ada/sem_ch3.adb19
-rw-r--r--gcc/ada/sem_ch4.adb13
-rw-r--r--gcc/ada/sem_ch5.adb9
-rw-r--r--gcc/ada/sem_ch5.ads3
-rw-r--r--gcc/ada/sinfo.adb2
-rw-r--r--gcc/ada/sinfo.ads64
-rw-r--r--gcc/ada/sprint.adb9
14 files changed, 171 insertions, 78 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 57c59f4..c073f87 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,37 @@
+2014-07-16 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch3.adb (Find_Type_Name): Diagnose properly
+ a private extension completion that is an interface definition
+ with an interface list.
+
+2014-07-16 Arnaud Charlet <charlet@adacore.com>
+
+ * gnatls.adb (Gnatls): Code clean ups.
+
+2014-07-16 Thomas Quinot <quinot@adacore.com>
+
+ * sinfo.ads, sinfo.adb (N_Compound_Statement): New node kind.
+ * sem.adb (Analyze): Handle N_Compound_Statement.
+ * sprint.adb (Sprint_Node_Actual): Ditto.
+ * sem_ch5.ads, sem_ch5.adb (Analyze_Compound_Statement): New
+ procedure to handle N_Compound_Statement.
+ * exp_aggr.adb (Collect_Initialization_Statements):
+ Use a proper compound statement node, instead of a bogus
+ expression-with-actions with a NULL statement as its expression,
+ to wrap collected initialization statements.
+ * freeze.ads, freeze.adb
+ (Explode_Initialization_Compound_Statement): New public procedure,
+ lifted from Freeze_Entity.
+ (Freeze_Entity): When freezing
+ an object with captured initialization statements and without
+ delayed freezing, explode compount statement.
+ * sem_ch4.adb (Analyze_Expression_With_Actions): Remove special
+ case that used to handle bogus EWAs with NULL statement as
+ the expression.
+ * exp_ch13.adb (Expand_N_Freeze_Entity): For an object with
+ delayed freezing and captured initialization statements, explode
+ compound statement.
+
2014-07-16 Gary Dismukes <dismukes@adacore.com>
* g-rewdat.adb, g-rewdat.ads: Minor reformatting.
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index 676a610..377fc7b 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -3033,7 +3033,7 @@ package body Exp_Aggr is
Loc : constant Source_Ptr := Sloc (N);
Init_Actions : constant List_Id := New_List;
Init_Node : Node_Id;
- EA : Node_Id;
+ Comp_Stmt : Node_Id;
begin
-- Nothing to do if Obj is already frozen, as in this case we known we
@@ -3049,12 +3049,10 @@ package body Exp_Aggr is
end loop;
if not Is_Empty_List (Init_Actions) then
- EA :=
- Make_Expression_With_Actions (Loc,
- Actions => Init_Actions,
- Expression => Make_Null_Statement (Loc));
- Insert_Action_After (Init_Node, EA);
- Set_Initialization_Statements (Obj, EA);
+ Comp_Stmt := Make_Compound_Statement (Loc,
+ Actions => Init_Actions);
+ Insert_Action_After (Init_Node, Comp_Stmt);
+ Set_Initialization_Statements (Obj, Comp_Stmt);
end if;
end Collect_Initialization_Statements;
diff --git a/gcc/ada/exp_ch13.adb b/gcc/ada/exp_ch13.adb
index c871327..9500a56 100644
--- a/gcc/ada/exp_ch13.adb
+++ b/gcc/ada/exp_ch13.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2013, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -31,6 +31,7 @@ with Exp_Ch6; use Exp_Ch6;
with Exp_Imgv; use Exp_Imgv;
with Exp_Tss; use Exp_Tss;
with Exp_Util; use Exp_Util;
+with Freeze; use Freeze;
with Namet; use Namet;
with Nlists; use Nlists;
with Nmake; use Nmake;
@@ -410,10 +411,18 @@ package body Exp_Ch13 is
end;
end if;
- -- Processing for objects with address clauses
+ -- Processing for objects
+
+ if Is_Object (E) then
+ if Present (Address_Clause (E)) then
+ Apply_Address_Clause_Check (E, N);
+ end if;
+
+ -- If initialization statements have been captured in a compound
+ -- statement, insert them back into the tree now.
+
+ Explode_Initialization_Compound_Statement (E);
- if Is_Object (E) and then Present (Address_Clause (E)) then
- Apply_Address_Clause_Check (E, N);
return;
-- Only other items requiring any front end action are types and
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index fdb87f5..95ea1eb 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -1366,6 +1366,29 @@ package body Freeze is
end if;
end Is_Atomic_Aggregate;
+ -----------------------------------------------
+ -- Explode_Initialization_Compound_Statement --
+ -----------------------------------------------
+
+ procedure Explode_Initialization_Compound_Statement (E : Entity_Id) is
+ Init_Stmts : constant Node_Id := Initialization_Statements (E);
+ begin
+ if Present (Init_Stmts)
+ and then Nkind (Init_Stmts) = N_Compound_Statement
+ then
+ Insert_List_Before (Init_Stmts, Actions (Init_Stmts));
+
+ -- Note that we rewrite Init_Stmts into a NULL statement, rather than
+ -- just removing it, because Freeze_All may rely on this particular
+ -- Node_Id still being present in the enclosing list to know where to
+ -- stop freezing.
+
+ Rewrite (Init_Stmts, Make_Null_Statement (Sloc (Init_Stmts)));
+
+ Set_Initialization_Statements (E, Empty);
+ end if;
+ end Explode_Initialization_Compound_Statement;
+
----------------
-- Freeze_All --
----------------
@@ -4314,36 +4337,15 @@ package body Freeze is
Layout_Object (E);
end if;
- -- If initialization statements were captured in an expression
- -- with actions with null expression, and the object does not
- -- have delayed freezing, move them back now directly within the
- -- enclosing statement sequence.
+ -- For an object that does not have delayed freezing, and whose
+ -- initialization actions have been captured in a compound
+ -- statement, move them back now directly within the enclosing
+ -- statement sequence.
if Ekind_In (E, E_Constant, E_Variable)
and then not Has_Delayed_Freeze (E)
then
- declare
- Init_Stmts : constant Node_Id :=
- Initialization_Statements (E);
- begin
- if Present (Init_Stmts)
- and then Nkind (Init_Stmts) = N_Expression_With_Actions
- and then Nkind (Expression (Init_Stmts)) = N_Null_Statement
- then
- Insert_List_Before (Init_Stmts, Actions (Init_Stmts));
-
- -- Note that we rewrite Init_Stmts into a NULL statement,
- -- rather than just removing it, because Freeze_All may
- -- depend on this particular Node_Id still being present
- -- in the enclosing list to signal where to stop
- -- freezing.
-
- Rewrite (Init_Stmts,
- Make_Null_Statement (Sloc (Init_Stmts)));
-
- Set_Initialization_Statements (E, Empty);
- end if;
- end;
+ Explode_Initialization_Compound_Statement (E);
end if;
end if;
diff --git a/gcc/ada/freeze.ads b/gcc/ada/freeze.ads
index 188ea5d..e88acbf 100644
--- a/gcc/ada/freeze.ads
+++ b/gcc/ada/freeze.ads
@@ -186,6 +186,10 @@ package Freeze is
-- of an object declaration or an assignment. Function is a noop and
-- returns false in other contexts.
+ procedure Explode_Initialization_Compound_Statement (E : Entity_Id);
+ -- If Initialization_Statements (E) is an N_Compound_Statement, insert its
+ -- actions in the enclosing list and reset the attribute.
+
function Freeze_Entity (E : Entity_Id; N : Node_Id) return List_Id;
-- Freeze an entity, and return Freeze nodes, to be inserted at the point
-- of call. N is a node whose source location corresponds to the freeze
diff --git a/gcc/ada/gnatls.adb b/gcc/ada/gnatls.adb
index c474b92..aa36e33 100644
--- a/gcc/ada/gnatls.adb
+++ b/gcc/ada/gnatls.adb
@@ -1579,9 +1579,6 @@ begin
Check_Version_And_Help ("GNATLS", "1992");
- Osint.Add_Default_Search_Dirs;
- Get_Target_Parameters;
-
-- Loop to scan out arguments
Next_Arg := 1;
@@ -1628,6 +1625,7 @@ begin
-- Finally, add the default directories and obtain target parameters
Osint.Add_Default_Search_Dirs;
+ Get_Target_Parameters;
if Verbose_Mode then
Write_Eol;
diff --git a/gcc/ada/sem.adb b/gcc/ada/sem.adb
index 94ee841..b1368f4 100644
--- a/gcc/ada/sem.adb
+++ b/gcc/ada/sem.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2013, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -166,6 +166,9 @@ package body Sem is
when N_Component_Declaration =>
Analyze_Component_Declaration (N);
+ when N_Compound_Statement =>
+ Analyze_Compound_Statement (N);
+
when N_Conditional_Entry_Call =>
Analyze_Conditional_Entry_Call (N);
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 3b68b7b..f1cb239 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -15567,6 +15567,16 @@ package body Sem_Ch3 is
Prev_Par := Parent (Prev);
end if;
+ if Nkind (N) = N_Full_Type_Declaration
+ and then Nkind_In
+ (Type_Definition (N), N_Record_Definition,
+ N_Derived_Type_Definition)
+ and then Interface_Present (Type_Definition (N))
+ then
+ Error_Msg_N
+ ("completion of private type cannot be an interface", N);
+ end if;
+
if Nkind (Parent (Prev)) /= N_Private_Extension_Declaration then
if Etype (Prev) /= Prev then
@@ -15596,15 +15606,6 @@ package body Sem_Ch3 is
("completion of tagged private type must be tagged",
N);
end if;
-
- elsif Nkind (N) = N_Full_Type_Declaration
- and then Nkind_In
- (Type_Definition (N), N_Record_Definition,
- N_Derived_Type_Definition)
- and then Interface_Present (Type_Definition (N))
- then
- Error_Msg_N
- ("completion of private type cannot be an interface", N);
end if;
-- Ada 2005 (AI-251): Private extension declaration of a task
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 52ff590..2e692c6 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -2040,17 +2040,8 @@ package body Sem_Ch4 is
Next (A);
end loop;
- -- We currently hijack Expression_With_Actions with a VOID type and
- -- a NULL statement in the Expression. This will ultimately be replaced
- -- by a proper separate N_Compound_Statement node, at which point the
- -- test below can go away???
-
- if Nkind (Expression (N)) = N_Null_Statement then
- Set_Etype (N, Standard_Void_Type);
- else
- Analyze_Expression (Expression (N));
- Set_Etype (N, Etype (Expression (N)));
- end if;
+ Analyze_Expression (Expression (N));
+ Set_Etype (N, Etype (Expression (N)));
end Analyze_Expression_With_Actions;
---------------------------
diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
index db7e985..d90a7e5 100644
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -1016,6 +1016,15 @@ package body Sem_Ch5 is
end;
end Analyze_Block_Statement;
+ --------------------------------
+ -- Analyze_Compound_Statement --
+ --------------------------------
+
+ procedure Analyze_Compound_Statement (N : Node_Id) is
+ begin
+ Analyze_List (Actions (N));
+ end Analyze_Compound_Statement;
+
----------------------------
-- Analyze_Case_Statement --
----------------------------
diff --git a/gcc/ada/sem_ch5.ads b/gcc/ada/sem_ch5.ads
index 86a92b7..9c29083 100644
--- a/gcc/ada/sem_ch5.ads
+++ b/gcc/ada/sem_ch5.ads
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
--- Copyright (C) 1992-2012, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -30,6 +30,7 @@ package Sem_Ch5 is
procedure Analyze_Assignment (N : Node_Id);
procedure Analyze_Block_Statement (N : Node_Id);
procedure Analyze_Case_Statement (N : Node_Id);
+ procedure Analyze_Compound_Statement (N : Node_Id);
procedure Analyze_Exit_Statement (N : Node_Id);
procedure Analyze_Goto_Statement (N : Node_Id);
procedure Analyze_If_Statement (N : Node_Id);
diff --git a/gcc/ada/sinfo.adb b/gcc/ada/sinfo.adb
index ade3b4e..5576cec 100644
--- a/gcc/ada/sinfo.adb
+++ b/gcc/ada/sinfo.adb
@@ -148,6 +148,7 @@ package body Sinfo is
or else NT (N).Nkind = N_And_Then
or else NT (N).Nkind = N_Case_Expression_Alternative
or else NT (N).Nkind = N_Compilation_Unit_Aux
+ or else NT (N).Nkind = N_Compound_Statement
or else NT (N).Nkind = N_Expression_With_Actions
or else NT (N).Nkind = N_Freeze_Entity
or else NT (N).Nkind = N_Or_Else);
@@ -3314,6 +3315,7 @@ package body Sinfo is
or else NT (N).Nkind = N_And_Then
or else NT (N).Nkind = N_Case_Expression_Alternative
or else NT (N).Nkind = N_Compilation_Unit_Aux
+ or else NT (N).Nkind = N_Compound_Statement
or else NT (N).Nkind = N_Expression_With_Actions
or else NT (N).Nkind = N_Freeze_Entity
or else NT (N).Nkind = N_Or_Else);
diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads
index 521ab0b..e879edd 100644
--- a/gcc/ada/sinfo.ads
+++ b/gcc/ada/sinfo.ads
@@ -86,6 +86,7 @@ package Sinfo is
-- Add it to the documentation in the appropriate place
-- Add its fields to this documentation section
-- Define it in the appropriate classification in Node_Kind
+ -- Add an entry in Is_Syntactic_Field
-- In the body (sinfo), add entries to the access functions for all
-- its fields (except standard expression fields) to include the new
-- node in the checks.
@@ -98,6 +99,8 @@ package Sinfo is
-- For a subexpression, add an appropriate section to the case
-- statement in sem_res.adb
+ -- All back ends must be made aware of the new node kind.
+
-- Finally, four utility programs must be run:
-- (Optional.) Run CSinfo to check that you have made the changes
@@ -7310,6 +7313,39 @@ package Sinfo is
-- reconstructed tree printed by Sprint, and the node descriptions here
-- show this syntax.
+ ------------------------
+ -- Compound Statement --
+ ------------------------
+
+ -- This node is created by the analyzer/expander to handle some
+ -- expansion cases where a sequence of actions needs to be captured
+ -- within a single node (which acts as a container and allows the
+ -- entire list of actions to be moved around as a whole) appearing
+ -- in a sequence of statements.
+
+ -- This is the statement counterpart to expression node N_Expression_
+ -- With_Actions.
+
+ -- The required semantics is that the set of actions is executed in
+ -- the order in which it appears, as though they appeared by themselves
+ -- in the enclosing list of declarations of statements. Unlike what
+ -- happens when using an N_Block_Statement, no new scope is introduced.
+
+ -- Note: for the time being, this is used only as a transient
+ -- representation during expansion, and all compound statement nodes
+ -- must be exploded back to their constituent statements before handing
+ -- the tree to the back end.
+
+ -- Sprint syntax: do
+ -- action;
+ -- action;
+ -- ...
+ -- action;
+ -- end;
+
+ -- N_Compound_Statement
+ -- Actions (List1)
+
--------------
-- Contract --
--------------
@@ -7375,7 +7411,7 @@ package Sinfo is
-- The ordering is in LIFO fashion.
-------------------
- -- Expanded_Name --
+ -- Expanded Name --
-------------------
-- The N_Expanded_Name node is used to represent a selected component
@@ -7404,7 +7440,7 @@ package Sinfo is
-- plus fields for expression
-----------------------------
- -- Expression with Actions --
+ -- Expression With Actions --
-----------------------------
-- This node is created by the analyzer/expander to handle some
@@ -7449,16 +7485,6 @@ package Sinfo is
-- the expression of the node is fully analyzed and expanded, at which
-- point it is safe to remove it, since no more actions can be inserted.
- -- Note: Expression may be a Null_Statement, in which case the
- -- N_Expression_With_Actions has type Standard_Void_Type. However some
- -- backends do not support such expression-with-actions occurring
- -- outside of a proper (non-void) expression, so this should just be
- -- used as an intermediate representation within the front end. Also
- -- note that this is really an irregularity (expressions and statements
- -- are not interchangeable, and in particular an N_Null_Statement is
- -- not a proper expression), and in the long term all cases of this
- -- idiom should instead use a new node kind N_Compound_Statement.
-
-- Note: In Modify_Tree_For_C, we never generate any declarations in
-- the action list, which can contain only non-declarative statements.
@@ -7526,7 +7552,7 @@ package Sinfo is
-- for this node points to the FREEZE keyword in the Sprint file output.
---------------------------
- -- Freeze_Generic_Entity --
+ -- Freeze Generic Entity --
---------------------------
-- The freeze point of an entity indicates the point at which the
@@ -7585,7 +7611,7 @@ package Sinfo is
-- for this node points to the label name in the generated declaration.
---------------------
- -- Itype_Reference --
+ -- Itype Reference --
---------------------
-- This node is used to create a reference to an Itype. The only purpose
@@ -7609,7 +7635,7 @@ package Sinfo is
-- for this node points to the REFERENCE keyword in the file output.
---------------------
- -- Raise_xxx_Error --
+ -- Raise xxx Error --
---------------------
-- One of these nodes is created during semantic analysis to replace
@@ -8197,6 +8223,7 @@ package Sinfo is
N_Block_Statement,
N_Case_Statement,
N_Code_Statement,
+ N_Compound_Statement,
N_Conditional_Entry_Call,
-- N_Statement_Other_Than_Procedure_Call, N_Delay_Statement
@@ -12078,6 +12105,13 @@ package Sinfo is
4 => False, -- unused
5 => False), -- Etype (Node5-Sem)
+ N_Compound_Statement =>
+ (1 => True, -- Actions (List1)
+ 2 => False, -- unused
+ 3 => False, -- unused
+ 4 => False, -- unused
+ 5 => False), -- unused
+
N_Contract =>
(1 => False, -- Pre_Post_Conditions (Node1)
2 => False, -- Contract_Test_Cases (Node2)
diff --git a/gcc/ada/sprint.adb b/gcc/ada/sprint.adb
index 49adb11..ec7f4ca 100644
--- a/gcc/ada/sprint.adb
+++ b/gcc/ada/sprint.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2013, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -1326,6 +1326,13 @@ package body Sprint is
Sprint_Node (Variant_Part (Node));
end if;
+ when N_Compound_Statement =>
+ Write_Indent_Str ("do");
+ Indent_Begin;
+ Sprint_Node_List (Actions (Node));
+ Indent_End;
+ Write_Indent_Str ("end;");
+
when N_Conditional_Entry_Call =>
Write_Indent_Str_Sloc ("select");
Indent_Begin;