[multiple changes]

2015-01-06  Pierre-Marie Derodat  <derodat@adacore.com>

	* scos.ads: Update documentation about the SCO table build
	process and about table records format.
	* par_sco.ads (SCO_Record): Rename to SCO_Record_Raw.
	(SCO_Record_Filtered): New procedure.
	(Set_SCO_Logical_Operator): New procedure.
	(dsco): Update documentation.
	* par_sco.adb: Update library-level comments.
	(SCO_Generation_State_Type): New type.
	(SCO_Generation_State): New variable.
	(SCO_Raw_Table): New package instanciation.
	(Condition_Pragma_Hash_Table): Rename to SCO_Raw_Hash_Table.
	("<"): New.
	(Tristate): New type.
	(Is_Logical_Operator): Return Tristate and update documentation.
	(Has_Decision): Update call to Is_Logical_Operator and complete
	documentation.
	(Set_Table_Entry): Rename to Set_Raw_Table_Entry, update
	comment, add an assertion for state checking and change
	references to SCO_Table into SCO_Raw_Table.
	(dsco): Refactor to dump the raw and the filtered tables.
	(Process_Decisions.Output_Decision_Operand): Handle putative
	short-circuit operators.
	(Process_Decisions.Output_Element): Update references
	to Set_Table_Entry and to Condition_Pragma_Hash_Table.
	(Process_Decisions.Process_Decision_Operand): Update call
	to Is_Logical_Operator.
	(Process_Decisions.Process_Node): Handle putative short-circuit
	operators and change references to
	SCO_Table into SCO_Raw_Table.
	(SCO_Output): Add an assertion
	for state checking and remove code that used to stamp out SCO entries.
	(SCO_Pragma_Disabled): Change reference to SCO_Table
	into SCO_Raw_Table.
	(SCO_Record): Rename to SCO_Record_Raw,
	add an assertion for state checking and change references
	to SCO_Table into SCO_Raw_Table.
	(Set_SCO_Condition): Add an assertion for state checking, update
	references to Condition_Pragma_Hash_Table and change references to
	SCO_Table into SCO_Raw_Table.
	(Set_SCO_Pragma_Enabled): Add an assertion for state checking and
	change references to SCO_Table into SCO_Raw_Table.
	(Set_SCO_Logical_Operator): New procedure.
	(Traverse_Declarations_Or_Statements.Set_Statement_Entry): Update
	references to Set_Table_Entry and to Condition_Pragma_Hash_Table.
	(SCO_Record_Fildered): New procedure.
	* gnat1drv.adb (Gnat1drv): Invoke the SCO filtering pass.
	* lib-writ.adb (Write_ALI): Invoke the SCO filtering pass and
	output SCOs.
	* par-load.adb (Load): Update reference to SCO_Record.
	* par.adb (Par): Update reference to SCO_Record.
	* put_scos.adb (Put_SCOs): Add an assertion to check that no
	putative SCO condition reaches this end.
	* sem_ch10.adb (Analyze_Proper_Body): Update reference to SCO_Record.
	* sem_res.adb (Resolve_Logical_Op): Validate putative SCOs
	when corresponding to an "and"/"or" operator affected by the
	Short_Circuit_And_Or pragma.

2015-01-06  Robert Dewar  <dewar@adacore.com>

	* sem_ch8.adb (Analyze_Use_Package): Give more specific error
	msg for attempted USE of generic subprogram or subprogram.

From-SVN: r219234
This commit is contained in:
Arnaud Charlet 2015-01-06 10:30:31 +01:00
parent 72eaa36512
commit 0566484a15
13 changed files with 862 additions and 148 deletions

View File

