From 6a2e4f0bc7db748ff765e354db134ebc83899c03 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Mon, 1 Aug 2011 15:50:27 +0200 Subject: [PATCH] [multiple changes] 2011-08-01 Robert Dewar * make.adb, sem_ch4.adb: Minor reformatting. * gcc-interface/Make-lang.in: Update dependencies. * sem_util.adb, exp_ch5.adb: Minor reformatting. 2011-08-01 Arnaud Charlet * gnat_rm.texi: Fix definition of Long_Integer. 2011-08-01 Ed Schonberg * exp_aggr.adb: check limit size of static aggregate unconditionally, to prevent storage exhaustion. * exp_ch7.adb (Clean_Simple_Protected_Objects): if the scope being finalized is a function body, insert the cleanup code before the final return statement, to prevent spurious warnings. * s-pooglo.ads: add overriding indicator. From-SVN: r177035 --- gcc/ada/ChangeLog | 19 ++++++++++ gcc/ada/exp_aggr.adb | 3 +- gcc/ada/exp_ch5.adb | 6 +-- gcc/ada/exp_ch7.adb | 16 ++++++-- gcc/ada/gcc-interface/Make-lang.in | 61 +++++++++++++++--------------- gcc/ada/gnat_rm.texi | 27 +++++++------ gcc/ada/make.adb | 8 ++-- gcc/ada/s-pooglo.ads | 2 +- gcc/ada/sem_ch4.adb | 6 +-- gcc/ada/sem_util.adb | 12 +++--- 10 files changed, 94 insertions(+), 66 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 364abb57305..b1ea0323591 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,22 @@ +2011-08-01 Robert Dewar + + * make.adb, sem_ch4.adb: Minor reformatting. + * gcc-interface/Make-lang.in: Update dependencies. + * sem_util.adb, exp_ch5.adb: Minor reformatting. + +2011-08-01 Arnaud Charlet + + * gnat_rm.texi: Fix definition of Long_Integer. + +2011-08-01 Ed Schonberg + + * exp_aggr.adb: check limit size of static aggregate unconditionally, + to prevent storage exhaustion. + * exp_ch7.adb (Clean_Simple_Protected_Objects): if the scope being + finalized is a function body, insert the cleanup code before the final + return statement, to prevent spurious warnings. + * s-pooglo.ads: add overriding indicator. + 2011-08-01 Ed Schonberg * sem_ch4.adb (Operator_Check): improve error message when both a diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 64d8127e5a2..c336a97d676 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -6680,8 +6680,9 @@ package body Exp_Aggr is elsif Nkind (Expression (Expr)) /= N_Integer_Literal then return False; + end if; - elsif not Aggr_Size_OK (N, Typ) then + if not Aggr_Size_OK (N, Typ) then return False; end if; diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index ef77ec938cb..8acbd877cc7 100644 --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -2767,10 +2767,10 @@ package body Exp_Ch5 is I_Spec : constant Node_Id := Iterator_Specification (Isc); Id : constant Entity_Id := Defining_Identifier (I_Spec); - Container : constant Node_Id := Name (I_Spec); - -- An expression whose type is an array or a predefined container. + Container : constant Node_Id := Name (I_Spec); + -- An expression whose type is an array or a predefined container - Typ : constant Entity_Id := Etype (Container); + Typ : constant Entity_Id := Etype (Container); Cursor : Entity_Id; New_Loop : Node_Id; diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index ebfac59d42f..b6b8c8510e8 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -729,15 +729,25 @@ package body Exp_Ch7 is Ref : constant Node_Id := New_Occurrence_Of (E, Sloc (Stmt)); begin + -- If the current context is a function, the end of the + -- statement sequence is likely to be a return statement. + -- The cleanup code must be executed before the return. + + if Ekind (Current_Scope) = E_Function + and then Nkind (Stmt) = Sinfo.N_Return_Statement + then + Stmt := Prev (Stmt); + end if; + if Is_Simple_Protected_Type (Typ) then - Append_To (Stmts, Cleanup_Protected_Object (N, Ref)); + Insert_After (Stmt, Cleanup_Protected_Object (N, Ref)); elsif Has_Simple_Protected_Object (Typ) then if Is_Record_Type (Typ) then - Append_List_To (Stmts, Cleanup_Record (N, Ref, Typ)); + Insert_List_After (Stmt, Cleanup_Record (N, Ref, Typ)); elsif Is_Array_Type (Typ) then - Append_List_To (Stmts, Cleanup_Array (N, Ref, Typ)); + Insert_List_After (Stmt, Cleanup_Array (N, Ref, Typ)); end if; end if; end; diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in index d0eab2e8c02..77d2b2eac97 100644 --- a/gcc/ada/gcc-interface/Make-lang.in +++ b/gcc/ada/gcc-interface/Make-lang.in @@ -2274,18 +2274,18 @@ ada/exp_strm.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/a-uncdea.ads ada/alloc.ads ada/aspects.ads ada/atree.ads \ ada/atree.adb ada/casing.ads ada/debug.ads ada/einfo.ads ada/einfo.adb \ ada/elists.ads ada/exp_strm.ads ada/exp_strm.adb ada/exp_tss.ads \ - ada/get_targ.ads ada/gnat.ads ada/g-htable.ads ada/hostparm.ads \ - ada/lib.ads ada/namet.ads ada/nlists.ads ada/nlists.adb ada/nmake.ads \ - ada/nmake.adb ada/opt.ads ada/output.ads ada/restrict.ads \ - ada/rident.ads ada/rtsfind.ads ada/sem_aux.ads ada/sem_util.ads \ - ada/sinfo.ads ada/sinfo.adb ada/sinput.ads ada/snames.ads ada/stand.ads \ - ada/stringt.ads ada/system.ads ada/s-exctab.ads ada/s-htable.ads \ - ada/s-imenne.ads ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads \ - ada/s-rident.ads ada/s-stalib.ads ada/s-string.ads ada/s-traent.ads \ - ada/s-unstyp.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \ - ada/tbuild.ads ada/tbuild.adb ada/tree_io.ads ada/ttypes.ads \ - ada/types.ads ada/uintp.ads ada/uintp.adb ada/unchconv.ads \ - ada/unchdeal.ads ada/urealp.ads + ada/exp_util.ads ada/get_targ.ads ada/gnat.ads ada/g-htable.ads \ + ada/hostparm.ads ada/lib.ads ada/namet.ads ada/nlists.ads \ + ada/nlists.adb ada/nmake.ads ada/nmake.adb ada/opt.ads ada/output.ads \ + ada/restrict.ads ada/rident.ads ada/rtsfind.ads ada/sem_aux.ads \ + ada/sem_util.ads ada/sinfo.ads ada/sinfo.adb ada/sinput.ads \ + ada/snames.ads ada/stand.ads ada/stringt.ads ada/system.ads \ + ada/s-exctab.ads ada/s-htable.ads ada/s-imenne.ads ada/s-memory.ads \ + ada/s-os_lib.ads ada/s-parame.ads ada/s-rident.ads ada/s-stalib.ads \ + ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads ada/s-wchcon.ads \ + ada/table.ads ada/table.adb ada/tbuild.ads ada/tbuild.adb \ + ada/tree_io.ads ada/ttypes.ads ada/types.ads ada/uintp.ads \ + ada/uintp.adb ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/exp_tss.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/a-uncdea.ads ada/alloc.ads ada/aspects.ads ada/atree.ads \ @@ -2409,24 +2409,25 @@ ada/freeze.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/atree.adb ada/casing.ads ada/checks.ads ada/csets.ads ada/debug.ads \ ada/debug_a.ads ada/einfo.ads ada/einfo.adb ada/elists.ads \ ada/elists.adb ada/err_vars.ads ada/errout.ads ada/erroutc.ads \ - ada/exp_aggr.ads ada/exp_ch11.ads ada/exp_ch3.ads ada/exp_ch6.ads \ - ada/exp_ch7.ads ada/exp_disp.ads ada/exp_pakd.ads ada/exp_tss.ads \ - ada/exp_util.ads ada/exp_util.adb ada/expander.ads ada/fname.ads \ - ada/freeze.ads ada/freeze.adb ada/get_targ.ads ada/gnat.ads \ - ada/g-hesorg.ads ada/g-htable.ads ada/hostparm.ads ada/inline.ads \ - ada/interfac.ads ada/itypes.ads ada/layout.ads ada/lib.ads ada/lib.adb \ - ada/lib-list.adb ada/lib-sort.adb ada/lib-xref.ads ada/namet.ads \ - ada/namet.adb ada/nlists.ads ada/nlists.adb ada/nmake.ads ada/nmake.adb \ - ada/opt.ads ada/output.ads ada/restrict.ads ada/rident.ads \ - ada/rtsfind.ads ada/scans.ads ada/sem.ads ada/sem_aggr.ads \ - ada/sem_attr.ads ada/sem_aux.ads ada/sem_cat.ads ada/sem_ch13.ads \ - ada/sem_ch4.ads ada/sem_ch6.ads ada/sem_ch7.ads ada/sem_ch8.ads \ - ada/sem_disp.ads ada/sem_dist.ads ada/sem_elab.ads ada/sem_elim.ads \ - ada/sem_eval.ads ada/sem_intr.ads ada/sem_mech.ads ada/sem_prag.ads \ - ada/sem_res.ads ada/sem_res.adb ada/sem_type.ads ada/sem_util.ads \ - ada/sem_util.adb ada/sem_warn.ads ada/sinfo.ads ada/sinfo.adb \ - ada/sinfo-cn.ads ada/sinput.ads ada/snames.ads ada/stand.ads \ - ada/stringt.ads ada/style.ads ada/styleg.ads ada/styleg.adb \ + ada/eval_fat.ads ada/exp_aggr.ads ada/exp_ch11.ads ada/exp_ch3.ads \ + ada/exp_ch6.ads ada/exp_ch7.ads ada/exp_disp.ads ada/exp_pakd.ads \ + ada/exp_tss.ads ada/exp_util.ads ada/exp_util.adb ada/expander.ads \ + ada/fname.ads ada/freeze.ads ada/freeze.adb ada/get_targ.ads \ + ada/gnat.ads ada/g-hesorg.ads ada/g-htable.ads ada/hostparm.ads \ + ada/inline.ads ada/interfac.ads ada/itypes.ads ada/layout.ads \ + ada/lib.ads ada/lib.adb ada/lib-list.adb ada/lib-sort.adb \ + ada/lib-xref.ads ada/namet.ads ada/namet.adb ada/nlists.ads \ + ada/nlists.adb ada/nmake.ads ada/nmake.adb ada/opt.ads ada/output.ads \ + ada/restrict.ads ada/rident.ads ada/rtsfind.ads ada/scans.ads \ + ada/sem.ads ada/sem_aggr.ads ada/sem_attr.ads ada/sem_aux.ads \ + ada/sem_cat.ads ada/sem_ch13.ads ada/sem_ch4.ads ada/sem_ch6.ads \ + ada/sem_ch7.ads ada/sem_ch8.ads ada/sem_disp.ads ada/sem_dist.ads \ + ada/sem_elab.ads ada/sem_elim.ads ada/sem_eval.ads ada/sem_eval.adb \ + ada/sem_intr.ads ada/sem_mech.ads ada/sem_prag.ads ada/sem_res.ads \ + ada/sem_res.adb ada/sem_type.ads ada/sem_util.ads ada/sem_util.adb \ + ada/sem_warn.ads ada/sinfo.ads ada/sinfo.adb ada/sinfo-cn.ads \ + ada/sinput.ads ada/snames.ads ada/stand.ads ada/stringt.ads \ + ada/stringt.adb ada/style.ads ada/styleg.ads ada/styleg.adb \ ada/stylesw.ads ada/system.ads ada/s-exctab.ads ada/s-exctab.adb \ ada/s-htable.ads ada/s-imenne.ads ada/s-memory.ads ada/s-os_lib.ads \ ada/s-parame.ads ada/s-rident.ads ada/s-secsta.ads ada/s-soflin.ads \ diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index ead41e6c638..0eb84822b25 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -4610,19 +4610,18 @@ pragma Static_Elaboration_Desired; @end smallexample @noindent -This pragma is used to indicate the desire for objects declared in the library -unit to which the pragma applies to be initialized statically. This means that -if an object is initialized (either explicitly or by default initialization), -then the object's value can be determined at compile time and it requires no -code to initialize it. This generally allows the object to be allocated in -read-only data space. A warning is issued if an object or aggregate declared -at the top level of the package cannot be initialized statically. Additionally, -use of this pragma will suppress the generation of loops to initialize named -aggregates whose only choice is an others choice that specifies a component -value known at compile time, so that it can be allocated as static data. This -is limited to aggregates with a maximum of 100 components. (See also the -restriction No_Implicit_Loops, which supports static allocation for larger -aggregates.) +This pragma is used to indicate that the compiler should attempt to initialize +statically the objects declared in the library unit to which the pragma applies, +when these objects are initialized (explicitly or implicitly) by an aggregate. +In the absence of this pragma, aggregates in object declarations are expanded +into assignments and loops, even when the aggregate components are static +constants. When the aggregate is present the compiler builds a static expression +that requires no run-time code, so that the initialized object can be placed in +read-only data space. If the components are not static, or the aggregate has +more that 100 components, the compiler emits a warning that the pragma cannot +be obeyed. (See also the restriction No_Implicit_Loops, which supports static +construction of larger aggregates with static components that include an others +choice.) @node Pragma Stream_Convert @unnumberedsec Pragma Stream_Convert @@ -8097,7 +8096,7 @@ further details. @item Integer 32 bit signed @item Long_Integer -64 bit signed (Alpha OpenVMS only) +64 bit signed (on most 64 bit targets, depending on the C definition of long). 32 bit signed (all other targets) @item Long_Long_Integer 64 bit signed diff --git a/gcc/ada/make.adb b/gcc/ada/make.adb index d4c1ae729f8..cc8cb36a921 100644 --- a/gcc/ada/make.adb +++ b/gcc/ada/make.adb @@ -2933,13 +2933,15 @@ package body Make is end if; -- Make a deep copy of the arguments, because Normalize_Arguments - -- may deallocate some arguments. - -- Also strip target specific -mxxx switches in CodePeer mode. + -- may deallocate some arguments. Also strip target specific -mxxx + -- switches in CodePeer mode. declare - Index : Natural := Comp_Next; + Index : Natural; Last : constant Natural := Comp_Last; + begin + Index := Comp_Next; for J in Comp_Next .. Last loop declare Str : String renames Args (Arg_Index).all; diff --git a/gcc/ada/s-pooglo.ads b/gcc/ada/s-pooglo.ads index ae2e1af86fc..f8a440fb75a 100644 --- a/gcc/ada/s-pooglo.ads +++ b/gcc/ada/s-pooglo.ads @@ -53,7 +53,7 @@ package System.Pool_Global is type Unbounded_No_Reclaim_Pool is new System.Storage_Pools.Root_Storage_Pool with null record; - function Storage_Size + overriding function Storage_Size (Pool : Unbounded_No_Reclaim_Pool) return System.Storage_Elements.Storage_Count; diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index af65aea0a21..2a3b840cee1 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -5691,12 +5691,10 @@ package body Sem_Ch4 is declare U : constant Node_Id := Cunit (Get_Source_Unit (Candidate_Type)); - begin if Unit_Is_Visible (U) then Error_Msg_N -- CODEFIX ("use clause would make operation legal!", N); - else Error_Msg_NE -- CODEFIX ("add with_clause and use_clause for&!", @@ -6793,9 +6791,7 @@ package body Sem_Ch4 is -- to same. while Present (Hom) loop - if (Ekind (Hom) = E_Procedure - or else - Ekind (Hom) = E_Function) + if Ekind_In (Hom, E_Procedure, E_Function) and then not Is_Hidden (Hom) and then Scope (Hom) = Scope (Anc_Type) and then Present (First_Formal (Hom)) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 689a04f0980..b7cf370c65e 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -11553,8 +11553,7 @@ package body Sem_Util is -- Unit_In_Parent_Context -- ---------------------------- - function Unit_In_Parent_Context (Par_Unit : Node_Id) return Boolean - is + function Unit_In_Parent_Context (Par_Unit : Node_Id) return Boolean is begin if Unit_In_Context (Par_Unit) then return True; @@ -11585,8 +11584,8 @@ package body Sem_Util is -- looking for, eg. Text_IO which renames Ada.Text_IO. elsif - Renamed_Entity (Entity (Name (Clause))) - = Defining_Entity (Unit (U)) + Renamed_Entity (Entity (Name (Clause))) = + Defining_Entity (Unit (U)) then return True; end if; @@ -11594,11 +11593,13 @@ package body Sem_Util is Next (Clause); end loop; + return False; end Unit_In_Context; - begin + -- Start of processing for Unit_Is_Visible + begin -- The currrent unit is directly visible. if Curr = U then @@ -11614,7 +11615,6 @@ package body Sem_Util is (Nkind (Unit (Curr)) = N_Subprogram_Body and then not Acts_As_Spec (Unit (Curr))) then - if Unit_In_Context (Library_Unit (Curr)) then return True; end if; -- 2.30.2