]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Wed, 22 Jan 2014 16:53:24 +0000 (17:53 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 22 Jan 2014 16:53:24 +0000 (17:53 +0100)
2014-01-22  Thomas Quinot  <quinot@adacore.com>

* rtsfind.adb: Update comment.

2014-01-22  Hristian Kirtchev  <kirtchev@adacore.com>

* sem_aux.ads, sem_aux.adb (Is_Body): New routine.
* sem_ch3.adb (Analyze_Declarations): Add local variable
Body_Seen. Generate the spec of a late controlled
primitive body that is about to freeze its related type.
(Handle_Late_Controlled_Primitive): New routine.

2014-01-22  Robert Dewar  <dewar@adacore.com>

* a-stream.adb: Minor reformatting.

2014-01-22  Ed Schonberg  <schonberg@adacore.com>

* sem_ch8.adb (From_Actual_Package): Introduce a recursive
sub-procedure Declared_In_Actual to handle properly the visibility
of actuals in actual packages, that are themselves actuals to a
actual package of the current instance. This mimics properly the
visibility of formals of formal packages declared with a box,
within the corresponding generic unit.

2014-01-22  Robert Dewar  <dewar@adacore.com>

* checks.adb: Do not assume that a volatile variable is valid.

2014-01-22  Thomas Quinot  <quinot@adacore.com>

* g-catiio.ads (Image, Value): Clarify that these functions
operate in the local time zone.  Minor documentation update.

2014-01-22  Thomas Quinot  <quinot@adacore.com>

* csets.adb, csets.ads, opt.ads: Minor documentation fixes.

From-SVN: r206930

12 files changed:
gcc/ada/ChangeLog
gcc/ada/a-stream.adb
gcc/ada/checks.adb
gcc/ada/csets.adb
gcc/ada/csets.ads
gcc/ada/g-catiio.ads
gcc/ada/opt.ads
gcc/ada/rtsfind.adb
gcc/ada/sem_aux.adb
gcc/ada/sem_aux.ads
gcc/ada/sem_ch3.adb
gcc/ada/sem_ch8.adb

index eafe2bd30b4a80cfaff01989afbf1ba71b4ea104..e8c2d2d65378785567b2697fe9118ca894b5f93d 100644 (file)
@@ -1,3 +1,41 @@
+2014-01-22  Thomas Quinot  <quinot@adacore.com>
+
+       * rtsfind.adb: Update comment.
+
+2014-01-22  Hristian Kirtchev  <kirtchev@adacore.com>
+
+       * sem_aux.ads, sem_aux.adb (Is_Body): New routine.
+       * sem_ch3.adb (Analyze_Declarations): Add local variable
+       Body_Seen. Generate the spec of a late controlled
+       primitive body that is about to freeze its related type.
+       (Handle_Late_Controlled_Primitive): New routine.
+
+2014-01-22  Robert Dewar  <dewar@adacore.com>
+
+       * a-stream.adb: Minor reformatting.
+
+2014-01-22  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch8.adb (From_Actual_Package): Introduce a recursive
+       sub-procedure Declared_In_Actual to handle properly the visibility
+       of actuals in actual packages, that are themselves actuals to a
+       actual package of the current instance. This mimics properly the
+       visibility of formals of formal packages declared with a box,
+       within the corresponding generic unit.
+
+2014-01-22  Robert Dewar  <dewar@adacore.com>
+
+       * checks.adb: Do not assume that a volatile variable is valid.
+
+2014-01-22  Thomas Quinot  <quinot@adacore.com>
+
+       * g-catiio.ads (Image, Value): Clarify that these functions
+       operate in the local time zone.  Minor documentation update.
+
+2014-01-22  Thomas Quinot  <quinot@adacore.com>
+
+       * csets.adb, csets.ads, opt.ads: Minor documentation fixes.
+
 2014-01-22  Robert Dewar  <dewar@adacore.com>
 
        * sem_aux.adb, sem_aux.ads, sem_ch3.adb (Has_Unconstrained_Elements):
index 59f0a3ddbdbfea9c1694f93fdf39e44342caed9e..a22161d16da1801d6c5c20d93d7c4bb63edcd51d 100644 (file)
@@ -46,8 +46,10 @@ package body Ada.Streams is
       V : out Stream_Element_Array)
    is
       Last : Stream_Element_Offset;
