diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-02-04 15:49:39 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-02-04 15:49:39 +0100 |
commit | 2db5b47e6d87fd9f76c11cb578a8b0e7fdeca87e (patch) | |
tree | 756cc1baf04f8f93de206f9821d2ef6c57cd187b | |
parent | 5a521b8ade74674b926ba242e3449ba094274bc3 (diff) | |
download | gcc-2db5b47e6d87fd9f76c11cb578a8b0e7fdeca87e.zip gcc-2db5b47e6d87fd9f76c11cb578a8b0e7fdeca87e.tar.gz gcc-2db5b47e6d87fd9f76c11cb578a8b0e7fdeca87e.tar.bz2 |
[multiple changes]
2014-02-04 Gary Dismukes <dismukes@adacore.com>
* sem_aggr.adb: Change "runtime" to "run time" in warning message,
for consistency with other messages.
2014-02-04 Ed Schonberg <schonberg@adacore.com>
* exp_ch5.adb (Expand_Iterator_Loop): For a container element
iterator, indicate that the element is a constant if the container
type does not have a variable indexing aspect.
* sem_ch8.adb (Analyze_Object_Renaming): If the entity is already
marked as constant, do not reset its Ekind, to ensure that
container elements in an element loop are not modified if the
container (e.g. a hashed set) only has a constant indexing aspect.
2014-02-04 Arnaud Charlet <charlet@adacore.com>
* g-souinf.ads: Subprograms in this unit are actually not pure.
* freeze.adb (Freeze_Subprogram): Do not reset Is_Pure for Intrinsics.
* einfo.ads (Is_Pure): Update doc to match implementation.
From-SVN: r207469
-rw-r--r-- | gcc/ada/ChangeLog | 21 | ||||
-rw-r--r-- | gcc/ada/einfo.ads | 14 | ||||
-rw-r--r-- | gcc/ada/exp_ch5.adb | 9 | ||||
-rw-r--r-- | gcc/ada/freeze.adb | 12 | ||||
-rw-r--r-- | gcc/ada/g-souinf.ads | 11 | ||||
-rw-r--r-- | gcc/ada/sem_aggr.adb | 2 | ||||
-rw-r--r-- | gcc/ada/sem_ch8.adb | 8 |
7 files changed, 61 insertions, 16 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index cab5263..8f43cfe 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,26 @@ 2014-02-04 Gary Dismukes <dismukes@adacore.com> + * sem_aggr.adb: Change "runtime" to "run time" in warning message, + for consistency with other messages. + +2014-02-04 Ed Schonberg <schonberg@adacore.com> + + * exp_ch5.adb (Expand_Iterator_Loop): For a container element + iterator, indicate that the element is a constant if the container + type does not have a variable indexing aspect. + * sem_ch8.adb (Analyze_Object_Renaming): If the entity is already + marked as constant, do not reset its Ekind, to ensure that + container elements in an element loop are not modified if the + container (e.g. a hashed set) only has a constant indexing aspect. + +2014-02-04 Arnaud Charlet <charlet@adacore.com> + + * g-souinf.ads: Subprograms in this unit are actually not pure. + * freeze.adb (Freeze_Subprogram): Do not reset Is_Pure for Intrinsics. + * einfo.ads (Is_Pure): Update doc to match implementation. + +2014-02-04 Gary Dismukes <dismukes@adacore.com> + * exp_ch13.adb: Minor spelling fix. 2014-02-04 Robert Dewar <dewar@adacore.com> diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index e006455..fae25de 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -2775,13 +2775,13 @@ package Einfo is -- Is_Pure (Flag44) -- Defined in all entities. Set in all entities of a unit to which a --- pragma Pure is applied, and also set for the entity of the unit --- itself. In addition, this flag may be set for any other functions --- or procedures that are known to be side effect free, so in the case --- of subprograms, the Is_Pure flag may be used by the optimizer to --- imply that it can assume freedom from side effects (other than those --- resulting from assignment to out parameters, or to objects designated --- by access parameters). +-- pragma Pure is applied except for non intrinsic imported subprogram, +-- and also set for the entity of the unit itself. In addition, this +-- flag may be set for any other functions or procedures that are known +-- to be side effect free, so in the case of subprograms, the Is_Pure +-- flag may be used by the optimizer to imply that it can assume freedom +-- from side effects (other than those resulting from assignment to out +-- parameters, or to objects designated by access parameters). -- Is_Pure_Unit_Access_Type (Flag189) -- Defined in access type and subtype entities. Set if the type or diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index e563ccf..d64d0c8 100644 --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -3128,6 +3128,15 @@ package body Exp_Ch5 is Set_Debug_Info_Needed (Id); + -- If the container does not have a variable indexing aspect, + -- the element is a constant in the loop. + + if No (Find_Value_Of_Aspect + (Container_Typ, Aspect_Variable_Indexing)) + then + Set_Ekind (Id, E_Constant); + end if; + -- If the container holds controlled objects, wrap the loop -- statements and element renaming declaration with a block. -- This ensures that the result of Element (Cusor) is diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 440d562..ad74fba 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -6514,15 +6514,17 @@ package body Freeze is end if; -- Reset the Pure indication on an imported subprogram unless an - -- explicit Pure_Function pragma was present. We do this because - -- otherwise it is an insidious error to call a non-pure function from - -- pure unit and have calls mysteriously optimized away. What happens - -- here is that the Import can bypass the normal check to ensure that - -- pure units call only pure subprograms. + -- explicit Pure_Function pragma was present or the subprogram is an + -- intrinsic. We do this because otherwise it is an insidious error + -- to call a non-pure function from pure unit and have calls + -- mysteriously optimized away. What happens here is that the Import + -- can bypass the normal check to ensure that pure units call only pure + -- subprograms. if Is_Imported (E) and then Is_Pure (E) and then not Has_Pragma_Pure_Function (E) + and then not Is_Intrinsic_Subprogram (E) then Set_Is_Pure (E, False); end if; diff --git a/gcc/ada/g-souinf.ads b/gcc/ada/g-souinf.ads index 54c106d..8810f4d 100644 --- a/gcc/ada/g-souinf.ads +++ b/gcc/ada/g-souinf.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2000-2005 AdaCore -- +-- Copyright (C) 2000-2013, 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,7 +37,14 @@ -- the name of the source file in which the exception is handled. package GNAT.Source_Info is - pragma Pure; + pragma Preelaborate; + -- Note that this unit is Preelaborate, but not Pure, that's because the + -- functions here such as Line are clearly not pure functions, and normally + -- we mark intrinsic functions in a Pure unit as Pure, even though they are + -- imported. + -- + -- Historical note: this used to be Pure, but that was when we marked all + -- intrinsics as not Pure, even in Pure units, so no problems arose. function File return String; -- Return the name of the current file, not including the path information. diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index 504ddcd..6ba4c12 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -4743,7 +4743,7 @@ package body Sem_Aggr is Error_Msg_N ("(Ada 2005) null not allowed in null-excluding component??", Expr); Error_Msg_N - ("\Constraint_Error will be raised at runtime?", Expr); + ("\Constraint_Error will be raised at run time?", Expr); Rewrite (Expr, Make_Raise_Constraint_Error diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index 773929d..da5c600 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -1193,7 +1193,13 @@ package body Sem_Ch8 is end; end if; - Set_Ekind (Id, E_Variable); + -- Set the Ekind of the entity, unless it has been set already, as is + -- the case for the iteration object over a container with no variable + -- indexing. + + if Ekind (Id) /= E_Constant then + Set_Ekind (Id, E_Variable); + end if; -- Initialize the object size and alignment. Note that we used to call -- Init_Size_Align here, but that's wrong for objects which have only |