[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Fri, 17 Feb 2012 13:56:55 +0000 (14:56 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 17 Feb 2012 13:56:55 +0000 (14:56 +0100)
2012-02-17  Robert Dewar  <dewar@adacore.com>

* sem_dim.adb, sem_dim.ads, s-tasren.adb, prj.adb, prj.ads, freeze.adb,
sem_res.adb, exp_ch4.adb, sinput.adb, sinput.ads, exp_aggr.adb,
exp_intr.adb, s-os_lib.adb: Minor reformatting.

2012-02-17  Ed Schonberg  <schonberg@adacore.com>

* sem_ch6.adb (Is_Non_Overriding_Operation): Add warning if the
old operation is abstract, the relevant type is not abstract,
and the new subprogram fails to override.

From-SVN: r184336

15 files changed:
gcc/ada/ChangeLog
gcc/ada/exp_aggr.adb
gcc/ada/exp_ch4.adb
gcc/ada/exp_intr.adb
gcc/ada/freeze.adb
gcc/ada/prj.adb
gcc/ada/prj.ads
gcc/ada/s-os_lib.adb
gcc/ada/s-tasren.adb
gcc/ada/sem_ch6.adb
gcc/ada/sem_dim.adb
gcc/ada/sem_dim.ads
gcc/ada/sem_res.adb
gcc/ada/sinput.adb
gcc/ada/sinput.ads

index 7c57446c60bede5ec7d49dcf0cbfe44bebdae3fc..f500453fbd896e9f2c99d74f3d63926635ca278b 100644 (file)
@@ -1,3 +1,15 @@
+2012-02-17  Robert Dewar  <dewar@adacore.com>
+
+       * sem_dim.adb, sem_dim.ads, s-tasren.adb, prj.adb, prj.ads, freeze.adb,
+       sem_res.adb, exp_ch4.adb, sinput.adb, sinput.ads, exp_aggr.adb,
+       exp_intr.adb, s-os_lib.adb: Minor reformatting.
+
+2012-02-17  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch6.adb (Is_Non_Overriding_Operation): Add warning if the
+       old operation is abstract, the relevant type is not abstract,
+       and the new subprogram fails to override.
+
 2012-02-15  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/trans.c (Identifier_to_gnu): Move block retrieving the
index 10cb04c1628d7aff9d6b3feb47a175b4e4d0428c..8cfbe3bac594e1d46007c209ca576337554a4fed 100644 (file)
@@ -5157,9 +5157,9 @@ package body Exp_Aggr is
       -- Compile_Time_Known_Composite_Value --
       ----------------------------------------
 
-      function Compile_Time_Known_Composite_Value (N : Node_Id) return Boolean
+      function Compile_Time_Known_Composite_Value
+        (N : Node_Id) return Boolean
       is
-
       begin
          --  If we have an entity name, then see if it is the name of a
          --  constant and if so, test the corresponding constant value.
@@ -5168,15 +5168,14 @@ package body Exp_Aggr is
             declare
                E : constant Entity_Id := Entity (N);
                V : Node_Id;
-
             begin
                if Ekind (E) /= E_Constant then
                   return False;
+               else
+                  V := Constant_Value (E);
+                  return Present (V)
+                    and then Compile_Time_Known_Composite_Value (V);
                end if;
-
-               V := Constant_Value (E);
-               return Present (V)
-                 and then Compile_Time_Known_Composite_Value (V);
             end;
 
          --  We have a value, see if it is compile time known
index 53529ddbb040708dc584226a8c8a1742eea7c395..d90b54c1e3ec1a0bc247d1ad339157323384bdaa 100644 (file)
@@ -3572,21 +3572,20 @@ package body Exp_Ch4 is
                              (Etype (Pool), Name_Simple_Storage_Pool_Type))
             then
                declare
-                  Alloc_Op  : Entity_Id := Get_Name_Entity_Id (Name_Allocate);
                   Pool_Type : constant Entity_Id := Base_Type (Etype (Pool));
-
+                  Alloc_Op  : Entity_Id;
                begin
+                  Alloc_Op := Get_Name_Entity_Id (Name_Allocate);
                   while Present (Alloc_Op) loop
                      if Scope (Alloc_Op) = Scope (Pool_Type)
                        and then Present (First_Formal (Alloc_Op))
                        and then Etype (First_Formal (Alloc_Op)) = Pool_Type
                      then
                         Set_Procedure_To_Call (N, Alloc_Op);
-
                         exit;
+                     else
+                        Alloc_Op := Homonym (Alloc_Op);
                      end if;
-
-                     Alloc_Op := Homonym (Alloc_Op);
                   end loop;
                end;
 
index ad7f253244ce35140d731af1cf4aa81ea4de2c37..5df8b3718637bbf47b850ff4f4d64d3bcc7585b5 100644 (file)
@@ -1094,21 +1094,20 @@ package body Exp_Intr is
                           (Etype (Pool), Name_Simple_Storage_Pool_Type))
          then
             declare