+
    begin
       Read (S.all, V, Last);
+
       if Last /= V'Last then
          raise Ada.IO_Exceptions.End_Error;
       end if;
index ff015cc5c08430477a2cea8e917f2d0e9e6aedc1..cdbe34e3a90145d671eaf131ee88ad82a03c45f7 100644 (file)
@@ -5257,6 +5257,10 @@ package body Checks is
 
       elsif Is_Entity_Name (Expr)
         and then Is_Known_Valid (Entity (Expr))
+
+        --  Exclude volatile variables
+
+        and then not Treat_As_Volatile (Entity (Expr))
       then
          return True;
 
index 771affc3be0eee814ee0a6bf2a43d09f4ddb16c8..97b21fa2ea890fe693474a8536f0d59055e4342d 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2010, 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- --
@@ -464,11 +464,11 @@ package body Csets is
 
       others => ' ');
 
-   ---------------------------------------------------
-   -- Definitions for Latin-5 (Cyrillic ISO-8859-5) --
-   ---------------------------------------------------
+   -------------------------------------------
+   -- Definitions for Cyrillic (ISO-8859-5) --
+   -------------------------------------------
 
-   Fold_Latin_5 : constant Translate_Table := Translate_Table'(
+   Fold_Cyrillic : constant Translate_Table := Translate_Table'(
 
       'a' => 'A',  X_D0 => X_B0,  X_E0 => X_C0,
       'b' => 'B',  X_D1 => X_B1,  X_E1 => X_C1,  X_F1 => X_A1,
@@ -539,9 +539,9 @@ package body Csets is
 
       others => ' ');
 
-   ------------------------------------------
-   -- Definitions for Latin-9 (ISO 8859-9) --
-   ------------------------------------------
+   -------------------------------------------
+   -- Definitions for Latin-9 (ISO 8859-15) --
+   -------------------------------------------
 
    Fold_Latin_9 : constant Translate_Table := Translate_Table'(
 
@@ -1112,7 +1112,7 @@ package body Csets is
          Fold_Upper := Fold_Latin_4;
 
       elsif Identifier_Character_Set = '5' then
-         Fold_Upper := Fold_Latin_5;
+         Fold_Upper := Fold_Cyrillic;
 
       elsif Identifier_Character_Set = 'p' then
          Fold_Upper := Fold_IBM_PC_437;
index 2f40e36aa8cdc393171913e346cfa1e8f8d159bd..bae234760add4413a2e0fec7f67705816c99c404 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          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- --
@@ -60,14 +60,14 @@ package Csets is
    --  The character set in use is specified by the value stored in
    --  Opt.Identifier_Character_Set, which has the following settings:
 
-   --    '1'  Latin-1 (ISO-8859-1)
-   --    '2'  Latin-2 (ISO-8859-2)
-   --    '3'  Latin-3 (ISO-8859-3)
-   --    '4'  Latin-4 (ISO-8859-4)
-   --    '5'  Latin-5 (ISO-8859-5, Cyrillic)
-   --    'p'  IBM PC  (code page 437)
-   --    '8'  IBM PC  (code page 850)
-   --    '9'  Latin-9 (ISO-9959-9)
+   --    '1'  Latin-1  (ISO-8859-1)
+   --    '2'  Latin-2  (ISO-8859-2)
+   --    '3'  Latin-3  (ISO-8859-3)
+   --    '4'  Latin-4  (ISO-8859-4)
+   --    '5'  Cyrillic (ISO-8859-5)
+   --    'p'  IBM PC   (code page 437)
+   --    '8'  IBM PC   (code page 850)
+   --    '9'  Latin-9  (ISO-8859-15)
    --    'f'  Full upper set (all distinct)
    --    'n'  No upper characters (Ada/83 rules)
    --    'w'  Latin-1 plus wide characters also allowed
index 523b597e79ef6efc044403409fd226bad73647a5..fa8d802eb67a2fab21837985428338c312de43de 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---                     Copyright (C) 1999-2010, AdaCore                     --
+--                     Copyright (C) 1999-2013, AdaCore                     --
 --                                                                          --
 -- 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- --
