OSDN Git Service

2011-09-02 Robert Dewar <dewar@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 2 Sep 2011 08:25:44 +0000 (08:25 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 2 Sep 2011 08:25:44 +0000 (08:25 +0000)
* s-rident.ads: Add new restriction No_Implicit_Aliasing
* sem_attr.adb: (Analyze_Access_Attribute): Deal with
No_Implicit_Aliasing
(Analyze_Attribute, case Address): ditto
(Analyze_Attribute, case Unrestricted_Access): ditto
* sem_util.ads, sem_util.adb: (Is_Aliased_View): Handle
No_Implicit_Aliasing restriction.
* gnat_rm.texi: Add documentation for No_Implicit_Aliasing

2011-09-02  Ed Schonberg  <schonberg@adacore.com>

* exp_util.adb: (Possible_Bit_Aligned_Object): If the object
is an unchecked conversion, apply test to its expression.

2011-09-02  Javier Miranda  <miranda@adacore.com>

* sem_ch3.adb (Check_Abstract_Overriding): When
traversing the chain of aliased subprograms avoid reporting a
redundant error on the current entity.

2011-09-02  Sergey Rybin  <rybin@adacore.com>

* gnat_ugn.texi: Minor clean up.

2011-09-02  Bob Duff  <duff@adacore.com>

* s-htable.adb (Set_If_Not_Present): Use renaming
instead of ":=", because the type Key is limited in the generic (even
if not in the instances).

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178440 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/exp_util.adb
gcc/ada/gnat_rm.texi
gcc/ada/gnat_ugn.texi
gcc/ada/s-htable.adb
gcc/ada/s-rident.ads
gcc/ada/sem_attr.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_util.adb
gcc/ada/sem_util.ads

index dec2a2c..423c174 100644 (file)
@@ -1,5 +1,37 @@
 2011-09-02  Robert Dewar  <dewar@adacore.com>
 
+       * s-rident.ads: Add new restriction No_Implicit_Aliasing
+       * sem_attr.adb: (Analyze_Access_Attribute): Deal with
+       No_Implicit_Aliasing
+       (Analyze_Attribute, case Address): ditto
+       (Analyze_Attribute, case Unrestricted_Access): ditto
+       * sem_util.ads, sem_util.adb: (Is_Aliased_View): Handle
+       No_Implicit_Aliasing restriction.
+       * gnat_rm.texi: Add documentation for No_Implicit_Aliasing
+
+2011-09-02  Ed Schonberg  <schonberg@adacore.com>
+
+       * exp_util.adb: (Possible_Bit_Aligned_Object): If the object
+       is an unchecked conversion, apply test to its expression.
+
+2011-09-02  Javier Miranda  <miranda@adacore.com>
+
+       * sem_ch3.adb (Check_Abstract_Overriding): When
+       traversing the chain of aliased subprograms avoid reporting a
+       redundant error on the current entity.
+
+2011-09-02  Sergey Rybin  <rybin@adacore.com>
+
+       * gnat_ugn.texi: Minor clean up.
+
+2011-09-02  Bob Duff  <duff@adacore.com>
+
+       * s-htable.adb (Set_If_Not_Present): Use renaming
+       instead of ":=", because the type Key is limited in the generic (even
+       if not in the instances).
+
+2011-09-02  Robert Dewar  <dewar@adacore.com>
+
        * exp_util.adb, sem_ch10.adb, sem_attr.adb, s-htable.adb,
        g-comlin.adb, g-comlin.ads, lib-xref-alfa.adb, lib-xref.adb: Minor
        reformatting.
index 736d3d0..df31bbe 100644 (file)
@@ -5687,6 +5687,12 @@ package body Exp_Util is
          when N_Slice =>
             return Possible_Bit_Aligned_Component (Prefix (N));
 
+         --  For an unchecked conversion, check whether the expression may
+         --  be bit-aligned.
+
+         when N_Unchecked_Type_Conversion =>
+            return Possible_Bit_Aligned_Component (Expression (N));
+
          --  If we have none of the above, it means that we have fallen off the
          --  top testing prefixes recursively, and we now have a stand alone
          --  object, where we don't have a problem.
index 5cc0cb6..5ee942c 100644 (file)
@@ -8988,6 +8988,17 @@ in a distributed environment. If this exception is active, then the generated
 code is simplified by omitting the otherwise-required global registration
 of exceptions when they are declared.
 
+@item No_Implicit_Aliasing
+@findex No_Implicit_Aliasing
+
+This restriction, which is not required to be partition-wide consistent,
+requires an explicit aliased keyword for an object to which 'Access,
+'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
+the 'Unrestricted_Access attribute for objects. Note: the reason that
+Unrestricted_Access is forbidden is that it would require the prefix
+to be aliased, and in such cases, it can always be replaced by
+the standard attribute Unchecked_Access which is preferable.
+
 @item No_Implicit_Conditionals
 @findex No_Implicit_Conditionals
 This restriction ensures that the generated code does not contain any
index 145c66e..8d1597d 100644 (file)
@@ -13071,8 +13071,6 @@ Reformat comment blocks
 @item ^-c5^/COMMENTS_LAYOUT=KEEP_SPECIAL^
 Keep unchanged special form comments
 
-Reformat comment blocks
-
 @cindex @option{^-l@var{n}^/CONSTRUCT_LAYOUT^} (@command{gnatpp})
 @item ^-l1^/CONSTRUCT_LAYOUT=GNAT^
 GNAT-style layout (this is the default)
index 7b5ee03..e2b5235 100644 (file)
@@ -195,7 +195,12 @@ package body System.HTable is
       ------------------------
 
       function Set_If_Not_Present (E : Elmt_Ptr) return Boolean is
-         K     : constant Key        := Get_Key (E);
+         K : Key renames Get_Key (E);
+         --  Note that it is important to use a renaming here rather than
+         --  define a constant initialized by the call, because the latter
+         --  construct runs into bootstrap problems with earlier versions
+         --  of the GNAT compiler.
+
          Index : constant Header_Num := Hash (K);
          Elmt  : Elmt_Ptr;
 
index 2f0a2f3..6923b59 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2010, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-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- --
@@ -128,6 +128,7 @@ package System.Rident is
       No_Implementation_Attributes,            -- Ada 2005 AI-257
       No_Implementation_Pragmas,               -- Ada 2005 AI-257
       No_Implementation_Restrictions,          -- GNAT
+      No_Implicit_Aliasing,                    -- GNAT
       No_Elaboration_Code,                     -- GNAT
       No_Obsolescent_Features,                 -- Ada 2005 AI-368
       No_Wide_Characters,                      -- GNAT
index 43ae847..d09e3b5 100644 (file)
@@ -837,7 +837,13 @@ package body Sem_Attr is
            and then not In_Instance
            and then not In_Inlined_Body
          then
-            Error_Attr_P ("prefix of % attribute must be aliased");
+            if Restriction_Check_Required (No_Implicit_Aliasing) then
+               Error_Attr_P
+                 ("prefix of % attribute must be explicitly aliased");
+            else
+               Error_Attr_P
+                 ("prefix of % attribute must be aliased");
+            end if;
          end if;
       end Analyze_Access_Attribute;
 
@@ -2221,11 +2227,19 @@ package body Sem_Attr is
                then
                   Set_Address_Taken (Ent);
 
-               --  If we have an address of an object, and the attribute
-               --  comes from source, then set the object as potentially
-               --  source modified. We do this because the resulting address
-               --  can potentially be used to modify the variable and we
-               --  might not detect this, leading to some junk warnings.
+                  --  Deal with No_Implicit_Aliasing restriction
+
+                  if Restriction_Check_Required (No_Implicit_Aliasing) then
+                     if not Is_Aliased_View (P) then
+                        Check_Restriction (No_Implicit_Aliasing, P);
+                     end if;
+                  end if;
+
+                  --  If we have an address of an object, and the attribute
+                  --  comes from source, then set the object as potentially
+                  --  source modified. We do this because the resulting address
+                  --  can potentially be used to modify the variable and we
+                  --  might not detect this, leading to some junk warnings.
 
                   Set_Never_Set_In_Source (Ent, False);
 
@@ -4927,6 +4941,10 @@ package body Sem_Attr is
       when Attribute_Unrestricted_Access =>
          if Comes_From_Source (N) then
             Check_Restriction (No_Unchecked_Access, N);
+
+            if Nkind (P) in N_Has_Entity and then Is_Object (Entity (P)) then
+               Check_Restriction (No_Implicit_Aliasing, N);
+            end if;
          end if;
 
          if Is_Entity_Name (P) then
index aedc29f..6a55aa9 100644 (file)
@@ -9105,9 +9105,16 @@ package body Sem_Ch3 is
                         begin
                            E := Subp;
                            while Present (Alias (E)) loop
-                              Error_Msg_Sloc := Sloc (E);
-                              Error_Msg_NE
-                                ("\& has been inherited #", T, Subp);
+
+                              --  Avoid reporting redundant errors on entities
+                              --  inherited from interfaces
+
+                              if Sloc (E) /= Sloc (T) then
+                                 Error_Msg_Sloc := Sloc (E);
+                                 Error_Msg_NE
+                                   ("\& has been inherited #", T, Subp);
+                              end if;
+
                               E := Alias (E);
                            end loop;
 
index 2b9d79d..658ca1a 100644 (file)
@@ -6489,9 +6489,12 @@ package body Sem_Util is
 
    begin
       if Is_Entity_Name (Obj) then
-
          E := Entity (Obj);
 
+         if Is_Object (E) and then not Is_Aliased (E) then
+            Check_Restriction (No_Implicit_Aliasing, Obj);
+         end if;
+
          return
            (Is_Object (E)
              and then
@@ -6526,13 +6529,10 @@ package body Sem_Util is
          return Has_Aliased_Components (Etype (Prefix (Obj)))
            or else
              (Is_Access_Type (Etype (Prefix (Obj)))
-               and then
-              Has_Aliased_Components
-                (Designated_Type (Etype (Prefix (Obj)))));
+               and then Has_Aliased_Components
+                          (Designated_Type (Etype (Prefix (Obj)))));
 
-      elsif Nkind (Obj) = N_Unchecked_Type_Conversion
-        or else Nkind (Obj) = N_Type_Conversion
-      then
+      elsif Nkind_In (Obj, N_Unchecked_Type_Conversion, N_Type_Conversion) then
          return Is_Tagged_Type (Etype (Obj))
            and then Is_Aliased_View (Expression (Obj));
 
index fc408b3..55a2310 100644 (file)
@@ -753,7 +753,8 @@ package Sem_Util is
 
    function Is_Aliased_View (Obj : Node_Id) return Boolean;
    --  Determine if Obj is an aliased view, i.e. the name of an object to which
-   --  'Access or 'Unchecked_Access can apply.
+   --  'Access or 'Unchecked_Access can apply. Note that the implementation
+   --  takes the No_Implicit_Aiasing restriction into account.
 
    function Is_Ancestor_Package
      (E1 : Entity_Id;