[multiple changes]

2013-04-11  Arnaud Charlet  <charlet@adacore.com>

	* debug.adb, sem_prag.adb, par-ch2.adb, sem_attr.adb, gnat1drv.adb,
	exp_disp.adb, opt.ads, sem_ch13.adb (Relaxed_RM_Semantics): New flag.
	Enable this flag in CodePeer mode, and also via -gnatd.M.
	Replace some uses of CodePeer_Mode by Relaxed_RM_Semantics.

2013-04-11  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch8.adb (Check_Constrained_Object): If a subtype is created
	from the renamed object in an object renaming declaration with
	an unconstrained nominal subtype, freeze the created subtype at
	once, to prevent order of elaboration issues in the backend.

2013-04-11  Arnaud Charlet  <charlet@adacore.com>

	* exp_aggr.adb (Aggr_Size_OK): Refine setting of Max_Aggr_Size
	in particular in CodePeer mode.

2013-04-11  Vincent Celier  <celier@adacore.com>

	* gnat_ugn.texi: Add documentation for backup copies of project
	files for gnatname.

From-SVN: r197751
This commit is contained in:
Arnaud Charlet 2013-04-11 11:46:54 +02:00
parent 165bdb4b49
commit 303fbb20de
12 changed files with 136 additions and 52 deletions

View File

@ -1,3 +1,27 @@
2013-04-11 Arnaud Charlet <charlet@adacore.com>
* debug.adb, sem_prag.adb, par-ch2.adb, sem_attr.adb, gnat1drv.adb,
exp_disp.adb, opt.ads, sem_ch13.adb (Relaxed_RM_Semantics): New flag.
Enable this flag in CodePeer mode, and also via -gnatd.M.
Replace some uses of CodePeer_Mode by Relaxed_RM_Semantics.
2013-04-11 Ed Schonberg <schonberg@adacore.com>
* sem_ch8.adb (Check_Constrained_Object): If a subtype is created
from the renamed object in an object renaming declaration with
an unconstrained nominal subtype, freeze the created subtype at
once, to prevent order of elaboration issues in the backend.
2013-04-11 Arnaud Charlet <charlet@adacore.com>
* exp_aggr.adb (Aggr_Size_OK): Refine setting of Max_Aggr_Size
in particular in CodePeer mode.
2013-04-11 Vincent Celier <celier@adacore.com>
* gnat_ugn.texi: Add documentation for backup copies of project
files for gnatname.
2013-04-11 Tristan Gingold <gingold@adacore.com> 2013-04-11 Tristan Gingold <gingold@adacore.com>
* gnat_rm.texi: Add Detect_BLocking in the ravenscar profile * gnat_rm.texi: Add Detect_BLocking in the ravenscar profile
@ -7,7 +31,8 @@
* gnatname.adb (Scan_Args): Recognize new switch --no-backup * gnatname.adb (Scan_Args): Recognize new switch --no-backup
(Usage): Add line for --no-backup. (Usage): Add line for --no-backup.
* opt.ads (No_Nackup): New Boolean variable, initialized to False. * opt.ads (No_Backup): New Boolean variable, initialized to False.
(Ada_Version_Default): Switch to Ada 2012 by default.
* prj-makr.adb (Initialize): Create a backup for an existing * prj-makr.adb (Initialize): Create a backup for an existing
project file if gnatname is not invoked with --no-backup. project file if gnatname is not invoked with --no-backup.

View File