-               Dealloc_Op  : Entity_Id := Get_Name_Entity_Id (Name_Deallocate);
-               Pool_Type : constant Entity_Id := Base_Type (Etype (Pool));
-
+               Pool_Type  : constant Entity_Id := Base_Type (Etype (Pool));
+               Dealloc_Op : Entity_Id;
             begin
+               Dealloc_Op := Get_Name_Entity_Id (Name_Deallocate);
                while Present (Dealloc_Op) loop
                   if Scope (Dealloc_Op) = Scope (Pool_Type)
                     and then Present (First_Formal (Dealloc_Op))
                     and then Etype (First_Formal (Dealloc_Op)) = Pool_Type
                   then
                      Set_Procedure_To_Call (Free_Node, Dealloc_Op);
-
                      exit;
+                  else
+                     Dealloc_Op := Homonym (Dealloc_Op);
                   end if;
-
-                  Dealloc_Op := Homonym (Dealloc_Op);
                end loop;
             end;
 
@@ -1140,8 +1139,8 @@ package body Exp_Intr is
          if Is_Class_Wide_Type (Desig_T)
            or else
             (Is_Array_Type (Desig_T)
-               and then not Is_Constrained (Desig_T)
-               and then Is_Packed (Desig_T))
+              and then not Is_Constrained (Desig_T)
+              and then Is_Packed (Desig_T))
          then
             declare
                Deref    : constant Node_Id :=
index a34517bb5be0535f96f2b127433a0bb46ce94143..6325b4521c308bc9903468ad163f88e85f80870c 100644 (file)
@@ -4114,7 +4114,6 @@ package body Freeze is
             if Present (Get_Rep_Pragma (E, Name_Simple_Storage_Pool_Type))
               and then (Is_Base_Type (E) or else Has_Private_Declaration (E))
             then
-
                --  If the type is marked Has_Private_Declaration, then this is
                --  a full type for a private type that was specified with the
                --  pragma Simple_Storage_Pool_Type, and here we ensure that the
@@ -4127,7 +4126,6 @@ package body Freeze is
                     and then not Is_Private_Type (E)
                   then
                      Error_Msg_Name_1 := Name_Simple_Storage_Pool_Type;
-
                      Error_Msg_N
                        ("pragma% can only apply to full type that is an " &
                         "explicitly limited type", E);
@@ -4197,6 +4195,7 @@ package body Freeze is
                      end if;
 
                      if Etype (Pool_Op_Formal) /= Expected_Type then
+
                         --  If the pool type was expected for this formal, then
                         --  this will not be considered a candidate operation
                         --  for the simple pool, so we unset OK_Formal so that
