From: Arnaud Charlet Date: Thu, 15 Mar 2012 08:44:33 +0000 (+0100) Subject: [multiple changes] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f307415a69fd804205368c98a57138d6753636ee;p=gcc.git [multiple changes] 2012-03-15 Ed Falis * s-vxwork-ppc.ads: Update copyright. 2012-03-15 Robert Dewar * sem_ch5.adb: Minor reformatting. 2012-03-15 Ed Schonberg * exp_ch3.adb (Expand_N_Object_Declaration): When rewriting the declaration of a class-wide object, retain the Ekind to prevent subsequent misuse of constants. 2012-03-15 Yannick Moy * gnat_rm.texi, gnat_ugn.texi: Minor correction of invariant terminology. 2012-03-15 Hristian Kirtchev * exp_util.adb (Initialized_By_Ctrl_Function): Add code to process the case when a function call appears in object.operation format. 2012-03-15 Ed Schonberg * sem_ch6.ads, sem_ch6.adb (Check_Subtype_Conformant): add Get_Inst formal, so that conformance within an instantiation follows renamings of formals. This is similar to what is already done in Check_Mode_conformant. * sem_ch12.adb (Vailidate_Access_Subprogram_Instance): check that formal and actual are subtype conformant. Previously only mode conformance was required. From-SVN: r185410 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 3eedfea9220..7835dc1a8e0 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,34 @@ +2012-03-15 Robert Dewar + + * sem_ch5.adb: Minor reformatting. + +2012-03-15 Ed Schonberg + + * exp_ch3.adb (Expand_N_Object_Declaration): When rewriting the + declaration of a class-wide object, retain the Ekind to prevent + subsequent misuse of constants. + +2012-03-15 Yannick Moy + + * gnat_rm.texi, gnat_ugn.texi: Minor correction of invariant + terminology. + +2012-03-15 Hristian Kirtchev + + * exp_util.adb (Initialized_By_Ctrl_Function): Add code to + process the case when a function call appears in object.operation + format. + +2012-03-15 Ed Schonberg + + * sem_ch6.ads, sem_ch6.adb (Check_Subtype_Conformant): add + Get_Inst formal, so that conformance within an instantiation + follows renamings of formals. This is similar to what is already + done in Check_Mode_conformant. + * sem_ch12.adb (Vailidate_Access_Subprogram_Instance): check that + formal and actual are subtype conformant. Previously only mode + conformance was required. + 2012-03-15 Robert Dewar * par-ch6.adb, einfo.ads, sem_eval.adb, sem_eval.ads, diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index 5035751e390..41fc6f36b8c 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -4829,10 +4829,12 @@ package body Exp_Ch3 is -- object renaming declaration ---because these identifiers -- were previously added by Enter_Name to the current scope. -- We must preserve the homonym chain of the source entity - -- as well. + -- as well. We must also preserve the kind of the entity, + -- which may be a constant. Set_Chars (Defining_Identifier (N), Chars (Def_Id)); Set_Homonym (Defining_Identifier (N), Homonym (Def_Id)); + Set_Ekind (Defining_Identifier (N), Ekind (Def_Id)); Exchange_Entities (Defining_Identifier (N), Def_Id); end; end if; diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 96498c2aa11..8ccf21634ec 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -3960,11 +3960,28 @@ package body Exp_Util is ---------------------------------- function Initialized_By_Ctrl_Function (N : Node_Id) return Boolean is - Expr : constant Node_Id := Original_Node (Expression (N)); + Expr : Node_Id := Original_Node (Expression (N)); + begin + if Nkind (Expr) = N_Function_Call then + Expr := Name (Expr); + end if; + + -- The function call may appear in object.operation format. Strip + -- all prefixes and retrieve the function name. + + loop + if Nkind (Expr) = N_Selected_Component then + Expr := Selector_Name (Expr); + else + exit; + end if; + end loop; + return - Nkind (Expr) = N_Function_Call - and then Needs_Finalization (Etype (Expr)); + Nkind_In (Expr, N_Expanded_Name, N_Identifier) + and then Ekind (Entity (Expr)) = E_Function + and then Needs_Finalization (Etype (Entity (Expr))); end Initialized_By_Ctrl_Function; ---------------------- diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index 82c61f4365c..701cc0f3551 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -3212,12 +3212,14 @@ pragma Invariant @end smallexample @noindent -This pragma provides exactly the same capabilities as the Invariant aspect -defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The Invariant -aspect is fully implemented in Ada 2012 mode, but since it requires the use -of the aspect syntax, which is not available exception in 2012 mode, it is -not possible to use the Invariant aspect in earlier versions of Ada. However -the Invariant pragma may be used in any version of Ada. +This pragma provides exactly the same capabilities as the Type_Invariant aspect +defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The +Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it +requires the use of the aspect syntax, which is not available except in 2012 +mode, it is not possible to use the Type_Invariant aspect in earlier versions +of Ada. However the Invariant pragma may be used in any version of Ada. Also +note that the aspect Invariant is a synonym in GNAT for the aspect +Type_Invariant, but there is no pragma Type_Invariant. The pragma must appear within the visible part of the package specification, after the type to which its Entity argument appears. As with the Invariant @@ -3233,7 +3235,7 @@ in Ada 2012 mode, but you cannot have both an invariant aspect and an invariant pragma for the same entity. For further details on the use of this pragma, see the Ada 2012 documentation -of the Invariant aspect. +of the Type_Invariant aspect. @node Pragma Keep_Names @unnumberedsec Pragma Keep_Names @@ -17378,7 +17380,7 @@ A complete description of the AIs may be found in @item @code{Favor_Top_Level} @tab -- GNAT @item @code{Inline} @tab @item @code{Inline_Always} @tab -- GNAT -@item @code{Invariant} @tab +@item @code{Invariant} @tab -- GNAT @item @code{Machine_Radix} @tab @item @code{No_Return} @tab @item @code{Object_Size} @tab -- GNAT @@ -17398,6 +17400,7 @@ A complete description of the AIs may be found in @item @code{Suppress} @tab @item @code{Suppress_Debug_Info} @tab -- GNAT @item @code{Test_Case} @tab -- GNAT +@item @code{Type_Invariant} @tab @item @code{Unchecked_Union} @tab @item @code{Universal_Aliasing} @tab -- GNAT @item @code{Unmodified} @tab -- GNAT @@ -18418,8 +18421,8 @@ A complete description of the AIs may be found in @noindent Type invariants may be specified for private types using the aspect notation. - Aspect @code{Invariant} may be specified for any private type, - @code{Invariant'Class} can + Aspect @code{Type_Invariant} may be specified for any private type, + @code{Type_Invariant'Class} can only be specified for tagged types, and is inherited by any descendent of the tagged types. The invariant is a boolean expression that is tested for being true in the following situations: conversions to the private type, object @@ -18427,6 +18430,8 @@ A complete description of the AIs may be found in [@b{in}] @b{out} parameters and returned result on return from any primitive operation for the type that is visible to a client. + GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and + @code{Invariant'Class} for @code{Type_Invariant'Class}. @noindent RM References: 13.03.03 (00) diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 1f73be75db5..08e064966ce 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -3090,7 +3090,7 @@ $ gnatlink ada_unit file1.o file2.o --LINK=./my_script @end smallexample If the @code{zero cost} exception mechanism is used, and the platform -doesn't support automatic registration of exception tables (e.g.@: HP-UX, +doesn't support automatic registration of exception tables (e.g.@: HP-UX or AIX), the simple approach described above will not work and a pre-linking phase using GNAT will be necessary. @@ -5442,8 +5442,8 @@ when such pragmas should be used. @emph{List inherited aspects.} @cindex @option{-gnatw.l} (@command{gcc}) This switch causes the compiler to list inherited invariants, -preconditions, and postconditions from Invariant'Class, Pre'Class, and -Post'Class aspects. Also list inherited subtype predicates. +preconditions, and postconditions from Type_Invariant'Class, Invariant'Class, +Pre'Class, and Post'Class aspects. Also list inherited subtype predicates. These messages are not automatically turned on by the use of @option{-gnatwa}. @item -gnatw.L diff --git a/gcc/ada/s-vxwork-ppc.ads b/gcc/ada/s-vxwork-ppc.ads index 85daa3f4270..2c25e2ce38a 100644 --- a/gcc/ada/s-vxwork-ppc.ads +++ b/gcc/ada/s-vxwork-ppc.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1998-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1998-2012, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 5acd7dc6a33..e873025c524 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -10433,7 +10433,11 @@ package body Sem_Ch12 is Abandon_Instantiation (Actual); end if; - Check_Mode_Conformant + -- In Ada 2012, actuals for access_to_subprograms must be subtype + -- conformant with the generic formal. Previous to AI05-288 only mode + -- conformance was required. + + Check_Subtype_Conformant (Designated_Type (Act_T), Designated_Type (A_Gen_T), Actual, diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 5a4e4c9acab..834d2f1b143 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -2087,10 +2087,9 @@ package body Sem_Ch5 is Check_Controlled_Array_Attribute (DS); - -- The index is not processed during the analysis of a - -- quantified expression but delayed to its expansion where the - -- quantified expression is transformed into an expression with - -- actions. + -- The index is not processed during analysis of a quantified + -- expression but delayed to its expansion where the quantified + -- expression is transformed into an expression with actions. if Nkind (Parent (N)) /= N_Quantified_Expression or else Operating_Mode = Check_Semantics diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 60d07c66edb..9b37f467350 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -7251,14 +7251,16 @@ package body Sem_Ch6 is (New_Id : Entity_Id; Old_Id : Entity_Id; Err_Loc : Node_Id := Empty; - Skip_Controlling_Formals : Boolean := False) + Skip_Controlling_Formals : Boolean := False; + Get_Inst : Boolean := False) is Result : Boolean; pragma Warnings (Off, Result); begin Check_Conformance (New_Id, Old_Id, Subtype_Conformant, True, Result, Err_Loc, - Skip_Controlling_Formals => Skip_Controlling_Formals); + Skip_Controlling_Formals => Skip_Controlling_Formals, + Get_Inst => Get_Inst); end Check_Subtype_Conformant; --------------------------- diff --git a/gcc/ada/sem_ch6.ads b/gcc/ada/sem_ch6.ads index 7b38792d071..42ea1e495a2 100644 --- a/gcc/ada/sem_ch6.ads +++ b/gcc/ada/sem_ch6.ads @@ -28,7 +28,7 @@ package Sem_Ch6 is type Conformance_Type is (Type_Conformant, Mode_Conformant, Subtype_Conformant, Fully_Conformant); - pragma Ordered (Conformance_Type); + -- pragma Ordered (Conformance_Type); -- Conformance type used in conformance checks between specs and bodies, -- and for overriding. The literals match the RM definitions of the -- corresponding terms. This is an ordered type, since each conformance @@ -141,7 +141,8 @@ package Sem_Ch6 is (New_Id : Entity_Id; Old_Id : Entity_Id; Err_Loc : Node_Id := Empty; - Skip_Controlling_Formals : Boolean := False); + Skip_Controlling_Formals : Boolean := False; + Get_Inst : Boolean := False); -- Check that two callable entities (subprograms, entries, literals) -- are subtype conformant, post error message if not (RM 6.3.1(16)), -- the flag being placed on the Err_Loc node if it is specified, and