[multiple changes]

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.

From-SVN: r212662
This commit is contained in:
Arnaud Charlet 2014-07-16 16:47:48 +02:00
parent 76241f8f24
commit 2ffcbaa596
14 changed files with 171 additions and 78 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -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;
---------------------------

View File

@ -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 --
----------------------------

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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;