@@ -4243,8 +4242,8 @@ package body Freeze is
                   begin
                      pragma Assert
                        (Op_Name = Name_Allocate
-                          or else Op_Name = Name_Deallocate
-                          or else Op_Name = Name_Storage_Size);
+                         or else Op_Name = Name_Deallocate
+                         or else Op_Name = Name_Storage_Size);
 
                      Error_Msg_Name_1 := Op_Name;
 
@@ -4270,7 +4269,6 @@ package body Freeze is
                               Validate_Simple_Pool_Op_Formal
                                 (Op, Formal, E_In_Parameter, Pool_Type,
                                  "Pool", Is_OK);
-
                            else
                               Validate_Simple_Pool_Op_Formal
                                 (Op, Formal, E_In_Out_Parameter, Pool_Type,
@@ -4295,7 +4293,6 @@ package body Freeze is
                               Validate_Simple_Pool_Op_Formal
                                 (Op, Formal, E_Out_Parameter,
                                  Address_Type, "Storage_Address", Is_OK);
-
                            elsif Op_Name = Name_Deallocate then
                               Validate_Simple_Pool_Op_Formal
                                 (Op, Formal, E_In_Parameter,
@@ -4310,7 +4307,6 @@ package body Freeze is
                               Validate_Simple_Pool_Op_Formal
                                 (Op, Formal, E_In_Parameter,
                                  Stg_Cnt_Type, "Size_In_Storage_Units", Is_OK);
-
                               Validate_Simple_Pool_Op_Formal
                                 (Op, Formal, E_In_Parameter,
                                  Stg_Cnt_Type, "Alignment", Is_OK);
@@ -4338,6 +4334,7 @@ package body Freeze is
                                      "storage pool type", Pool_Type);
 
                      elsif Present (Found_Op) then
+
                         --  Simple pool operations can't be abstract
 
                         if Is_Abstract_Subprogram (Found_Op) then
@@ -4373,9 +4370,7 @@ package body Freeze is
 
                begin
                   Validate_Simple_Pool_Operation (Name_Allocate);
-
                   Validate_Simple_Pool_Operation (Name_Deallocate);
-
                   Validate_Simple_Pool_Operation (Name_Storage_Size);
                end Validate_Simple_Pool_Ops;
             end if;
index f9cc7398cc0a1e50990bab6e2631fd6dfe47515d..c8c5958aad5e4fbfe21177164ae050a2e8187e82 100644 (file)
@@ -1893,6 +1893,7 @@ package body Prj is
       is
          Agg : Aggregated_Project_List;
          Ctx : Project_Context;
+
       begin
          Action (Project, Tree, Context);
 
@@ -1901,8 +1902,7 @@ package body Prj is
               (In_Aggregate_Lib      => True,
                From_Encapsulated_Lib =>
                  Context.From_Encapsulated_Lib
-                   or else
-                 Project.Standalone_Library = Encapsulated);
+                   or else Project.Standalone_Library = Encapsulated);
 
             Agg := Project.Aggregated_Projects;
             while Agg /= null loop
@@ -1912,6 +1912,8 @@ package body Prj is
          end if;
       end Recursive_Process;
 
+   --  Start of processing for For_Project_And_Aggregated_Context
+
    begin
       Recursive_Process
         (Root_Project, Root_Tree, Project_Context'(False, False));
index 44aa94d8151767c535688a20d52fb7c0f208ea73..877d1b59b390237eb024fb80ee501597895e623d 100644 (file)
@@ -1621,7 +1621,7 @@ package Prj is
       With_State         : in out State;
       Include_Aggregated : Boolean := True;
       Imported_First     : Boolean := False);
-   --  As above but with an associated context
+   --  As for For_Every_Project_Imported but with an associated context
 
    generic
       with procedure Action
@@ -1631,7 +1631,7 @@ package Prj is
    procedure For_Project_And_Aggregated_Context
      (Root_Project : Project_Id;
       Root_Tree    : Project_Tree_Ref);