@@ -111,11 +111,13 @@ package GNAT.Calendar.Time_IO is
    function Image
      (Date    : Ada.Calendar.Time;
       Picture : Picture_String) return String;
-   --  Return Date as a string with format Picture. Raise Picture_Error if
-   --  picture string is null or has an incorrect format.
+   --  Return Date, as interpreted in the current local time zone, as a string
+   --  with format Picture. Raise Picture_Error if picture string is null or
+   --  has an incorrect format.
 
    function Value (Date : String) return Ada.Calendar.Time;
-   --  Parse the string Date and return its equivalent as a Time value. The
+   --  Parse the string Date, interpreted as a time representation in the
+   --  current local time zone, and return the corresponding Time value. The
    --  following time format is supported:
    --
    --     hh:mm:ss             - Date is the current date
index f6177eb52ee0a4aa0250f323a6bb9cd6599a9cf0..8f0fa52ae2c3fed042685425d1b1351b32f1884d 100644 (file)
@@ -702,12 +702,12 @@ package Opt is
    --  GNAT
    --  This variable indicates the character set to be used for identifiers.
    --  The possible settings are:
-   --    '1'  Latin-5 (ISO-8859-1)
-   --    '2'  Latin-5 (ISO-8859-2)
-   --    '3'  Latin-5 (ISO-8859-3)
-   --    '4'  Latin-5 (ISO-8859-4)
-   --    '5'  Latin-5 (ISO-8859-5, Cyrillic)
-   --    '9'  Latin-5 (ISO-8859-9)
+   --    '1'  Latin-1 (ISO-8859-1)
+   --    '2'  Latin-2 (ISO-8859-2)
+   --    '3'  Latin-3 (ISO-8859-3)
+   --    '4'  Latin-4 (ISO-8859-4)
+   --    '5'  Latin-Cyrillic (ISO-8859-5)
+   --    '9'  Latin-9 (ISO-8859-15)
    --    'p'  PC (US, IBM page 437)
    --    '8'  PC (European, IBM page 850)
    --    'f'  Full upper set (all distinct)
index 2b25c9fdd9551949003f42579a200f2206ec7aa5..9eeaa331f627cfd80e5b5eb30ac7959e80f8ea82 100644 (file)
@@ -233,8 +233,8 @@ package body Rtsfind is
 
            --  If the entity being referenced is defined in the current scope,
            --  using it is always fine as such usage can never introduce any
-           --  dependency on an additional unit.
-           --  Why do we need to do this test ???
+           --  dependency on an additional unit. The presence of this test
+           --  helps generating meaningful error messages for CRT violations.
 
            and then Scope (Eid) /= Current_Scope
          then
index 5098d74f8d1aa0686e1573f4ca441b3dbb05ea25..84547c2fb5548af27e4cfbb57b38fc8d7f639fa2 100644 (file)
@@ -698,6 +698,21 @@ package body Sem_Aux is
       Obsolescent_Warnings.Init;
    end Initialize;
 
+   -------------
+   -- Is_Body --
+   -------------
+
+   function Is_Body (N : Node_Id) return Boolean is
+   begin
+      return
+        Nkind (N) in N_Body_Stub
+          or else Nkind_In (N, N_Entry_Body,
+                               N_Package_Body,
+                               N_Protected_Body,
+                               N_Subprogram_Body,
+                               N_Task_Body);
+   end Is_Body;
+
    ---------------------
    -- Is_By_Copy_Type --
    ---------------------
index ed218d712a9318f823e9791865e958aae2ac7f6a..9f574ece1d3616cfe612d5ddf6851c18f5251d3f 100644 (file)
@@ -259,6 +259,9 @@ package Sem_Aux is
    --  or subtype. This is true if Suppress_Initialization is set either for
    --  the subtype itself, or for the corresponding base type.
 
+   function Is_Body (N : Node_Id) return Boolean;
+   --  Determine whether an arbitrary node denotes a body
+
    function Is_By_Copy_Type (Ent : Entity_Id) return Boolean;
    --  Ent is any entity. Returns True if Ent is a type entity where the type
    --  is required to be passed by copy, as defined in (RM 6.2(3)).
index 671776ad217e4153fcf6af851fffbd3b4c9c49bd..58bac3570ede820acbe4f7257133e26f63defe5e 100644 (file)
@@ -2075,6 +2075,12 @@ package body Sem_Ch3 is
       --  (They have the sloc of the label as found in the source, and that
       --  is ahead of the current declarative part).
 
