Commit 0da343bc by Arnaud Charlet

[multiple changes]

2016-06-14  Hristian Kirtchev  <kirtchev@adacore.com>

	* lib.adb: Minor reformatting.
	* sem_util.adb (Is_OK_Volatile_Context): Do
	include Address in the supported attributes.

2016-06-14  Hristian Kirtchev  <kirtchev@adacore.com>

	* exp_ch4.adb (Expand_N_Case_Expression):
	Code cleanup. Finalize any transient controlled
	objects on exit from a case expression alternative.
	(Expand_N_If_Expression): Code cleanup.
	(Process_Actions): Removed.
	(Process_If_Case_Statements): New routine.
	(Process_Transient_Object): Change the name of formal Rel_Node to
	N and update all occurrences. Update the comment on usage. When
	the type of the context is Boolean, the proper insertion point
	for the finalization call is after the last declaration.

2016-06-14  Ed Schonberg  <schonberg@adacore.com>

	* lib-xref.ads, lib-xref.adb (Has_Deferred_Reference): new
	predicate to determine whether an entity appears in a context
	for which a Deferred_Reference was created, because it is not
	possible to determine when reference is analyzed whether it
	appears in a context in which the entity is modified.
	* sem_ch5.adb (Analyze_Statement): Do not emit a useless warning
	on assignment for an entity that has a deferred_reference.

2016-06-14  Javier Miranda  <miranda@adacore.com>

	* sem_res.adb (Resolve_Actuals): Generate a reference to actuals that
	come from source. Previously the reference was generated only if the
	call comes from source but the call may be rewritten by the expander
	thus causing the notification of spurious warnings.

2016-06-14  Arnaud Charlet  <charlet@adacore.com>

	* gnat1drv.adb: Remove further references to AAMP.
	* checks.adb (Apply_Scalar_Range_Check): Take
	Check_Float_Overflow info account.
	* live.ads, live.adb Added subprogram headers and
	start-of-processing-for comments.
	* sem_ch12.adb (Instantiate_Package_Body): Do not suppress
	checks when instantiating runtime units in CodePeer mode.