@ -126,11 +126,11 @@ package body Debug is
-- d.F Alfa mode -- d.F Alfa mode
-- d.G -- d.G
-- d.H Standard package only mode for gnat2why -- d.H Standard package only mode for gnat2why
-- d.I SCIL generation mode -- d.I
-- d.J Disable parallel SCIL generation mode -- d.J Disable parallel SCIL generation mode
-- d.K Alfa detection only mode for gnat2why -- d.K Alfa detection only mode for gnat2why
-- d.L Depend on back end for limited types in if and case expressions -- d.L Depend on back end for limited types in if and case expressions
-- d.M -- d.M Relaxed RM semantics
-- d.N Add node to all entities -- d.N Add node to all entities
-- d.O Dump internal SCO tables -- d.O Dump internal SCO tables
-- d.P Previous (non-optimized) handling of length comparisons -- d.P Previous (non-optimized) handling of length comparisons
@ -625,6 +625,9 @@ package body Debug is
-- case expansion, leaving it up to the back end to handle conditional -- case expansion, leaving it up to the back end to handle conditional
-- expressions correctly. -- expressions correctly.
-- d.M Relaxed RM semantics. This flag sets Opt.Relaxed_RM_Semantics
-- See Opt.Relaxed_RM_Semantics for more details.
-- d.N Enlarge entities by one node (but don't attempt to use this extra -- d.N Enlarge entities by one node (but don't attempt to use this extra
-- node for storage of any flags or fields). This can be used to do -- node for storage of any flags or fields). This can be used to do
-- experiments on the impact of increasing entity sizes. -- experiments on the impact of increasing entity sizes.

View File

@ -313,31 +313,11 @@ package body Exp_Aggr is
Lov : Uint; Lov : Uint;
Hiv : Uint; Hiv : Uint;
-- The following constant determines the maximum size of an array Max_Aggr_Size : Nat;
-- aggregate produced by converting named to positional notation (e.g. -- Determines the maximum size of an array aggregate produced by
-- from others clauses). This avoids running away with attempts to -- converting named to positional notation (e.g. from others clauses).
-- convert huge aggregates, which hit memory limits in the backend. -- This avoids running away with attempts to convert huge aggregates,
-- which hit memory limits in the backend.
-- The normal limit is 5000, but we increase this limit to 2**24 (about
-- 16 million) if Restrictions (No_Elaboration_Code) or Restrictions
-- (No_Implicit_Loops) is specified, since in either case we are at
-- risk of declaring the program illegal because of this limit. We also
-- increase the limit when Static_Elaboration_Desired, given that this
-- means that objects are intended to be placed in data memory.
-- We also increase the limit if the aggregate is for a packed two-
-- dimensional array, because if components are static it is much more
-- efficient to construct a one-dimensional equivalent array with static
-- components.
Max_Aggr_Size : constant Nat :=
5000 + (2 ** 24 - 5000) *
Boolean'Pos
(Restriction_Active (No_Elaboration_Code)
or else Restriction_Active (No_Implicit_Loops)
or else Is_Two_Dim_Packed_Array (Typ)
or else ((Ekind (Current_Scope) = E_Package
and then Static_Elaboration_Desired (Current_Scope))));
function Component_Count (T : Entity_Id) return Int; function Component_Count (T : Entity_Id) return Int;
-- The limit is applied to the total number of components that the -- The limit is applied to the total number of components that the
@ -396,6 +376,36 @@ package body Exp_Aggr is
-- Start of processing for Aggr_Size_OK -- Start of processing for Aggr_Size_OK
begin begin
-- The normal aggregate limit is 5000, but we increase this limit to
-- 2**24 (about 16 million) if Restrictions (No_Elaboration_Code) or
-- Restrictions (No_Implicit_Loops) is specified, since in either case
-- we are at risk of declaring the program illegal because of this
-- limit. We also increase the limit when Static_Elaboration_Desired,
-- given that this means that objects are intended to be placed in data
-- memory.
-- We also increase the limit if the aggregate is for a packed two-
-- dimensional array, because if components are static it is much more
-- efficient to construct a one-dimensional equivalent array with static
-- components.
-- Finally, we use a small limit in CodePeer mode where we favor loops
-- instead of thousands of single assignments (from large aggregates).
Max_Aggr_Size := 5000;
if CodePeer_Mode then
Max_Aggr_Size := 100;
elsif Restriction_Active (No_Elaboration_Code)
or else Restriction_Active (No_Implicit_Loops)
or else Is_Two_Dim_Packed_Array (Typ)
or else ((Ekind (Current_Scope) = E_Package
and then Static_Elaboration_Desired (Current_Scope)))
then
Max_Aggr_Size := 2 ** 24;
end if;
Siz := Component_Count (Component_Type (Typ)); Siz := Component_Count (Component_Type (Typ));
Indx := First_Index (Typ); Indx := First_Index (Typ);

