[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Fri, 6 Jan 2012 14:48:05 +0000 (15:48 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 6 Jan 2012 14:48:05 +0000 (15:48 +0100)
2012-01-06  Robert Dewar  <dewar@adacore.com>

* a-wichha.ads, a-wichun.ads, a-zchhan.ads, a-zchuni.ads,
s-utf_32.ads: Add pragma Pure
* s-utf_32.adb: Suppress warnings on non-static constants (now
that this is Pure).

2012-01-06  Bob Duff  <duff@adacore.com>

* s-rpc.ads (Read, Write): Add overriding indicators.

2012-01-06  Robert Dewar  <dewar@adacore.com>

* gnat_rm.texi: Add documentation for conventions
Ada_Pass_By_Copy and Ada_Pass_By_Reference.

2012-01-06  Gary Dismukes  <dismukes@adacore.com>

* a-tienio.adb (Put): Add exception message on
raise statements. Remove unneeded blocks and object declarations.

2012-01-06  Robert Dewar  <dewar@adacore.com>

* sem_prag.adb: Minor reformatting.

2012-01-06  Ed Schonberg  <schonberg@adacore.com>

* sinfo.ads, sinfo.adb (Has_Prefixed_Call): New flag to indicate
that a selected component within a generic unit has been resolved
as a prefixed call with local references.
* sem_ch3.adb (Is_Visible_Component): In an instance body a selected
component is always visible.
* sem_ch4.adb (Analyze_Selected_Component): If the node is a
prefixed call in an instance, do not look for visible components
of the type.
* sem_ch12.adb (Reset_Entity): If a selected component has resolved
to a prefixed call, mark the node accordingly when prefix and
selector are local references.

From-SVN: r182954

16 files changed:
gcc/ada/ChangeLog
gcc/ada/a-tienio.adb
gcc/ada/a-wichha.ads
gcc/ada/a-wichun.ads
gcc/ada/a-zchhan.ads
gcc/ada/a-zchuni.ads
gcc/ada/gnat_rm.texi
gcc/ada/s-rpc.ads
gcc/ada/s-utf_32.adb
gcc/ada/s-utf_32.ads
gcc/ada/sem_ch12.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_ch4.adb
gcc/ada/sem_prag.adb
gcc/ada/sinfo.adb
gcc/ada/sinfo.ads

index 5e76857..6790572 100644 (file)
@@ -1,3 +1,42 @@
+2012-01-06  Robert Dewar  <dewar@adacore.com>
+
+       * a-wichha.ads, a-wichun.ads, a-zchhan.ads, a-zchuni.ads,
+       s-utf_32.ads: Add pragma Pure
+       * s-utf_32.adb: Suppress warnings on non-static constants (now
+       that this is Pure).
+
+2012-01-06  Bob Duff  <duff@adacore.com>
+
+       * s-rpc.ads (Read, Write): Add overriding indicators.
+
+2012-01-06  Robert Dewar  <dewar@adacore.com>
+
+       * gnat_rm.texi: Add documentation for conventions
+       Ada_Pass_By_Copy and Ada_Pass_By_Reference.
+
+2012-01-06  Gary Dismukes  <dismukes@adacore.com>
+
+       * a-tienio.adb (Put): Add exception message on
+       raise statements. Remove unneeded blocks and object declarations.
+
+2012-01-06  Robert Dewar  <dewar@adacore.com>
+
+       * sem_prag.adb: Minor reformatting.
+
+2012-01-06  Ed Schonberg  <schonberg@adacore.com>
+
+       * sinfo.ads, sinfo.adb (Has_Prefixed_Call): New flag to indicate
+       that a selected component within a generic unit has been resolved
+       as a prefixed call with local references.
+       * sem_ch3.adb (Is_Visible_Component): In an instance body a selected
+       component is always visible.
+       * sem_ch4.adb (Analyze_Selected_Component): If the node is a
+       prefixed call in an instance, do not look for visible components
+       of the type.
+       * sem_ch12.adb (Reset_Entity): If a selected component has resolved
+       to a prefixed call, mark the node accordingly when prefix and
+       selector are local references.
+
 2012-01-02  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnatvsn.ads (Current_Year): Bump to 2012.
index a643f87..1b9ab8b 100644 (file)
@@ -101,14 +101,10 @@ package body Ada.Text_IO.Enumeration_IO is
       --  checks suppressed, which includes instantiated generics.
 
       if not Item'Valid then
-         raise Constraint_Error;
+         raise Constraint_Error with "invalid enumeration value";
       end if;
 
-      declare
-         Image : constant String := Enum'Image (Item);
-      begin
-         Aux.Put (File, Image, Width, Set);
-      end;
+      Aux.Put (File, Enum'Image (Item), Width, Set);
    end Put;
 
    procedure Put
@@ -132,14 +128,10 @@ package body Ada.Text_IO.Enumeration_IO is
       --  checks suppressed, which includes instantiated generics.
 
       if not Item'Valid then
-         raise Constraint_Error;
+         raise Constraint_Error with "invalid enumeration value";
       end if;
 
-      declare
-         Image : constant String := Enum'Image (Item);
-      begin
-         Aux.Puts (To, Image, Set);
-      end;
+      Aux.Puts (To, Enum'Image (Item), Set);
    end Put;
 
 end Ada.Text_IO.Enumeration_IO;
index 50c3ff8..a9cff25 100755 (executable)
 ------------------------------------------------------------------------------
 
 package Ada.Wide_Characters.Handling is
+   pragma Pure;
+   --  This package is clearly intended to be Pure, by analogy with the
+   --  base Ada.Characters.Handling package. The version in the RM does
+   --  not yet have this pragma, but that is a clear omission. This will
+   --  be fixed in a future version of AI05-0266-1.
 
    function Is_Control (Item : Wide_Character) return Boolean;
    pragma Inline (Is_Control);
index 08ac83d..a2f78e3 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 2005-2010, Free Software Foundation, Inc.         --
+--          Copyright (C) 2005-2011, 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- --
@@ -37,6 +37,7 @@
 with System.UTF_32;
 
 package Ada.Wide_Characters.Unicode is
+   pragma Pure;
 
    --  The following type defines the categories from the unicode definitions.
    --  The one addition we make is Fe, which represents the characters FFFE
index 973a780..4c78dcd 100755 (executable)
 ------------------------------------------------------------------------------
 
 package Ada.Wide_Wide_Characters.Handling is
+   pragma Pure;
+   --  This package is clearly intended to be Pure, by analogy with the
+   --  base Ada.Characters.Handling package. The version in the RM does
+   --  not yet have this pragma, but that is a clear omission. This will
+   --  be fixed in a future version of AI05-0266-1.
 
    function Is_Control (Item : Wide_Wide_Character) return Boolean;
    pragma Inline (Is_Control);
index 1050695..bb2af79 100755 (executable)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 2005-2010, Free Software Foundation, Inc.         --
+--          Copyright (C) 2005-2011, 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- --
@@ -34,6 +34,7 @@
 with System.UTF_32;
 
 package Ada.Wide_Wide_Characters.Unicode is
+   pragma Pure;
 
    --  The following type defines the categories from the unicode definitions.
    --  The one addition we make is Fe, which represents the characters FFFE
index 781e0ae..908b177 100644 (file)
@@ -9608,6 +9608,14 @@ The following convention names are supported
 @table @code
 @item  Ada
 Ada
+@item Ada_Pass_By_Copy
+Allowed for any types except by-reference types such as limited
+records. Compatible with convention Ada, but causes any parameters
+with this convention to be passed by copy.
+@item Ada_Pass_By_Reference
+Allowed for any types except by-copy types such as scalars.
+Compatible with convention Ada, but causes any parameters
+with this convention to be passed by reference.
 @item Assembler
 Assembly language
 @item Asm
index fa883ec..93ad69b 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -52,12 +52,12 @@ package System.RPC is
      (Initial_Size : Ada.Streams.Stream_Element_Count) is new
        Ada.Streams.Root_Stream_Type with private;
 
-   procedure Read
+   overriding procedure Read
      (Stream : in out Params_Stream_Type;
       Item   : out Ada.Streams.Stream_Element_Array;
       Last   : out Ada.Streams.Stream_Element_Offset);
 
-   procedure Write
+   overriding procedure Write
      (Stream : in out Params_Stream_Type;
       Item   : Ada.Streams.Stream_Element_Array);
 
index f044b9b..676d0e3 100755 (executable)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2005-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 2005-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- --
@@ -34,6 +34,13 @@ pragma Compiler_Unit;
 pragma Style_Checks (Off);
 --  Allow long lines in this unit
 
+--  pragma Warnings (Off, "non-static constant in preelaborated unit");
+--  We need this to be pure, and the three constants in question are not a
+--  real problem, they are completely known at compile time. This pragma
+--  is commented out for now, because we still want to be able to bootstrap
+--  with old versions of the compiler that did not support this form. We
+--  have added additional pragma Warnings (Off/On) for now ???
+
 package body System.UTF_32 is
 
    ----------------------
@@ -1850,6 +1857,9 @@ package body System.UTF_32 is
      (16#F0000#, 16#FFFFD#),  -- (Co)  <Plane 15 Private Use, First> .. <Plane 15 Private Use, Last>
      (16#100000#, 16#10FFFD#));  -- (Co)  <Plane 16 Private Use, First> .. <Plane 16 Private Use, Last>
 
+   pragma Warnings (Off);
+   --  Temporary, until pragma at start can be activated ???
+
    --  The following array is parallel to the Unicode_Ranges table above. For
    --  each entry in the Unicode_Ranges table, there is a corresponding entry
    --  in the following table indicating the corresponding unicode category.
@@ -6060,6 +6070,9 @@ package body System.UTF_32 is
         40,  -- DESERET CAPITAL LETTER LONG I .. DESERET CAPITAL LETTER EW
         32); -- TAG LATIN CAPITAL LETTER A .. TAG LATIN CAPITAL LETTER Z
 
+   pragma Warnings (On);
+   --  Temporary until pragma Warnings at start can be activated ???
+
    --  The following is a list of the 10646 names for CAPITAL LETTER entries
    --  that have no matching SMALL LETTER entry and are thus not folded
 
index 4cdbf95..4f61a01 100755 (executable)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 2005-2010, Free Software Foundation, Inc.         --
+--          Copyright (C) 2005-2011, 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- --
@@ -44,6 +44,7 @@
 pragma Compiler_Unit;
 
 package System.UTF_32 is
+   pragma Pure;
 
    type UTF_32 is range 0 .. 16#7FFF_FFFF#;
    --  So far, the only defined character codes are in 0 .. 16#01_FFFF#
index 3557ed8..cbc8b4d 100644 (file)
@@ -12676,6 +12676,7 @@ package body Sem_Ch12 is
                   Save_Entity_Descendants (N);
 
                else
+                  Set_Is_Prefixed_Call (Parent (N));
                   Set_Associated_Node (N, Empty);
                   Set_Etype (N, Empty);
                end if;
@@ -12683,10 +12684,13 @@ package body Sem_Ch12 is
             --  In Ada 2005, X.F may be a call to a primitive operation,
             --  rewritten as F (X). This rewriting will be done again in an
             --  instance, so keep the original node. Global entities will be
-            --  captured as for other constructs.
+            --  captured as for other constructs. Indicate that this must
+            --  resolve as a call, to prevent accidental overloading in the
+            --  instance, if both a component and a primitive operation appear
+            --  as candidates.
 
             else
-               null;
+               Set_Is_Prefixed_Call (Parent (N));
             end if;
 
          --  Entity is local. Reset in generic unit, so that node is resolved
index 50c9d3d..88ef267 100644 (file)
@@ -16300,34 +16300,11 @@ package body Sem_Ch3 is
       then
          return True;
 
-      --  If we are in the body of an instantiation, the component is visible
-      --  if the parent type is non-private, or in  an enclosing scope. The
-      --  scope stack is not present when analyzing an instance body, so we
-      --  must inspect the chain of scopes explicitly.
+      --  In the body of an instantiation, no need to check for the visibility
+      --  of a component.
 
       elsif In_Instance_Body then
-         if not Is_Private_Type (Scope (C)) then
-            return True;
-
-         else
-            declare
-               S : Entity_Id;
-
-            begin
-               S := Current_Scope;
-               while Present (S)
-                 and then S /= Standard_Standard
-               loop
-                  if S = Type_Scope then
-                     return True;
-                  end if;
-
-                  S := Scope (S);
-               end loop;
-
-               return False;
-            end;
-         end if;
+         return True;
 
       --  If the component has been declared in an ancestor which is currently
       --  a private type, then it is not visible. The same applies if the
index 99f2966..5ade3a8 100644 (file)
@@ -3858,8 +3858,10 @@ package body Sem_Ch4 is
       elsif Is_Record_Type (Prefix_Type) then
 
          --  Find component with given name
+         --  In an instance, if the node is known as a prefixed call, do
+         --  not examine components whose visibility may be accidental.
 
-         while Present (Comp) loop
+         while Present (Comp) and then not Is_Prefixed_Call (N) loop
             if Chars (Comp) = Chars (Sel)
               and then Is_Visible_Component (Comp)
             then
index 0afe05c..8ac54a5 100644 (file)
@@ -14501,7 +14501,7 @@ package body Sem_Prag is
                      --  the formal may be wrapped in a conversion if the
                      --  actual is a conversion. Retrieve the real entity name.
 
-                     if (In_Instance_Body or else In_Inlined_Body)
+                     if (In_Instance_Body or In_Inlined_Body)
                        and then Nkind (E_Id) = N_Unchecked_Type_Conversion
                      then
                         E_Id := Expression (E_Id);
index 440cf02..96b4570 100644 (file)
@@ -1838,6 +1838,14 @@ package body Sinfo is
       return Flag13 (N);
    end Is_Power_Of_2_For_Shift;
 
+   function Is_Prefixed_Call
+      (N : Node_Id) return Boolean is
+   begin
+      pragma Assert (False
+        or else NT (N).Nkind = N_Selected_Component);
+      return Flag17 (N);
+   end Is_Prefixed_Call;
+
    function Is_Protected_Subprogram_Body
       (N : Node_Id) return Boolean is
    begin
@@ -4910,6 +4918,14 @@ package body Sinfo is
       Set_Flag13 (N, Val);
    end Set_Is_Power_Of_2_For_Shift;
 
+   procedure Set_Is_Prefixed_Call
+      (N : Node_Id; Val : Boolean := True) is
+   begin
+      pragma Assert (False
+        or else NT (N).Nkind = N_Selected_Component);
+      Set_Flag17 (N, Val);
+   end Set_Is_Prefixed_Call;
+
    procedure Set_Is_Protected_Subprogram_Body
       (N : Node_Id; Val : Boolean := True) is
    begin
index ce4a31c..3d1809b 100644 (file)
@@ -1335,6 +1335,12 @@ package Sinfo is
    --    conditions holds, and the flag is set, then the division or
    --    multiplication can be (and is) converted to a shift.
 
+   --  Is_Prefixed_Call (Flag17-Sem)
+   --    This flag is set in a selected component within a generic unit, if
+   --    it resolves to a prefixed call to a primitive operation. The flag
+   --    is used to prevent accidental overloadings in an instance, when a
+   --    primitive operation and a private record component may be homographs.
+
    --  Is_Protected_Subprogram_Body (Flag7-Sem)
    --    A flag set in a Subprogram_Body block to indicate that it is the
    --    implementation of a protected subprogram. Such a body needs cleanup
@@ -3249,6 +3255,7 @@ package Sinfo is
       --  Associated_Node (Node4-Sem)
       --  Do_Discriminant_Check (Flag13-Sem)
       --  Is_In_Discriminant_Check (Flag11-Sem)
+      --  Is_Prefixed_Call (Flag17-Sem)
       --  Atomic_Sync_Required (Flag14-Sem)
       --  plus fields for expression
 
@@ -8653,6 +8660,9 @@ package Sinfo is
    function Is_Power_Of_2_For_Shift
      (N : Node_Id) return Boolean;    -- Flag13
 
+   function Is_Prefixed_Call
+     (N : Node_Id) return Boolean;    -- Flag17
+
    function Is_Protected_Subprogram_Body
      (N : Node_Id) return Boolean;    -- Flag7
 
@@ -9631,6 +9641,9 @@ package Sinfo is
    procedure Set_Is_Power_Of_2_For_Shift
      (N : Node_Id; Val : Boolean := True);    -- Flag13
 
+   procedure Set_Is_Prefixed_Call
+     (N : Node_Id; Val : Boolean := True);    -- Flag17
+
    procedure Set_Is_Protected_Subprogram_Body
      (N : Node_Id; Val : Boolean := True);    -- Flag7
 
@@ -11971,6 +11984,7 @@ package Sinfo is
    pragma Inline (Is_Null_Loop);
    pragma Inline (Is_Overloaded);
    pragma Inline (Is_Power_Of_2_For_Shift);
+   pragma Inline (Is_Prefixed_Call);
    pragma Inline (Is_Protected_Subprogram_Body);
    pragma Inline (Is_Static_Coextension);
    pragma Inline (Is_Static_Expression);
@@ -12293,6 +12307,7 @@ package Sinfo is
    pragma Inline (Set_Is_Null_Loop);
    pragma Inline (Set_Is_Overloaded);
    pragma Inline (Set_Is_Power_Of_2_For_Shift);
+   pragma Inline (Set_Is_Prefixed_Call);
    pragma Inline (Set_Is_Protected_Subprogram_Body);
    pragma Inline (Set_Has_Self_Reference);
    pragma Inline (Set_Is_Static_Coextension);