From-SVN: r237432
parent a5150cb1
2016-06-14 Hristian Kirtchev <kirtchev@adacore.com>
* lib.adb: Minor reformatting.
* sem_util.adb (Is_OK_Volatile_Context): Do
include Address in the supported attributes.
2016-06-14 Hristian Kirtchev <kirtchev@adacore.com>
* exp_ch4.adb (Expand_N_Case_Expression):
Code cleanup. Finalize any transient controlled
objects on exit from a case expression alternative.
(Expand_N_If_Expression): Code cleanup.
(Process_Actions): Removed.
(Process_If_Case_Statements): New routine.
(Process_Transient_Object): Change the name of formal Rel_Node to
N and update all occurrences. Update the comment on usage. When
the type of the context is Boolean, the proper insertion point
for the finalization call is after the last declaration.
2016-06-14 Ed Schonberg <schonberg@adacore.com>
* lib-xref.ads, lib-xref.adb (Has_Deferred_Reference): new
predicate to determine whether an entity appears in a context
for which a Deferred_Reference was created, because it is not
possible to determine when reference is analyzed whether it
appears in a context in which the entity is modified.
* sem_ch5.adb (Analyze_Statement): Do not emit a useless warning
on assignment for an entity that has a deferred_reference.
2016-06-14 Javier Miranda <miranda@adacore.com>
* sem_res.adb (Resolve_Actuals): Generate a reference to actuals that
come from source. Previously the reference was generated only if the
call comes from source but the call may be rewritten by the expander
thus causing the notification of spurious warnings.
2016-06-14 Arnaud Charlet <charlet@adacore.com>
* gnat1drv.adb: Remove further references to AAMP.
* checks.adb (Apply_Scalar_Range_Check): Take
Check_Float_Overflow info account.
* live.ads, live.adb Added subprogram headers and
start-of-processing-for comments.
* sem_ch12.adb (Instantiate_Package_Body): Do not suppress
checks when instantiating runtime units in CodePeer mode.
2016-06-14 Arnaud Charlet <charlet@adacore.com> 2016-06-14 Arnaud Charlet <charlet@adacore.com>
* exp_ch3.adb (Expand_N_Object_Declaration): Only consider * exp_ch3.adb (Expand_N_Object_Declaration): Only consider
......
...@@ -3077,15 +3077,11 @@ package body Checks is ...@@ -3077,15 +3077,11 @@ package body Checks is
-- Floating-point case -- Floating-point case
-- In the floating-point case, we only do range checks if the type is -- In the floating-point case, we only do range checks if the type is
-- constrained. We definitely do NOT want range checks for unconstrained -- constrained. We definitely do NOT want range checks for unconstrained
-- types, since we want to have infinities -- types, since we want to have infinities, except when
-- Check_Float_Overflow is set.
elsif Is_Floating_Point_Type (S_Typ) then elsif Is_Floating_Point_Type (S_Typ) then
if Is_Constrained (S_Typ) or else Check_Float_Overflow then
-- Normally, we only do range checks if the type is constrained. We do
-- NOT want range checks for unconstrained types, since we want to have
-- infinities.
if Is_Constrained (S_Typ) then
Enable_Range_Check (Expr); Enable_Range_Check (Expr);
end if; end if;
......
...@@ -634,11 +634,9 @@ procedure Gnat1drv is ...@@ -634,11 +634,9 @@ procedure Gnat1drv is
if Debug_Flag_Dot_LL then if Debug_Flag_Dot_LL then
Back_End_Handles_Limited_Types := True; Back_End_Handles_Limited_Types := True;
-- If no debug flag, usage off for AAMP, SCIL cases -- If no debug flag, usage off for SCIL cases
elsif AAMP_On_Target elsif Generate_SCIL then
or else Generate_SCIL
then
Back_End_Handles_Limited_Types := False; Back_End_Handles_Limited_Types := False;
-- Otherwise normal gcc back end, for now still turn flag off by -- Otherwise normal gcc back end, for now still turn flag off by
...@@ -667,20 +665,16 @@ procedure Gnat1drv is ...@@ -667,20 +665,16 @@ procedure Gnat1drv is
-- back end some day, it would not be true for this test, but it -- back end some day, it would not be true for this test, but it
-- would be non-GCC, so this is a bit troublesome ??? -- would be non-GCC, so this is a bit troublesome ???
Front_End_Inlining := AAMP_On_Target or Generate_C_Code; Front_End_Inlining := Generate_C_Code;
end if; end if;
-- Set back-end inlining indication -- Set back-end inlining indication
Back_End_Inlining := Back_End_Inlining :=
-- No back-end inlining available on AAMP
not AAMP_On_Target
-- No back-end inlining available on C generation -- No back-end inlining available on C generation
and then not Generate_C_Code not Generate_C_Code
-- No back-end inlining in GNATprove mode, since it just confuses -- No back-end inlining in GNATprove mode, since it just confuses
-- the formal verification process. -- the formal verification process.
......
...@@ -1218,6 +1218,21 @@ package body Lib.Xref is ...@@ -1218,6 +1218,21 @@ package body Lib.Xref is
return E; return E;
end Get_Key; end Get_Key;
----------------------------
-- Has_Deferred_Reference --
----------------------------
function Has_Deferred_Reference (Ent : Entity_Id) return Boolean is
begin
for J in Deferred_References.First .. Deferred_References.Last loop
if Deferred_References.Table (J).E = Ent then
return True;
end if;
end loop;
return False;
end Has_Deferred_Reference;
---------- ----------
-- Hash -- -- Hash --
---------- ----------
......
...@@ -613,6 +613,11 @@ package Lib.Xref is ...@@ -613,6 +613,11 @@ package Lib.Xref is
procedure Process_Deferred_References; procedure Process_Deferred_References;
-- This procedure is called from Frontend to process these table entries -- This procedure is called from Frontend to process these table entries
function Has_Deferred_Reference (Ent : Entity_Id) return Boolean;
-- This function determines whether an entity has a pending reference, in
-- order to suppress premature warnings about useless assignments. See
-- comments in Analyze_Assignment in sem-ch5.adb.
----------------------------- -----------------------------
-- SPARK Xrefs Information -- -- SPARK Xrefs Information --
----------------------------- -----------------------------
......
...@@ -70,10 +70,12 @@ package body Lib is ...@@ -70,10 +70,12 @@ package body Lib is
(S : Source_Ptr; (S : Source_Ptr;
Unwind_Instances : Boolean; Unwind_Instances : Boolean;
Unwind_Subunits : Boolean) return Unit_Number_Type; Unwind_Subunits : Boolean) return Unit_Number_Type;
-- Common code for Get_Code_Unit (get unit of instantiation for -- Common processing for routines Get_Code_Unit, Get_Source_Unit, and
-- location) Get_Source_Unit (get unit of template for location) and -- Get_Top_Level_Code_Unit. Unwind_Instances is True when the unit for the
-- Get_Top_Level_Code_Unit (same as Get_Code_Unit but not stopping at -- top-level instantiation should be returned instead of the unit for the
-- subunits). -- template, in the case of an instantiation. Unwind_Subunits is True when
-- the corresponding top-level unit should be returned instead of a
-- subunit, in the case of a subunit.
-------------------------------------------- --------------------------------------------
-- Access Functions for Unit Table Fields -- -- Access Functions for Unit Table Fields --
...@@ -635,8 +637,11 @@ package body Lib is ...@@ -635,8 +637,11 @@ package body Lib is
function Get_Code_Unit (S : Source_Ptr) return Unit_Number_Type is function Get_Code_Unit (S : Source_Ptr) return Unit_Number_Type is
begin begin
return Get_Code_Or_Source_Unit (Top_Level_Location (S), return
Unwind_Instances => False, Unwind_Subunits => False); Get_Code_Or_Source_Unit
(Top_Level_Location (S),
Unwind_Instances => False,
Unwind_Subunits => False);
end Get_Code_Unit; end Get_Code_Unit;
function Get_Code_Unit (N : Node_Or_Entity_Id) return Unit_Number_Type is function Get_Code_Unit (N : Node_Or_Entity_Id) return Unit_Number_Type is
...@@ -652,7 +657,6 @@ package body Lib is ...@@ -652,7 +657,6 @@ package body Lib is
begin begin
if N <= Compilation_Switches.Last then if N <= Compilation_Switches.Last then
return Compilation_Switches.Table (N); return Compilation_Switches.Table (N);
else else
return null; return null;
end if; end if;
...@@ -711,8 +715,9 @@ package body Lib is ...@@ -711,8 +715,9 @@ package body Lib is
function Get_Source_Unit (S : Source_Ptr) return Unit_Number_Type is function Get_Source_Unit (S : Source_Ptr) return Unit_Number_Type is
begin begin
return Get_Code_Or_Source_Unit (S, return
Unwind_Instances => True, Unwind_Subunits => False); Get_Code_Or_Source_Unit
(S, Unwind_Instances => True, Unwind_Subunits => False);
end Get_Source_Unit; end Get_Source_Unit;
function Get_Source_Unit (N : Node_Or_Entity_Id) return Unit_Number_Type is function Get_Source_Unit (N : Node_Or_Entity_Id) return Unit_Number_Type is
...@@ -726,8 +731,11 @@ package body Lib is ...@@ -726,8 +731,11 @@ package body Lib is
function Get_Top_Level_Code_Unit (S : Source_Ptr) return Unit_Number_Type is function Get_Top_Level_Code_Unit (S : Source_Ptr) return Unit_Number_Type is
begin begin
return Get_Code_Or_Source_Unit (Top_Level_Location (S), return
Unwind_Instances => False, Unwind_Subunits => True); Get_Code_Or_Source_Unit
(Top_Level_Location (S),
Unwind_Instances => False,
Unwind_Subunits => True);
end Get_Top_Level_Code_Unit; end Get_Top_Level_Code_Unit;
function Get_Top_Level_Code_Unit function Get_Top_Level_Code_Unit
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2000-2013, Free Software Foundation, Inc. -- -- Copyright (C) 2000-2016, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -36,10 +36,10 @@ package body Live is ...@@ -36,10 +36,10 @@ package body Live is
-- Name_Set -- Name_Set
-- The Name_Set type is used to store the temporary mark bits -- The Name_Set type is used to store the temporary mark bits used by the
-- used by the garbage collection of entities. Using a separate -- garbage collection of entities. Using a separate array prevents using up
-- array prevents using up any valuable per-node space and possibly -- any valuable per-node space and possibly results in better locality and
-- results in better locality and cache usage. -- cache usage.
type Name_Set is array (Node_Id range <>) of Boolean; type Name_Set is array (Node_Id range <>) of Boolean;
pragma Pack (Name_Set); pragma Pack (Name_Set);
...@@ -66,14 +66,13 @@ package body Live is ...@@ -66,14 +66,13 @@ package body Live is
-- The Mark phase is split into two phases: -- The Mark phase is split into two phases:
procedure Init_Marked (Root : Node_Id; Marks : out Name_Set); procedure Init_Marked (Root : Node_Id; Marks : out Name_Set);
-- For all subprograms, reset Is_Public flag if a pragma Eliminate -- For all subprograms, reset Is_Public flag if a pragma Eliminate applies
-- applies to the entity, and set the Marked flag to Is_Public -- to the entity, and set the Marked flag to Is_Public.
procedure Trace_Marked (Root : Node_Id; Marks : in out Name_Set); procedure Trace_Marked (Root : Node_Id; Marks : in out Name_Set);
-- Traverse the tree skipping any unmarked subprogram bodies. -- Traverse the tree skipping any unmarked subprogram bodies. All visited
-- All visited entities are marked, as well as entities denoted -- entities are marked, as well as entities denoted by a visited identifier
-- by a visited identifier or operator. When an entity is first -- or operator. When an entity is first marked it is traced as well.
-- marked it is traced as well.
-- Local functions -- Local functions
...@@ -137,6 +136,10 @@ package body Live is ...@@ -137,6 +136,10 @@ package body Live is
function Process (N : Node_Id) return Traverse_Result; function Process (N : Node_Id) return Traverse_Result;
procedure Traverse is new Traverse_Proc (Process); procedure Traverse is new Traverse_Proc (Process);
-------------
-- Process --
-------------
function Process (N : Node_Id) return Traverse_Result is function Process (N : Node_Id) return Traverse_Result is
begin begin
case Nkind (N) is case Nkind (N) is
...@@ -233,6 +236,10 @@ package body Live is ...@@ -233,6 +236,10 @@ package body Live is
function Process (N : Node_Id) return Traverse_Result; function Process (N : Node_Id) return Traverse_Result;
procedure Traverse is new Traverse_Proc (Process); procedure Traverse is new Traverse_Proc (Process);
-------------
-- Process --
-------------
function Process (N : Node_Id) return Traverse_Result is function Process (N : Node_Id) return Traverse_Result is
begin begin
case Nkind (N) is case Nkind (N) is
...@@ -263,6 +270,8 @@ package body Live is ...@@ -263,6 +270,8 @@ package body Live is
return OK; return OK;
end Process; end Process;
-- Start of processing for Sweep
begin begin
Traverse (Root); Traverse (Root);
end Sweep; end Sweep;
...@@ -277,6 +286,10 @@ package body Live is ...@@ -277,6 +286,10 @@ package body Live is
procedure Process (N : Node_Id); procedure Process (N : Node_Id);
procedure Traverse is new Traverse_Proc (Process); procedure Traverse is new Traverse_Proc (Process);
-------------
-- Process --
-------------
procedure Process (N : Node_Id) is procedure Process (N : Node_Id) is
Result : Traverse_Result; Result : Traverse_Result;
pragma Warnings (Off, Result); pragma Warnings (Off, Result);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2000-2008, Free Software Foundation, Inc. -- -- Copyright (C) 2000-2016, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -23,14 +23,14 @@ ...@@ -23,14 +23,14 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- This package implements a compiler phase that determines the set -- This package implements a compiler phase that determines the set of live
-- of live entities. For now entities are considered live when they -- entities. For now entities are considered live when they have at least one
-- have at least one execution time reference. -- execution time reference.
package Live is package Live is
procedure Collect_Garbage_Entities; procedure Collect_Garbage_Entities;
-- Eliminate unreachable entities using a mark-and-sweep from -- Eliminate unreachable entities using a mark-and-sweep from the set of
-- the set of root entities, i.e. those having Is_Public set. -- root entities, i.e. those having Is_Public set.
end Live; end Live;
...@@ -11001,8 +11001,12 @@ package body Sem_Ch12 is ...@@ -11001,8 +11001,12 @@ package body Sem_Ch12 is
-- Note that we do NOT apply this criterion to children of GNAT -- Note that we do NOT apply this criterion to children of GNAT
-- The latter units must suppress checks explicitly if needed. -- The latter units must suppress checks explicitly if needed.
if Is_Predefined_File_Name -- We also do not suppress checks in CodePeer mode where we are
(Unit_File_Name (Get_Source_Unit (Gen_Decl))) -- interested in finding possible runtime errors.
if not CodePeer_Mode
and then Is_Predefined_File_Name
(Unit_File_Name (Get_Source_Unit (Gen_Decl)))
then then
Analyze (Act_Body, Suppress => All_Checks); Analyze (Act_Body, Suppress => All_Checks);
else else
......
...@@ -830,10 +830,24 @@ package body Sem_Ch5 is ...@@ -830,10 +830,24 @@ package body Sem_Ch5 is
-- warnings when an assignment is rewritten as another -- warnings when an assignment is rewritten as another
-- assignment, and gets tied up with itself. -- assignment, and gets tied up with itself.
-- There may have been a previous reference to a component of
-- the variable, which in general removes the Last_Assignment
-- field of the variable to indicate a relevant use of the
-- previous assignment. However, if the assignment is to a
-- subcomponent the reference may not have registered, because
-- it is not possible to determine whether the context is an
-- assignment. In those cases we generate a Deferred_Reference,
-- to be used at the end of compilation to generate the right
-- kind of reference, and we suppress a potential warning for
-- a useless assignment, which might be premature. This may
-- lose a warning in rare cases, but seems preferable to a
-- misleading warning.
if Warn_On_Modified_Unread if Warn_On_Modified_Unread
and then Is_Assignable (Ent) and then Is_Assignable (Ent)
and then Comes_From_Source (N) and then Comes_From_Source (N)
and then In_Extended_Main_Source_Unit (Ent) and then In_Extended_Main_Source_Unit (Ent)
and then not Has_Deferred_Reference (Ent)
then then
Warn_On_Useless_Assignment (Ent, N); Warn_On_Useless_Assignment (Ent, N);
end if; end if;
......
...@@ -3704,7 +3704,7 @@ package body Sem_Res is ...@@ -3704,7 +3704,7 @@ package body Sem_Res is
if Present (A) if Present (A)
and then Is_Entity_Name (A) and then Is_Entity_Name (A)
and then Comes_From_Source (N) and then Comes_From_Source (A)
then then
Orig_A := Entity (A); Orig_A := Entity (A);
......
...@@ -13643,7 +13643,8 @@ package body Sem_Util is ...@@ -13643,7 +13643,8 @@ package body Sem_Util is
elsif Nkind (Context) = N_Attribute_Reference elsif Nkind (Context) = N_Attribute_Reference
and then Prefix (Context) = Obj_Ref and then Prefix (Context) = Obj_Ref
and then Nam_In (Attribute_Name (Context), Name_Alignment, and then Nam_In (Attribute_Name (Context), Name_Address,
Name_Alignment,
Name_Component_Size, Name_Component_Size,
Name_First_Bit, Name_First_Bit,
Name_Last_Bit, Name_Last_Bit,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment