]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2014-07-17 Robert Dewar <dewar@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Jul 2014 06:40:45 +0000 (06:40 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Jul 2014 06:40:45 +0000 (06:40 +0000)
* gnat_rm.texi: Improve documentation of Unrestricted_Access.
* sinfo.ads: Document restriction on aggregates (must expand to
assignments if one or more assignments needs expansion, e.g. for
controlled types).
* sem_ch13.adb: All warning messages regarding bit order should
be info: messages.
* gnat_ugn.texi: Minor correction of missing @ on @code

2014-07-17  Robert Dewar  <dewar@adacore.com>

* restrict.ads (Implementation_Restriction): Add No_Long_Long_Integer.
* s-rident.ads (Partition_Boolean_Restrictions): Add
No_Long_Long_Integer.
* sem_ch3.adb (Modular_Type_Declaration): Size must be <=
Long_Integer'Size if restriction No_Long_Long_Integer is active.
(Signed_Integer_Type_Declaration): Do not allow Long_Long_Integer
as the implicit base type for a signed integer type declaration
if restriction No_Long_Long_Integer is active.
* sem_util.ads, sem_util.adb (Set_Entity_With_Checks): Include check for
No_Long_Long_Integer.

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

gcc/ada/ChangeLog
gcc/ada/gnat_rm.texi
gcc/ada/gnat_ugn.texi
gcc/ada/restrict.ads
gcc/ada/s-rident.ads
gcc/ada/sem_ch13.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_util.adb
gcc/ada/sem_util.ads
gcc/ada/sinfo.ads

index a96b0ce51a7cb6e80a1c8d63d4e94c7ddd27f91c..f70dcf8e8f0b14b254b6f2d95993f3b160e9549f 100644 (file)
@@ -1,3 +1,26 @@
+2014-07-17  Robert Dewar  <dewar@adacore.com>
+
+       * gnat_rm.texi: Improve documentation of Unrestricted_Access.
+       * sinfo.ads: Document restriction on aggregates (must expand to
+       assignments if one or more assignments needs expansion, e.g. for
+       controlled types).
+       * sem_ch13.adb: All warning messages regarding bit order should
+       be info: messages.
+       * gnat_ugn.texi: Minor correction of missing @ on @code
+
+2014-07-17  Robert Dewar  <dewar@adacore.com>
+
+       * restrict.ads (Implementation_Restriction): Add No_Long_Long_Integer.
+       * s-rident.ads (Partition_Boolean_Restrictions): Add
+       No_Long_Long_Integer.
+       * sem_ch3.adb (Modular_Type_Declaration): Size must be <=
+       Long_Integer'Size if restriction No_Long_Long_Integer is active.
+       (Signed_Integer_Type_Declaration): Do not allow Long_Long_Integer
+       as the implicit base type for a signed integer type declaration
+       if restriction No_Long_Long_Integer is active.
+       * sem_util.ads, sem_util.adb (Set_Entity_With_Checks): Include check for
+       No_Long_Long_Integer.
+
 2014-07-17  Robert Dewar  <dewar@adacore.com>
 
        * sem_ch3.adb, a-ztexio.ads, exp_imgv.adb, casing.adb, casing.ads,
index b82931fbbc34e4c197f5d27c5b72354adaf6e467..05b3cb44fe113ee8487a5696bc89be9fddd476e9 100644 (file)
@@ -9672,6 +9672,41 @@ unconstrained array.  The use of thin pointers should be restricted to
 cases of porting legacy code which implicitly assumes the size of pointers,
 and such code should not in any case be using this attribute.
 
+Another erroroneous situation arises if the attribute is
+applied to a constant. The resulting pointer can be used to access the
+constant, but the effect of trying to modify a constant in this manner
+is not well-defined. Consider this example:
+
+@smallexample @c ada
+P : constant Integer := 4;
+type R is access all Integer;
+RV : R := P'Unrestricted_Access;
+..
+RV.all := 3;
+@end smallexample
+
+@noindent
+Here we attempt to modify the constant P from 4 to 3, but the compiler may
+or may not notice this attempt, and subsequent references to P may yield
+either the value 3 or the value 4 or the assignment may blow up if the
+compiler decides to put P in read-only memory. One particular case where
+@code{Unrestricted_Access} can be used in this way is to modify the
+value of an @code{IN} parameter:
+
+@smallexample @c ada
+procedure K (S : in String) is
+   type R is access all Character;
+   RV : R := S (3)'Unrestricted_Access;
+begin
+   RV.all := 'a';
+end;
+@end smallexample
+
+@noindent
+In general this is a risky approach. It may appear to "work" but such uses of
+@code{Unrestricted_Access} are potentially non-portable, even from one version
+of @code{GNAT} to another, so are best avoided if possible.
+
 @node Attribute Update
 @unnumberedsec Attribute Update
 @findex Update
index 08d4e086b0dc070aaae56f81a1d858cd037ed09d..501b576caf0e2883129c4e9715d9ab4a519d8e7c 100644 (file)
@@ -6827,7 +6827,7 @@ the Ada standard, the additional implementation defined checks
 @code{Alignment_Check},
 @code{Duplicated_Tag_Check}, @code{Predicate_Check}, and
 @code{Validity_Check}, as well as any checks introduced using
-@code{pragma Check_Name}. Note that code{Atomic_Synchronization}
+@code{pragma Check_Name}. Note that @code{Atomic_Synchronization}
 is not automatically suppressed by use of this option.
 
 If the code depends on certain checks being active, you can use
index b6c93f8a7d747f90fd1208f51ee6ad42a629d0f6..ef5c2c727cfa47260670cd54e8dc2566e84e3003 100644 (file)
@@ -72,7 +72,7 @@ package Restrict is
    --  restriction to the binder.
 
    --  The following declarations establish a mapping between restriction
-   --  identifiers, and the names of corresponding restriction library units.
+   --  identifiers, and the names of corresponding restricted library units.
 
    type Unit_Entry is record
       Res_Id : Restriction_Id;
@@ -129,6 +129,7 @@ package Restrict is
       No_Implicit_Loops                  => True,
       No_Initialize_Scalars              => True,
       No_Local_Protected_Objects         => True,
+      No_Long_Long_Integer               => True,
       No_Protected_Type_Allocators       => True,
       No_Relative_Delay                  => True,
       No_Requeue_Statements              => True,
index 4f22a1943dda3681991a38fd6dc150f8e1645850..181530d117b8c8b37782c4ba5d81d4868a9126c6 100644 (file)
@@ -124,6 +124,7 @@ package System.Rident is
       No_Local_Allocators,                       -- (RM H.4(8))
       No_Local_Timing_Events,                    -- (RM D.7(10.2/2))
       No_Local_Protected_Objects,                -- Ada 2012 (D.7(10/1.3))
+      No_Long_Long_Integer,                      -- GNAT
       No_Nested_Finalization,                    -- (RM D.7(4))
       No_Protected_Type_Allocators,              -- Ada 2012 (D.7 (10.3/2))
       No_Protected_Types,                        -- (RM H.4(5))
index f9bf2a3fb4efea70ad9c3b2d0b075bd4f895847e..da4252d6794456e786e152645f26886f4e08b6ee 100644 (file)
@@ -302,17 +302,17 @@ package body Sem_Ch13 is
                        and then CSZ mod System_Storage_Unit = 0
                      then
                         Error_Msg_N
-                          ("multi-byte field specified with non-standard"
-                           & " Bit_Order??", CLC);
+                          ("info: multi-byte field specified with "
+                           & "non-standard Bit_Order?V?", CLC);
 
                         if Bytes_Big_Endian then
                            Error_Msg_N
-                             ("bytes are not reversed "
-                              & "(component is big-endian)??", CLC);
+                             ("\bytes are not reversed "
+                              & "(component is big-endian)?V?", CLC);
                         else
                            Error_Msg_N
-                             ("bytes are not reversed "
-                              & "(component is little-endian)??", CLC);
+                             ("\bytes are not reversed "
+                              & "(component is little-endian)?V?", CLC);
                         end if;
 
                         --  Do not allow non-contiguous field
@@ -338,13 +338,13 @@ package body Sem_Ch13 is
                        and then Warn_On_Reverse_Bit_Order
                      then
                         Error_Msg_N
-                          ("Bit_Order clause does not affect " &
+                          ("info: Bit_Order clause does not affect " &
                            "byte ordering?V?", Pos);
                         Error_Msg_Uint_1 :=
                           Intval (Pos) + Intval (FB) /
                           System_Storage_Unit;
                         Error_Msg_N
-                          ("position normalized to ^ before bit " &
+                          ("info: position normalized to ^ before bit " &
                            "order interpreted?V?", Pos);
                      end if;
 
@@ -431,7 +431,7 @@ package body Sem_Ch13 is
 
                            if Warn_On_Reverse_Bit_Order then
                               Error_Msg_N
-                                ("multi-byte field specified with "
+                                ("info: multi-byte field specified with "
                                  & "  non-standard Bit_Order?V?", CC);
 
                               if Bytes_Big_Endian then
@@ -661,14 +661,12 @@ package body Sem_Ch13 is
 
                            if Bytes_Big_Endian then
                               Error_Msg_NE
-                                ("\big-endian range for "
-                                 & "component & is ^ .. ^?V?",
-                                 First_Bit (CC), Comp);
+                                ("\big-endian range for component "
+                                 & "& is ^ .. ^?V?", First_Bit (CC), Comp);
                            else
                               Error_Msg_NE
-                                ("\little-endian range "
-                                 & "for component & is ^ .. ^?V?",
-                                 First_Bit (CC), Comp);
+                                ("\little-endian range for component"
+                                 & "& is ^ .. ^?V?", First_Bit (CC), Comp);
                            end if;
                         end if;
 
index 48982bd4b5b7ea82c9506d4b699946cc349d4a20..8c6747261241598f75b5d6f4b1a2ee5cbd612727 100644 (file)
@@ -17445,6 +17445,10 @@ package body Sem_Ch3 is
          M_Val := 2 ** System_Max_Binary_Modulus_Power;
       end if;
 
+      if M_Val > 2 ** Standard_Long_Integer_Size then
+         Check_Restriction (No_Long_Long_Integer, Mod_Expr);
+      end if;
+
       Set_Modulus (T, M_Val);
 
       --   Create bounds for the modular type based on the modulus given in
@@ -20622,6 +20626,7 @@ package body Sem_Ch3 is
             Base_Typ := Base_Type (Standard_Long_Integer);
 
          elsif Can_Derive_From (Standard_Long_Long_Integer) then
+            Check_Restriction (No_Long_Long_Integer, Def);
             Base_Typ := Base_Type (Standard_Long_Long_Integer);
 
          else
index 0639e97259c8e38ef3e48b670ccc4a5d3962ab53..d85e903419cad220d72973d062ede30683472acf 100644 (file)
@@ -15980,6 +15980,10 @@ package body Sem_Util is
          Check_Restriction (No_Abort_Statements, Post_Node);
       end if;
 
+      if Val = Standard_Long_Long_Integer then
+         Check_Restriction (No_Long_Long_Integer, Post_Node);
+      end if;
+
       --  Check for violation of No_Dynamic_Attachment
 
       if Restriction_Check_Required (No_Dynamic_Attachment)
index 9d40a8594a474e694885dc39c22c511227b27b66..efaa63cac0c3f7e597c7c81efddd15fa0003527c 100644 (file)
@@ -1796,6 +1796,9 @@ package Sem_Util is
    --    If restriction No_Dynamic_Attachment is set, then it checks that the
    --    entity is not one of the restricted names for this restriction.
    --
+   --    If restriction No_Long_Long_Integer is set, then it checks that the
+   --    entity is not Standard.Long_Long_Integer.
+   --
    --    If restriction No_Implementation_Identifiers is set, then it checks
    --    that the entity is not implementation defined.
 
index 4c282132abdd63aeec57bf0dde21d90f81ee3bd9..4bb9d4f34fec132be647c478162bc042d7f3571f 100644 (file)
@@ -3627,6 +3627,16 @@ package Sinfo is
       --  references a subprogram that is a renaming, then the front end must
       --  rewrite the attribute to refer directly to the renamed entity.
 
+      --  Note: syntactically the prefix of an attribute reference must be a
+      --  name, and this (somewhat artificial) requirement is enforced by the
+      --  parser. However, for many attributes, such as 'Valid, it is quite
+      --  reasonable to apply the attribute to any value, and hence to any
+      --  expression. Internally in the tree, the prefix is an expression which
+      --  does not have to be a name, and this is handled fine by the semantic
+      --  analysis and expansion, and back ends. This arises for the case of
+      --  attribute references built by the expander (e.g. 'Valid for the case
+      --  of an implicit validity check).
+
       --  Note: In generated code, the Address and Unrestricted_Access
       --  attributes can be applied to any expression, and the meaning is
       --  to create an object containing the value (the object is in the
@@ -3638,7 +3648,7 @@ package Sinfo is
 
       --  N_Attribute_Reference
       --  Sloc points to apostrophe
-      --  Prefix (Node3)
+      --  Prefix (Node3) (general expression, see note above)
       --  Attribute_Name (Name2) identifier name from attribute designator
       --  Expressions (List1) (set to No_List if no associated expressions)
       --  Entity (Node4-Sem) used if the attribute yields a type
@@ -3731,11 +3741,18 @@ package Sinfo is
       --  are not met, then the front end must translate the aggregate into
       --  an appropriate set of assignments into a temporary.
 
-      --  Note: for the record aggregate case, gigi/gcc can handle all cases of
-      --  record aggregates, including those for packed, and rep-claused
+      --  Note: for the record aggregate case, gigi/gcc can handle most cases
+      --  of record aggregates, including those for packed, and rep-claused
       --  records, and also variant records, providing that there are no
-      --  variable length fields whose size is not known at compile time, and
-      --  providing that the aggregate is presented in fully named form.
+      --  variable length fields whose size is not known at compile time,
+      --  and providing that the aggregate is presented in fully named form.
+
+      --  The other situation in which array aggregates and record aggregates
+      --  cannot be passed to the back end is if assignment to one or more
+      --  components itself needs expansion, e.g. in the case of an assignment
+      --  of an object of a controlled type. In such cases, the front end
+      --  must expand the aggregate to a series of assignments, and apply
+      --  the required expansion to the individual assignment statements.
 
       ----------------------------------------------
       -- 4.3.1  Record Component Association List --