From: Arnaud Charlet Date: Thu, 11 Apr 2013 09:46:54 +0000 (+0200) Subject: [multiple changes] X-Git-Tag: upstream/12.2.0~70367 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=303fbb20de25887e87f259cef49db64b51a7db0e;p=platform%2Fupstream%2Fgcc.git [multiple changes] 2013-04-11 Arnaud Charlet * 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 * 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 * exp_aggr.adb (Aggr_Size_OK): Refine setting of Max_Aggr_Size in particular in CodePeer mode. 2013-04-11 Vincent Celier * gnat_ugn.texi: Add documentation for backup copies of project files for gnatname. From-SVN: r197751 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 386ce23..07f04f0 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,27 @@ +2013-04-11 Arnaud Charlet + + * 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 + + * 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 + + * exp_aggr.adb (Aggr_Size_OK): Refine setting of Max_Aggr_Size + in particular in CodePeer mode. + +2013-04-11 Vincent Celier + + * gnat_ugn.texi: Add documentation for backup copies of project + files for gnatname. + 2013-04-11 Tristan Gingold * gnat_rm.texi: Add Detect_BLocking in the ravenscar profile @@ -7,7 +31,8 @@ * gnatname.adb (Scan_Args): Recognize new switch --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 project file if gnatname is not invoked with --no-backup. diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb index deb36ec..6d0a53f 100644 --- a/gcc/ada/debug.adb +++ b/gcc/ada/debug.adb @@ -126,11 +126,11 @@ package body Debug is -- d.F Alfa mode -- d.G -- d.H Standard package only mode for gnat2why - -- d.I SCIL generation mode + -- d.I -- d.J Disable parallel SCIL generation mode -- d.K Alfa detection only mode for gnat2why -- 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.O Dump internal SCO tables -- 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 -- 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 -- node for storage of any flags or fields). This can be used to do -- experiments on the impact of increasing entity sizes. diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index ab42366..c80ecd5 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -313,31 +313,11 @@ package body Exp_Aggr is Lov : Uint; Hiv : Uint; - -- The following constant determines the maximum size of an array - -- aggregate produced by converting named to positional notation (e.g. - -- from others clauses). 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)))); + Max_Aggr_Size : Nat; + -- Determines the maximum size of an array aggregate produced by + -- converting named to positional notation (e.g. from others clauses). + -- This avoids running away with attempts to convert huge aggregates, + -- which hit memory limits in the backend. function Component_Count (T : Entity_Id) return Int; -- 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 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)); Indx := First_Index (Typ); diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb index bf530cb..b036229 100644 --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -8382,10 +8382,10 @@ package body Exp_Disp is -- excluded from this check because interfaces must be visible in -- the public and private part (RM 7.3 (7.3/2)) - -- We disable this check in CodePeer mode, to accommodate legacy - -- Ada code. + -- We disable this check in Relaxed_RM_Semantics mode, to + -- accommodate legacy Ada code. - if not CodePeer_Mode + if not Relaxed_RM_Semantics and then Is_Abstract_Type (Typ) and then Is_Abstract_Subprogram (Prim) and then Present (Alias (Prim)) diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb index 4cfc339..2680b4f 100644 --- a/gcc/ada/gnat1drv.adb +++ b/gcc/ada/gnat1drv.adb @@ -6,7 +6,7 @@ -- -- -- 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 -- -- 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 begin - -- Debug flag -gnatd.I is a synonym for Generate_SCIL and requires code - -- generation. + -- -gnatd.M enables Relaxed_RM_Semantics - if Debug_Flag_Dot_II and then Operating_Mode = Generate_Code then - Generate_SCIL := True; + if Debug_Flag_Dot_MM then + Relaxed_RM_Semantics := True; end if; -- Disable CodePeer_Mode in Check_Syntax, since we need front-end @@ -275,6 +274,13 @@ procedure Gnat1drv is Force_ALI_Tree_File := 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; -- Set switches for formal verification mode diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index ad48a21..506356b 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -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 all other options. +@item --subdirs= +Real object, library or exec directories are subdirectories of the +specified ones. + +@item --no-backup +Do not create a backup copy of an existing project file. + @item --and 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 @file{file}. +@item -eL +Follow symbolic links when processing project files. + @item ^-f^/FOREIGN_PATTERN=^@file{pattern} @cindex @option{^-f^/FOREIGN_PATTERN^} (@code{gnatname}) 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^}. When a switch @option{^-P^/PROJECT_FILE^} is 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 .gpr, a backup copy of the project file is created +in the project directory with file name .gpr.saved_x. 'x' is the first +non negative number that makes this backup copy a new file. @item ^-v^/VERBOSE^ @cindex @option{^-v^/VERBOSE^} (@code{gnatname}) diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index 8f60b71..e48eb00 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -1188,6 +1188,11 @@ package Opt is -- Set to True to enable compatibility mode with Rational compiler, and -- 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; -- GNATPREP -- Set to True if -C switch used diff --git a/gcc/ada/par-ch2.adb b/gcc/ada/par-ch2.adb index 2cd54b7..62c6735 100644 --- a/gcc/ada/par-ch2.adb +++ b/gcc/ada/par-ch2.adb @@ -6,7 +6,7 @@ -- -- -- 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 -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -493,9 +493,10 @@ package body Ch2 is -- Ada RM terminology). -- 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 ("\since previous argument had identifier (RM 2.8(4))"); end if; diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index c2a298b..ef9e4b9 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -2405,6 +2405,11 @@ package body Sem_Attr is elsif not Comes_From_Source (N) then null; + elsif Relaxed_RM_Semantics + and then Nkind (P) = N_Attribute_Reference + then + null; + else Error_Attr ("invalid prefix for % attribute", P); end if; @@ -5011,6 +5016,11 @@ package body Sem_Attr is then null; + elsif Relaxed_RM_Semantics + and then Nkind (P) = N_Attribute_Reference + then + null; + else Error_Attr_P ("invalid prefix for % attribute"); end if; @@ -9180,15 +9190,12 @@ package body Sem_Attr is -- when within an instance, because any violations will have -- been caught by the compilation of the generic unit. - -- Note that we relax this check in CodePeer mode for - -- compatibility with legacy code, since CodePeer is an - -- Ada source code analyzer, not a strict compiler. - -- ??? Note that a better approach would be to have a - -- separate switch to relax this rule, and enable this - -- switch in CodePeer mode. + -- We relax this check in Relaxed_RM_Semantics mode for + -- compatibility with legacy code for use by Ada source + -- code analyzers (e.g. CodePeer). elsif Attr_Id = Attribute_Access - and then not CodePeer_Mode + and then not Relaxed_RM_Semantics and then not In_Instance and then Present (Enclosing_Generic_Unit (Entity (P))) and then Present (Enclosing_Generic_Body (N)) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 92df556..3b63574 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -9002,7 +9002,9 @@ package body Sem_Ch13 is procedure Too_Late is 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; -- Start of processing for Rep_Item_Too_Late @@ -9017,7 +9019,7 @@ package body Sem_Ch13 is 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 -- renamed internal entity, but we still want to be able to set copies -- of attribute values such as Size/Alignment. diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index 214fb11..06dddf5 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -792,6 +792,12 @@ package body Sem_Ch8 is Make_Subtype_From_Expr (Nam, Typ))); Rewrite (Subtype_Mark (N), New_Occurrence_Of (Subt, Loc)); 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 Check_Constrained_Object; diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index e60573e..4980bfd 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -1914,13 +1914,13 @@ package body Sem_Prag is -- instance can be in a nested scope. The check that protected type -- is itself a library-level declaration is done elsewhere. - -- Note: we omit this check in Codepeer mode to properly handle code - -- prior to AI-0033 (pragmas don't matter to codepeer in any case). + -- Note: we omit this check in Relaxed_RM_Semantics mode to properly + -- handle code prior to AI-0033. if Inside_A_Generic then if Ekind (Scope (Current_Scope)) = E_Generic_Package and then In_Package_Body (Scope (Current_Scope)) - and then not CodePeer_Mode + and then not Relaxed_RM_Semantics then Error_Pragma ("pragma% cannot be used inside a generic"); end if; @@ -3648,9 +3648,12 @@ package body Sem_Prag is end if; -- 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) and then Nkind (Parent (Declaration_Node (E))) = N_Subprogram_Body + and then not Relaxed_RM_Semantics then Error_Pragma ("pragma% requires separate spec and must come before body"); @@ -5996,7 +5999,9 @@ package body Sem_Prag is Error_Pragma_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 ("cannot export entity& that has an address clause", Arg); end if;