@ -1,3 +1,67 @@
2015-01-06 Pierre-Marie Derodat <derodat@adacore.com>
* scos.ads: Update documentation about the SCO table build
process and about table records format.
* par_sco.ads (SCO_Record): Rename to SCO_Record_Raw.
(SCO_Record_Filtered): New procedure.
(Set_SCO_Logical_Operator): New procedure.
(dsco): Update documentation.
* par_sco.adb: Update library-level comments.
(SCO_Generation_State_Type): New type.
(SCO_Generation_State): New variable.
(SCO_Raw_Table): New package instanciation.
(Condition_Pragma_Hash_Table): Rename to SCO_Raw_Hash_Table.
("<"): New.
(Tristate): New type.
(Is_Logical_Operator): Return Tristate and update documentation.
(Has_Decision): Update call to Is_Logical_Operator and complete
documentation.
(Set_Table_Entry): Rename to Set_Raw_Table_Entry, update
comment, add an assertion for state checking and change
references to SCO_Table into SCO_Raw_Table.
(dsco): Refactor to dump the raw and the filtered tables.
(Process_Decisions.Output_Decision_Operand): Handle putative
short-circuit operators.
(Process_Decisions.Output_Element): Update references
to Set_Table_Entry and to Condition_Pragma_Hash_Table.
(Process_Decisions.Process_Decision_Operand): Update call
to Is_Logical_Operator.
(Process_Decisions.Process_Node): Handle putative short-circuit
operators and change references to
SCO_Table into SCO_Raw_Table.
(SCO_Output): Add an assertion
for state checking and remove code that used to stamp out SCO entries.
(SCO_Pragma_Disabled): Change reference to SCO_Table
into SCO_Raw_Table.
(SCO_Record): Rename to SCO_Record_Raw,
add an assertion for state checking and change references
to SCO_Table into SCO_Raw_Table.
(Set_SCO_Condition): Add an assertion for state checking, update
references to Condition_Pragma_Hash_Table and change references to
SCO_Table into SCO_Raw_Table.
(Set_SCO_Pragma_Enabled): Add an assertion for state checking and
change references to SCO_Table into SCO_Raw_Table.
(Set_SCO_Logical_Operator): New procedure.
(Traverse_Declarations_Or_Statements.Set_Statement_Entry): Update
references to Set_Table_Entry and to Condition_Pragma_Hash_Table.
(SCO_Record_Fildered): New procedure.
* gnat1drv.adb (Gnat1drv): Invoke the SCO filtering pass.
* lib-writ.adb (Write_ALI): Invoke the SCO filtering pass and
output SCOs.
* par-load.adb (Load): Update reference to SCO_Record.
* par.adb (Par): Update reference to SCO_Record.
* put_scos.adb (Put_SCOs): Add an assertion to check that no
putative SCO condition reaches this end.
* sem_ch10.adb (Analyze_Proper_Body): Update reference to SCO_Record.
* sem_res.adb (Resolve_Logical_Op): Validate putative SCOs
when corresponding to an "and"/"or" operator affected by the
Short_Circuit_And_Or pragma.
2015-01-06 Robert Dewar <dewar@adacore.com>
* sem_ch8.adb (Analyze_Use_Package): Give more specific error
msg for attempted USE of generic subprogram or subprogram.
2015-01-06 Robert Dewar <dewar@adacore.com>
* s-valllu.adb, a-tiinau.adb, a-timoau.adb, a-ztinau.adb, a-ztmoau.adb,

View File

@ -1279,6 +1279,13 @@ begin
Write_ALI (Object => True);
end if;
-- Some back ends (for instance Gigi) are known to rely on SCOs for code
-- generation. Make sure they are available.
if Generate_SCO then
Par_SCO.SCO_Record_Filtered;
end if;
-- Back end needs to explicitly unlock tables it needs to touch
Atree.Lock;

View File

@ -1494,6 +1494,7 @@ package body Lib.Writ is
-- Output SCO information if present
if Generate_SCO then
SCO_Record_Filtered;
SCO_Output;
end if;

View File

@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- 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- --
@ -285,7 +285,7 @@ begin
Main_Unit_Entity := Cunit_Entity (Unum);
if Generate_SCO then
SCO_Record (Unum);
SCO_Record_Raw (Unum);
end if;
end if;

View File

@ -1658,7 +1658,7 @@ begin
-- Here we make the SCO table entries for the main unit
if Generate_SCO then
SCO_Record (Main_Unit);
SCO_Record_Raw (Main_Unit);
end if;
-- Remaining steps are to create implicit label declarations and to load

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2009-2012, Free Software Foundation, Inc. --
-- Copyright (C) 2009-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- --
@ -38,7 +38,7 @@ package Par_SCO is
procedure Initialize;
-- Initialize internal tables for a new compilation
procedure SCO_Record (U : Unit_Number_Type);
procedure SCO_Record_Raw (U : Unit_Number_Type);
-- This procedure scans the tree for the unit identified by U, populating
-- internal tables recording the SCO information. Note that this is done
-- before any semantic analysis/expansion happens.
@ -49,6 +49,9 @@ package Par_SCO is
-- by Val. The condition is identified by the First_Sloc value in the
-- original tree associated with Cond.
procedure Set_SCO_Logical_Operator (Op : Node_Id);
-- Mark some putative logical operator as a short circuit one
procedure Set_SCO_Pragma_Enabled (Loc : Source_Ptr);
-- This procedure is called from Sem_Prag when a pragma is enabled (i.e.
-- when the Pragma_Enabled flag is set). Loc is the Sloc of the N_Pragma
@ -60,14 +63,19 @@ package Par_SCO is
function SCO_Pragma_Disabled (Loc : Source_Ptr) return Boolean;
-- True if Loc is the source location of a disabled pragma
procedure SCO_Record_Filtered;
-- This procedure filters remaining putative AND/OR short-circuit operators
-- from the internal SCO raw table after the semantic analysis and fills
-- the filtered SCO table.
procedure SCO_Output;
-- Outputs SCO lines for all units, with appropriate section headers, as
-- recorded by previous calls to SCO_Record, possibly modified by calls to
-- Set_SCO_Condition.
procedure dsco;
-- Debug routine to dump internal SCO table. This is a raw format dump
-- showing exactly what the table contains.
-- Debug routine to dump internal SCO tables. This is a raw format dump
-- showing exactly what the tables contain.
procedure pscos;
-- Debugging procedure to output contents of SCO binary tables in the

