[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Thu, 15 Mar 2012 08:44:33 +0000 (09:44 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 15 Mar 2012 08:44:33 +0000 (09:44 +0100)
2012-03-15  Ed Falis  <falis@adacore.com>

* s-vxwork-ppc.ads: Update copyright.

2012-03-15  Robert Dewar  <dewar@adacore.com>

* sem_ch5.adb: Minor reformatting.

2012-03-15  Ed Schonberg  <schonberg@adacore.com>

* 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  <moy@adacore.com>

* gnat_rm.texi, gnat_ugn.texi: Minor correction of invariant
terminology.

2012-03-15  Hristian Kirtchev  <kirtchev@adacore.com>

* 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  <schonberg@adacore.com>

* 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

gcc/ada/ChangeLog
gcc/ada/exp_ch3.adb
gcc/ada/exp_util.adb
gcc/ada/gnat_rm.texi
gcc/ada/gnat_ugn.texi
gcc/ada/s-vxwork-ppc.ads
gcc/ada/sem_ch12.adb
gcc/ada/sem_ch5.adb
gcc/ada/sem_ch6.adb
gcc/ada/sem_ch6.ads

index 3eedfea922036c5d948a0a9b036f0ed349dcbf12..7835dc1a8e09747b0e3bb39758b34cfac63bb6ec 100644 (file)
@@ -1,3 +1,34 @@
+2012-03-15  Robert Dewar  <dewar@adacore.com>
+
+       * sem_ch5.adb: Minor reformatting.
+
+2012-03-15  Ed Schonberg  <schonberg@adacore.com>
+
+       * 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  <moy@adacore.com>
+
+       * gnat_rm.texi, gnat_ugn.texi: Minor correction of invariant
+       terminology.
+
+2012-03-15  Hristian Kirtchev  <kirtchev@adacore.com>
+
+       * 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  <schonberg@adacore.com>
+
+       * 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  <dewar@adacore.com>
 
        * par-ch6.adb, einfo.ads, sem_eval.adb, sem_eval.ads,
index 5035751e3904e460fe2f7c85a46774126f6e944f..41fc6f36b8c6721dcb54996817fc0021c29a7094 100644 (file)
@@ -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;
index 96498c2aa111edb5e5b94647397c28c2755f0b9a..8ccf21634ec9e148fec7346de6c8fbfdb1ff7c06 100644 (file)
@@ -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;
 
       ----------------------
index 82c61f4365c6dbca6d03dae132f0d6bdd28962c5..701cc0f35513add319963a176c7568c7d1664f07 100644 (file)
@@ -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)
index 1f73be75db52b2e8ea468ba1d41f5a33e141fcd8..08e064966ce032eaf2e32e523b77cb324d6e76ae 100644 (file)
@@ -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
index 85daa3f42704a95e619df1607696667ce82049d8..2c25e2ce38a629dc85594717987545eaddb98d64 100644 (file)
@@ -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- --
index 5acd7dc6a3384118dc68a6608cc7adf96677fc32..e873025c524c9e5092feaab0588851c2a2ca3617 100644 (file)
@@ -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,
index 5a4e4c9acab6f3433c091865a8cda42aca66f996..834d2f1b1431d0884f34d0a67295d2a6cde250c7 100644 (file)
@@ -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
index 60d07c66edb0bf047a08cfecf1d1f6a5c98db275..9b37f467350155f1af21076f284ffbf2843c60a8 100644 (file)
@@ -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;
 
    ---------------------------
index 7b38792d071c27918f07d21cf34d84453cdabc38..42ea1e495a2b58968d0e7977e3ab873ff7d506e5 100644 (file)
@@ -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