View File

@ -8382,10 +8382,10 @@ package body Exp_Disp is
-- excluded from this check because interfaces must be visible in -- excluded from this check because interfaces must be visible in
-- the public and private part (RM 7.3 (7.3/2)) -- the public and private part (RM 7.3 (7.3/2))
-- We disable this check in CodePeer mode, to accommodate legacy -- We disable this check in Relaxed_RM_Semantics mode, to
-- Ada code. -- accommodate legacy Ada code.
if not CodePeer_Mode if not Relaxed_RM_Semantics
and then Is_Abstract_Type (Typ) and then Is_Abstract_Type (Typ)
and then Is_Abstract_Subprogram (Prim) and then Is_Abstract_Subprogram (Prim)
and then Present (Alias (Prim)) and then Present (Alias (Prim))

View File

@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2013, 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- --
@ -110,11 +110,10 @@ procedure Gnat1drv is
procedure Adjust_Global_Switches is procedure Adjust_Global_Switches is
begin begin
-- Debug flag -gnatd.I is a synonym for Generate_SCIL and requires code -- -gnatd.M enables Relaxed_RM_Semantics
-- generation.
if Debug_Flag_Dot_II and then Operating_Mode = Generate_Code then if Debug_Flag_Dot_MM then
Generate_SCIL := True; Relaxed_RM_Semantics := True;
end if; end if;
-- Disable CodePeer_Mode in Check_Syntax, since we need front-end -- Disable CodePeer_Mode in Check_Syntax, since we need front-end
@ -275,6 +274,13 @@ procedure Gnat1drv is
Force_ALI_Tree_File := True; Force_ALI_Tree_File := True;
Try_Semantics := True; Try_Semantics := True;
-- Make the Ada front-end more liberal to support other Ada compilers
Relaxed_RM_Semantics := True;
end if;
if Relaxed_RM_Semantics then
Overriding_Renamings := True;
end if; end if;
-- Set switches for formal verification mode -- Set switches for formal verification mode

View File

@ -12282,6 +12282,13 @@ Display Copyright and version, then exit disregarding all other options.
If @option{--version} was not used, display usage, then exit disregarding If @option{--version} was not used, display usage, then exit disregarding
all other options. all other options.
@item --subdirs=<dir>
Real object, library or exec directories are subdirectories <dir> of the
specified ones.
@item --no-backup
Do not create a backup copy of an existing project file.
@item --and @item --and
Start another section of directories/patterns. Start another section of directories/patterns.
@ -12328,6 +12335,9 @@ Specifying switch @option{^-D^/DIRS_FILE^} is equivalent to specifying as many
switches @option{^-d^/SOURCE_DIRS^} as there are nonempty lines in switches @option{^-d^/SOURCE_DIRS^} as there are nonempty lines in
@file{file}. @file{file}.
@item -eL
Follow symbolic links when processing project files.
@item ^-f^/FOREIGN_PATTERN=^@file{pattern} @item ^-f^/FOREIGN_PATTERN=^@file{pattern}
@cindex @option{^-f^/FOREIGN_PATTERN^} (@code{gnatname}) @cindex @option{^-f^/FOREIGN_PATTERN^} (@code{gnatname})
Foreign patterns. Using this switch, it is possible to add sources of languages Foreign patterns. Using this switch, it is possible to add sources of languages
@ -12354,6 +12364,10 @@ information. @file{proj} must be writable.
There may be only one switch @option{^-P^/PROJECT_FILE^}. There may be only one switch @option{^-P^/PROJECT_FILE^}.
When a switch @option{^-P^/PROJECT_FILE^} is specified, When a switch @option{^-P^/PROJECT_FILE^} is specified,
no switch @option{^-c^/CONFIG_FILE^} may be specified. no switch @option{^-c^/CONFIG_FILE^} may be specified.
On all platforms, except on VMS, when @code{gnatname} is invoked for an
existing project file <proj>.gpr, a backup copy of the project file is created
in the project directory with file name <proj>.gpr.saved_x. 'x' is the first
non negative number that makes this backup copy a new file.
@item ^-v^/VERBOSE^ @item ^-v^/VERBOSE^
@cindex @option{^-v^/VERBOSE^} (@code{gnatname}) @cindex @option{^-v^/VERBOSE^} (@code{gnatname})