View File

@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2009-2012, Free Software Foundation, Inc. --
-- Copyright (C) 2009-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- --
@ -260,6 +260,7 @@ begin
T.C1 = '|'
then
Write_Info_Char (T.C1);
pragma Assert (T.C2 /= '?');
Output_Source_Location (T.From);
else

View File

@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2009-2012, Free Software Foundation, Inc. --
-- Copyright (C) 2009-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- --

View File

@ -443,8 +443,8 @@ package SCOs is
-- SCO contexts, the only pragmas with decisions are Assert, Check,
-- dyadic Debug, Precondition and Postcondition). These entries will
-- be omitted in output if the pragma is disabled (see comments for
-- statement entries). This is achieved by setting C1 to NUL for all
-- SCO entries of the decision.
-- statement entries): this filtering is achieved during the second pass
-- of SCO generation (Par_SCO.SCO_Record_Filtered).
-- Decision (ASPECT)
-- C1 = 'A'
@ -467,7 +467,7 @@ package SCOs is
-- Operator
-- C1 = '!', '&', '|'
-- C2 = ' '
-- C2 = ' '/'?'/ (Logical operator/Putative one)
-- From = location of NOT/AND/OR token
-- To = No_Source_Location
-- Last = False
@ -511,6 +511,14 @@ package SCOs is
To : Nat;
-- Ending index in SCO_Table of SCO information for this unit
-- Warning: SCOs generation (in Par_SCO) is done in two passes, which
-- communicate through an intermediate table (Par_SCO.SCO_Raw_Table).
-- Before the second pass executes, From and To actually reference index
-- in the internal table: SCO_Table is empty. Then, at the end of the
-- second pass, these indexes are updated in order to reference indexes
-- in SCO_Table.
end record;
package SCO_Unit_Table is new GNAT.Table (

View File

@ -1855,7 +1855,7 @@ package body Sem_Ch10 is
In_Extended_Main_Source_Unit
(Cunit_Entity (Current_Sem_Unit))
then
SCO_Record (Unum);
SCO_Record_Raw (Unum);
end if;
-- Analyze the unit if semantics active

View File

@ -3551,10 +3551,22 @@ package body Sem_Ch8 is
if Ekind (Pack) /= E_Package and then Etype (Pack) /= Any_Type then
if Ekind (Pack) = E_Generic_Package then
Error_Msg_N -- CODEFIX
("a generic package is not allowed in a use clause",
Pack_Name);
("a generic package is not allowed in a use clause",
Pack_Name);
elsif Ekind_In (Pack, E_Generic_Function, E_Generic_Package)
then
Error_Msg_N -- CODEFIX
("a generic subprogram is not allowed in a use clause",
Pack_Name);
elsif Ekind_In (Pack, E_Function, E_Procedure, E_Operator) then
Error_Msg_N -- CODEFIX
("a subprogram is not allowed in a use clause",
Pack_Name);
else
Error_Msg_N ("& is not a usable package", Pack_Name);
Error_Msg_N ("& is not allowed in a use clause", Pack_Name);
end if;
else

View File

@ -46,6 +46,7 @@ with Nmake; use Nmake;
with Nlists; use Nlists;
with Opt; use Opt;
with Output; use Output;
with Par_SCO; use Par_SCO;
with Restrict; use Restrict;
with Rident; use Rident;
with Rtsfind; use Rtsfind;
@ -8188,11 +8189,11 @@ package body Sem_Res is
procedure Resolve_Generalized_Indexing (N : Node_Id; Typ : Entity_Id) is
Indexing : constant Node_Id := Generalized_Indexing (N);
Call : Node_Id;
Indices : List_Id;
Indexes : List_Id;
Pref : Node_Id;
begin
-- In ASIS mode, propagate the information about the indices back to
-- In ASIS mode, propagate the information about the indexes back to
-- to the original indexing node. The generalized indexing is either
-- a function call, or a dereference of one. The actuals include the
-- prefix of the original node, which is the container expression.
@ -8209,9 +8210,9 @@ package body Sem_Res is
end loop;
if Nkind (Call) = N_Function_Call then
Indices := Parameter_Associations (Call);
Pref := Remove_Head (Indices);
Set_Expressions (N, Indices);
Indexes := Parameter_Associations (Call);
Pref := Remove_Head (Indexes);
Set_Expressions (N, Indexes);
Set_Prefix (N, Pref);
end if;
@ -8658,6 +8659,13 @@ package body Sem_Res is
and then B_Typ = Standard_Boolean
and then Nkind_In (N, N_Op_And, N_Op_Or)
then
-- Mark the corresponding putative SCO operator as truly a logical
-- (and short-circuit) operator.
if Generate_SCO and then Comes_From_Source (N) then
Set_SCO_Logical_Operator (N);
end if;
if Nkind (N) = N_Op_And then
Rewrite (N,
Make_And_Then (Sloc (N),