+      procedure Handle_Late_Controlled_Primitive (Body_Decl : Node_Id);
+      --  Determine whether Body_Decl denotes the body of a late controlled
+      --  primitive (either Initialize, Adjust or Finalize). If this is the
+      --  case, add a proper spec if the body lacks one. The spec is inserted
+      --  before Body_Decl and immedately analyzed.
+
       procedure Remove_Visible_Refinements (Spec_Id : Entity_Id);
       --  Spec_Id is the entity of a package that may define abstract states.
       --  If the states have visible refinement, remove the visibility of each
@@ -2099,6 +2105,70 @@ package body Sem_Ch3 is
          end loop;
       end Adjust_Decl;
 
+      --------------------------------------
+      -- Handle_Late_Controlled_Primitive --
+      --------------------------------------
+
+      procedure Handle_Late_Controlled_Primitive (Body_Decl : Node_Id) is
+         Body_Spec : constant Node_Id    := Specification (Body_Decl);
+         Body_Id   : constant Entity_Id  := Defining_Entity (Body_Spec);
+         Loc       : constant Source_Ptr := Sloc (Body_Id);
+         Params    : constant List_Id    :=
+                       Parameter_Specifications (Body_Spec);
+         Spec      : Node_Id;
+         Spec_Id   : Entity_Id;
+
+         Dummy : Entity_Id;
+         pragma Unreferenced (Dummy);
+         --  A dummy variable used to capture the unused result of subprogram
+         --  spec analysis.
+
+      begin
+         --  Consider only procedure bodies whose name matches one of type
+         --  [Limited_]Controlled's primitives.
+
+         if Nkind (Body_Spec) /= N_Procedure_Specification
+           or else not Nam_In (Chars (Body_Id), Name_Adjust,
+                                                Name_Finalize,
+                                                Name_Initialize)
+         then
+            return;
+
+         --  A controlled primitive must have exactly one formal whose type
+         --  derives from [Limited_]Controlled.
+
+         elsif List_Length (Params) /= 1 then
+            return;
+         end if;
+
+         Dummy := Analyze_Subprogram_Specification (Body_Spec);
+
+         if not Is_Controlled (Etype (Defining_Entity (First (Params)))) then
+            return;
+         end if;
+
+         Spec_Id := Find_Corresponding_Spec (Body_Decl, Post_Error => False);
+
+         --  The body has a matching spec, therefore it cannot be a late
+         --  primitive.
+
+         if Present (Spec_Id) then
+            return;
+         end if;
+
+         --  At this point the body is known to be a late controlled primitive.
+         --  Generate a matching spec and insert it before the body.
+
+         Spec := New_Copy_Tree (Body_Spec);
+
+         Set_Defining_Unit_Name
+           (Spec, Make_Defining_Identifier (Loc, Chars (Body_Id)));
+
+         Insert_Before_And_Analyze (Body_Decl,
+           Make_Subprogram_Declaration (Loc,
+             Specification => Spec));
+      end Handle_Late_Controlled_Primitive;
+
       --------------------------------
       -- Remove_Visible_Refinements --
       --------------------------------
@@ -2200,6 +2270,9 @@ package body Sem_Ch3 is
       Prag        : Node_Id;
       Spec_Id     : Entity_Id;
 
+      Body_Seen : Boolean := False;
+      --  Flag set when the first body [stub] is encountered
+
       In_Package_Body : Boolean := False;
       --  Flag set when the current declaration list belongs to a package body
 
@@ -2294,15 +2367,28 @@ package body Sem_Ch3 is
          --  care to attach the bodies at a proper place in the tree so as to
          --  not cause unwanted freezing at that point.
 