View File

@ -1188,6 +1188,11 @@ package Opt is
-- Set to True to enable compatibility mode with Rational compiler, and -- Set to True to enable compatibility mode with Rational compiler, and
-- to accept renamings of implicit operations in their own scope. -- to accept renamings of implicit operations in their own scope.
Relaxed_RM_Semantics : Boolean := False;
-- GNAT
-- Set to True to ignore some Ada semantic error to help parse legacy
-- Ada code for use in e.g. static analysis (such as CodePeer).
Replace_In_Comments : Boolean := False; Replace_In_Comments : Boolean := False;
-- GNATPREP -- GNATPREP
-- Set to True if -C switch used -- Set to True if -C switch used

View File

@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2013, 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- --
@ -493,9 +493,10 @@ package body Ch2 is
-- Ada RM terminology). -- Ada RM terminology).
-- Since older GNAT versions did not generate this error, disable this -- Since older GNAT versions did not generate this error, disable this
-- message in codepeer mode to help legacy code using codepeer. -- message in Relaxed_RM_Semantics mode to help legacy code using e.g.
-- codepeer.
if Identifier_Seen and not Id_Present and not CodePeer_Mode then if Identifier_Seen and not Id_Present and not Relaxed_RM_Semantics then
Error_Msg_SC ("|pragma argument identifier required here"); Error_Msg_SC ("|pragma argument identifier required here");
Error_Msg_SC ("\since previous argument had identifier (RM 2.8(4))"); Error_Msg_SC ("\since previous argument had identifier (RM 2.8(4))");
end if; end if;

View File

@ -2405,6 +2405,11 @@ package body Sem_Attr is
elsif not Comes_From_Source (N) then elsif not Comes_From_Source (N) then
null; null;
elsif Relaxed_RM_Semantics
and then Nkind (P) = N_Attribute_Reference
then
null;
else else
Error_Attr ("invalid prefix for % attribute", P); Error_Attr ("invalid prefix for % attribute", P);
end if; end if;
@ -5011,6 +5016,11 @@ package body Sem_Attr is
then then
null; null;
elsif Relaxed_RM_Semantics
and then Nkind (P) = N_Attribute_Reference
then
null;
else else
Error_Attr_P ("invalid prefix for % attribute"); Error_Attr_P ("invalid prefix for % attribute");
end if; end if;
@ -9180,15 +9190,12 @@ package body Sem_Attr is
-- when within an instance, because any violations will have -- when within an instance, because any violations will have
-- been caught by the compilation of the generic unit. -- been caught by the compilation of the generic unit.
-- Note that we relax this check in CodePeer mode for -- We relax this check in Relaxed_RM_Semantics mode for
-- compatibility with legacy code, since CodePeer is an -- compatibility with legacy code for use by Ada source
-- Ada source code analyzer, not a strict compiler. -- code analyzers (e.g. CodePeer).
-- ??? Note that a better approach would be to have a
-- separate switch to relax this rule, and enable this
-- switch in CodePeer mode.
elsif Attr_Id = Attribute_Access elsif Attr_Id = Attribute_Access
and then not CodePeer_Mode and then not Relaxed_RM_Semantics
and then not In_Instance and then not In_Instance
and then Present (Enclosing_Generic_Unit (Entity (P))) and then Present (Enclosing_Generic_Unit (Entity (P)))
and then Present (Enclosing_Generic_Body (N)) and then Present (Enclosing_Generic_Body (N))

View File