-   --  As above but with an associated context
+   --  As for For_Project_And_Aggregated but with an associated context
 
    function Extend_Name
      (File        : File_Name_Type;
index 993cc8c5959305fc3f93bc1bffd8bb885c62f428..100b174bf2c32c46cff11b3558437c6d85ae8d20 100755 (executable)
@@ -1695,12 +1695,11 @@ package body System.OS_Lib is
                else
                   Res (J) := Arg (K);
                end if;
-
             end loop;
 
             if Quote_Needed then
 
-               --  If null terminated string, put the quote before
+               --  Case of null terminated string
 
                if Res (J) = ASCII.NUL then
 
@@ -1711,7 +1710,7 @@ package body System.OS_Lib is
                      J := J + 1;
                   end if;
 
-                  --  Then adds the quote and the NUL character
+                  --  Put a quote just before the null at the end
 
                   Res (J) := '"';
                   J := J + 1;
index 2d9baadc794b99e7af1de51975164ea48a5acbf1..16873e85e01bf7496e8f3b3c5e92fab95f327b21 100644 (file)
@@ -110,8 +110,8 @@ package body System.Tasking.Rendezvous is
    procedure Local_Complete_Rendezvous (Ex : Ada.Exceptions.Exception_Id);
    --  Internal version of Complete_Rendezvous, used to implement
    --  Complete_Rendezvous and Exceptional_Complete_Rendezvous.
-   --  Should be called holding no locks, generally with abort not yet
-   --  deferred.
+   --  Should be called holding no locks, generally with abort
+   --  not yet deferred.
 
    procedure Boost_Priority (Call : Entry_Call_Link; Acceptor : Task_Id);
    pragma Inline (Boost_Priority);
@@ -538,7 +538,7 @@ package body System.Tasking.Rendezvous is
       Called_PO              : STPE.Protection_Entries_Access;
       Acceptor_Prev_Priority : Integer;
 
-      Ceiling_Violation  : Boolean;
+      Ceiling_Violation : Boolean;
 
       use type Ada.Exceptions.Exception_Id;
       procedure Transfer_Occurrence
index eec427a0ddf6d2a3075eeb8aa18442fcb7eebc6b..8df63dc958a1367aa0e3628d953c4c193cc7d2f0 100644 (file)
@@ -188,9 +188,9 @@ package body Sem_Ch6 is
       New_E  : Entity_Id) return Boolean;
    --  Enforce the rule given in 12.3(18): a private operation in an instance
    --  overrides an inherited operation only if the corresponding operation
-   --  was overriding in the generic. This can happen for primitive operations
-   --  of types derived (in the generic unit) from formal private or formal
-   --  derived types.
+   --  was overriding in the generic. This needs to be checked for primitive
+   --  operations of types derived (in the generic unit) from formal private
+   --  or formal derived types.
 
    procedure Make_Inequality_Operator (S : Entity_Id);
    --  Create the declaration for an inequality operator that is implicitly
@@ -7844,6 +7844,22 @@ package body Sem_Ch6 is
                --  If no match found, then the new subprogram does not
                --  override in the generic (nor in the instance).
 
+               --  If the type in question is not abstract, and the subprogram
+               --  is, this will be an error if the new operation is in the
+               --  private part of the instance. Emit a warning now, which will
+               --  make the subsequent error message easier to understand.
+
+               if not Is_Abstract_Type (F_Typ)
+                 and then Is_Abstract_Subprogram (Prev_E)
+                 and then In_Private_Part (Current_Scope)
+               then
+                  Error_Msg_Node_2 := F_Typ;
+                  Error_Msg_NE
+                    ("private operation& in generic unit does not override " &
+                     "any primitive operation of& (RM 12.3 (18))?",
+                     New_E, New_E);
+               end if;
+
                return True;
             end;
          end if;
index bb81a470b66c15dacd125e34f47da74d83f1728c..d28e23f57c6dc341777f851668469c5792be7962 100644 (file)
@@ -2247,7 +2247,8 @@ package body Sem_Dim is
                   Package_Name := Chars (Ent);
 
                   if Package_Name = Name_Float_IO