-         elsif not Analyzed (Next_Decl)
-           and then (Nkind_In (Next_Decl, N_Subprogram_Body,
-                                          N_Entry_Body,
-                                          N_Package_Body,
-                                          N_Protected_Body,
-                                          N_Task_Body)
-                       or else
-                     Nkind (Next_Decl) in N_Body_Stub)
-         then
+         elsif not Analyzed (Next_Decl) and then Is_Body (Next_Decl) then
+
+            --  When a controlled type is frozen, the expander generates stream
+            --  and controlled type support routines. If the freeze is caused
+            --  by the stand alone body of Initialize, Adjust and Finalize, the
+            --  expander will end up using the wrong version of these routines
+            --  as the body has not been processed yet. To remedy this, detect
+            --  a late controlled primitive and create a proper spec for it.
+            --  This ensures that the primitive will override its inherited
+            --  counterpart before the freeze takes place.
+
+            --  ??? a cleaner approach may be possible and/or this solution
+            --  could be extended to general-purpose late primitives, TBD.
+
+            if not Body_Seen and then not Is_Body (Decl) then
+               Body_Seen := True;
+
+               if Nkind (Next_Decl) = N_Subprogram_Body then
+                  Handle_Late_Controlled_Primitive (Next_Decl);
+               end if;
+            end if;
+
             Adjust_Decl;
             Freeze_All (Freeze_From, Decl);
             Freeze_From := Last_Entity (Current_Scope);
index b44d4e0f94a80f1c7ae3bd465eee70f79bead1e2..c6e23b586d55cbddd017ea18523b6e15b42a39b1 100644 (file)
@@ -4168,10 +4168,11 @@ package body Sem_Ch8 is
       --  generate the precise error message.
 
       function From_Actual_Package (E : Entity_Id) return Boolean;
-      --  Returns true if the entity is declared in a package that is
+      --  Returns true if the entity is an actual for a package that is itself
       --  an actual for a formal package of the current instance. Such an
-      --  entity requires special handling because it may be use-visible
-      --  but hides directly visible entities defined outside the instance.
+      --  entity requires special handling because it may be use-visible but
+      --  hides directly visible entities defined outside the instance, because
+      --  the corresponding formal did so in the generic.
 
       function Is_Actual_Parameter return Boolean;
       --  This function checks if the node N is an identifier that is an actual
@@ -4214,11 +4215,57 @@ package body Sem_Ch8 is
 
       function From_Actual_Package (E : Entity_Id) return Boolean is
          Scop : constant Entity_Id := Scope (E);
-         Act  : Entity_Id;
+         --  Declared scope of candidate entity
+
+         Act : Entity_Id;
+
+         function Declared_In_Actual (Pack : Entity_Id) return Boolean;
+         --  Recursive function that does the work and examines actuals of
+         --  actual packages of current instance.
+
+         ------------------------
+         -- Declared_In_Actual --
+         ------------------------
+
+         function Declared_In_Actual (Pack : Entity_Id) return Boolean is
+            Act : Entity_Id;
+
+         begin
+            if No (Associated_Formal_Package (Pack)) then
+               return False;
+
+            else
+               Act := First_Entity (Pack);
+               while Present (Act) loop
+                  if Renamed_Object (Pack) = Scop then
+                     return True;
+
+                  --  Check for end of list of actuals.
+
+                  elsif Ekind (Act) = E_Package
+                    and then Renamed_Object (Act) = Pack
+                  then
+                     return False;
+
+                  elsif Ekind (Act) = E_Package
+                    and then Declared_In_Actual (Act)
+                  then
+                     return True;
+                  end if;
+
+                  Next_Entity (Act);
+               end loop;
+
+               return False;
+            end if;
+         end Declared_In_Actual;
+
+      --  Start of processing for From_Actual_Package
 
       begin
          if not In_Instance then
             return False;
+
          else
             Inst := Current_Scope;
             while Present (Inst)
@@ -4234,27 +4281,13 @@ package body Sem_Ch8 is
 
             Act := First_Entity (Inst);
             while Present (Act) loop
-               if Ekind (Act) = E_Package then
-
-                  --  Check for end of actuals list
-
-                  if Renamed_Object (Act) = Inst then
-                     return False;
-
-                  elsif Present (Associated_Formal_Package (Act))
-                    and then Renamed_Object (Act) = Scop
-                  then
-                     --  Entity comes from (instance of) formal package
-
-                     return True;
-
-                  else
-                     Next_Entity (Act);
-                  end if;
-
-               else
-                  Next_Entity (Act);
+               if Ekind (Act) = E_Package
+                 and then Declared_In_Actual (Act)
+               then
+                  return True;
                end if;
+
+               Next_Entity (Act);
             end loop;
 
             return False;