From: charlet Date: Thu, 17 Jul 2014 06:40:45 +0000 (+0000) Subject: 2014-07-17 Robert Dewar X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7a41db5b2e39bcfbf513612fbe4f23891f474f07;p=thirdparty%2Fgcc.git 2014-07-17 Robert Dewar * 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 * 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 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index a96b0ce51a7c..f70dcf8e8f0b 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,26 @@ +2014-07-17 Robert Dewar + + * 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 + + * 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 * sem_ch3.adb, a-ztexio.ads, exp_imgv.adb, casing.adb, casing.ads, diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index b82931fbbc34..05b3cb44fe11 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -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 diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 08d4e086b0dc..501b576caf0e 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -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 diff --git a/gcc/ada/restrict.ads b/gcc/ada/restrict.ads index b6c93f8a7d74..ef5c2c727cfa 100644 --- a/gcc/ada/restrict.ads +++ b/gcc/ada/restrict.ads @@ -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, diff --git a/gcc/ada/s-rident.ads b/gcc/ada/s-rident.ads index 4f22a1943dda..181530d117b8 100644 --- a/gcc/ada/s-rident.ads +++ b/gcc/ada/s-rident.ads @@ -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)) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index f9bf2a3fb4ef..da4252d67944 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -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; diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 48982bd4b5b7..8c6747261241 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -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 diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 0639e97259c8..d85e903419ca 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -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) diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index 9d40a8594a47..efaa63cac0c3 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -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. diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index 4c282132abdd..4bb9d4f34fec 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -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 --