From 7a41db5b2e39bcfbf513612fbe4f23891f474f07 Mon Sep 17 00:00:00 2001 From: charlet Date: Thu, 17 Jul 2014 06:40:45 +0000 Subject: 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 --- gcc/ada/gnat_rm.texi | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'gcc/ada/gnat_rm.texi') diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index b82931fbbc3..05b3cb44fe1 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 -- cgit v1.2.1