@ -9002,7 +9002,9 @@ package body Sem_Ch13 is
procedure Too_Late is procedure Too_Late is
begin begin
Error_Msg_N ("|representation item appears too late!", N); if not Relaxed_RM_Semantics then
Error_Msg_N ("|representation item appears too late!", N);
end if;
end Too_Late; end Too_Late;
-- Start of processing for Rep_Item_Too_Late -- Start of processing for Rep_Item_Too_Late
@ -9017,7 +9019,7 @@ package body Sem_Ch13 is
and then not From_With_Type (T) and then not From_With_Type (T)
-- Exclude generated entitiesa (not coming from source). The common -- Exclude generated entities (not coming from source). The common
-- case is when we generate a renaming which prematurely freezes the -- case is when we generate a renaming which prematurely freezes the
-- renamed internal entity, but we still want to be able to set copies -- renamed internal entity, but we still want to be able to set copies
-- of attribute values such as Size/Alignment. -- of attribute values such as Size/Alignment.

View File

@ -792,6 +792,12 @@ package body Sem_Ch8 is
Make_Subtype_From_Expr (Nam, Typ))); Make_Subtype_From_Expr (Nam, Typ)));
Rewrite (Subtype_Mark (N), New_Occurrence_Of (Subt, Loc)); Rewrite (Subtype_Mark (N), New_Occurrence_Of (Subt, Loc));
Set_Etype (Nam, Subt); Set_Etype (Nam, Subt);
-- Freeze subtype at once, to prevent order of elaboration
-- issues in the backend. The renamed object exists, so its
-- type is already frozen in any case.
Freeze_Before (N, Subt);
end if; end if;
end if; end if;
end Check_Constrained_Object; end Check_Constrained_Object;

View File

@ -1914,13 +1914,13 @@ package body Sem_Prag is
-- instance can be in a nested scope. The check that protected type -- instance can be in a nested scope. The check that protected type
-- is itself a library-level declaration is done elsewhere. -- is itself a library-level declaration is done elsewhere.
-- Note: we omit this check in Codepeer mode to properly handle code -- Note: we omit this check in Relaxed_RM_Semantics mode to properly
-- prior to AI-0033 (pragmas don't matter to codepeer in any case). -- handle code prior to AI-0033.
if Inside_A_Generic then if Inside_A_Generic then
if Ekind (Scope (Current_Scope)) = E_Generic_Package if Ekind (Scope (Current_Scope)) = E_Generic_Package
and then In_Package_Body (Scope (Current_Scope)) and then In_Package_Body (Scope (Current_Scope))
and then not CodePeer_Mode and then not Relaxed_RM_Semantics
then then
Error_Pragma ("pragma% cannot be used inside a generic"); Error_Pragma ("pragma% cannot be used inside a generic");
end if; end if;
@ -3648,9 +3648,12 @@ package body Sem_Prag is
end if; end if;
-- Check that we are not applying this to a specless body -- Check that we are not applying this to a specless body
-- Relax this check if Relaxed_RM_Semantics to accomodate other Ada
-- compilers.
if Is_Subprogram (E) if Is_Subprogram (E)
and then Nkind (Parent (Declaration_Node (E))) = N_Subprogram_Body and then Nkind (Parent (Declaration_Node (E))) = N_Subprogram_Body
and then not Relaxed_RM_Semantics
then then
Error_Pragma Error_Pragma
("pragma% requires separate spec and must come before body"); ("pragma% requires separate spec and must come before body");
@ -5996,7 +5999,9 @@ package body Sem_Prag is
Error_Pragma_Arg Error_Pragma_Arg
("cannot export entity& that was previously imported", Arg); ("cannot export entity& that was previously imported", Arg);
elsif Present (Address_Clause (E)) and then not CodePeer_Mode then elsif Present (Address_Clause (E))
and then not Relaxed_RM_Semantics
then
Error_Pragma_Arg Error_Pragma_Arg
("cannot export entity& that has an address clause", Arg); ("cannot export entity& that has an address clause", Arg);
end if; end if;