-                    or else Package_Name = Name_Integer_IO
+                       or else
+                     Package_Name = Name_Integer_IO
                   then
                      return Chars (Scope (Ent)) = Name_Dim;
                   end if;
@@ -2512,10 +2513,13 @@ package body Sem_Dim is
       if Is_Entity_Name (Gen_Id) then
          Ent := Entity (Gen_Id);
 
+         --  Is it really OK just to test names ??? why???
+
          if Is_Library_Level_Entity (Ent)
            and then
             (Chars (Ent) = Name_Float_IO
-               or else Chars (Ent) = Name_Integer_IO)
+               or else
+             Chars (Ent) = Name_Integer_IO)
          then
             return Chars (Scope (Ent)) = Name_Dim;
          end if;
index b32322b902737a068a59f3aa9de3c169c686ed05..b339ff6090e12c577d0c0378c00509ecbd415e77 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---           Copyright (C) 2011-2012, Free Software Foundation, Inc.        --
+--          Copyright (C) 2011-2012, 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- --
index 3d693e033bc26eb8d6191ec2182b62e825f9727c..1b2eef0a90db2eeb9a6febcd46f77abec1477173 100644 (file)
@@ -4239,8 +4239,8 @@ package body Sem_Res is
            and then Nkind (Expression (E)) = N_Function_Call
          then
             declare
-               Pool : constant Entity_Id
-                        := Associated_Storage_Pool (Root_Type (Typ));
+               Pool : constant Entity_Id :=
+                        Associated_Storage_Pool (Root_Type (Typ));
             begin
                if Present (Pool)
                  and then
index b31e041670a912e35fa608394a5762cfa89fd7ab..5e1ac44b617340cfe3c5c8c8a8575e2707691379 100644 (file)
@@ -250,6 +250,10 @@ package body Sinput is
       return Name_Buffer (1 .. Name_Len);
    end Build_Location_String;
 
+   -------------------
+   -- Check_For_BOM --
+   -------------------
+
    procedure Check_For_BOM is
       BOM : BOM_Kind;
       Len : Natural;
index 816fa72d0947a8a1dcdcedc730398010559ba017..32aab9d3966e69eb47df597940c530774d7432c2 100644 (file)
@@ -544,6 +544,14 @@ package Sinput is
    --  Functional form returning a string, which does not include a terminating
    --  null character. The contents of Name_Buffer is destroyed.
 
+   procedure Check_For_BOM;
+   --  Check if the current source starts with a BOM. Scan_Ptr needs to be at
+   --  the start of the current source. If the current source starts with a
+   --  recognized BOM, then some flags such as Wide_Character_Encoding_Method
+   --  are set accordingly, and the Scan_Ptr on return points past this BOM.
+   --  An error message is output and Unrecoverable_Error raised if a non-
+   --  recognized BOM is detected. The call has no effect if no BOM is found.
+
    function Get_Column_Number (P : Source_Ptr) return Column_Number;
    --  The ones-origin column number of the specified Source_Ptr value is
    --  determined and returned. Tab characters if present are assumed to
@@ -712,16 +720,6 @@ package Sinput is
    --  Writes out internal tables to current tree file using the relevant
    --  Table.Tree_Write routines.
 
-   procedure Check_For_BOM;
-   --  Check if the current source starts with a BOM. Scan_Ptr needs to be at
-   --  the start of the current source.
-   --  If the current source starts with a recognized BOM, then some flags
-   --  such as Wide_Character_Encoding_Method are set accordingly.
-   --  An exception is raised if a BOM is found that indicates an unrecognized
-   --  format.
-   --  This procedure has no effect if there is no BOM at the beginning of the
-   --  current source.
-
 private
    pragma Inline (File_Name);
    pragma Inline (First_Mapped_Line);