From: Arnaud Charlet Date: Tue, 4 Feb 2014 14:49:39 +0000 (+0100) Subject: [multiple changes] X-Git-Tag: releases/gcc-4.9.0~1104 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2db5b47e6d87fd9f76c11cb578a8b0e7fdeca87e;p=thirdparty%2Fgcc.git [multiple changes] 2014-02-04 Gary Dismukes * sem_aggr.adb: Change "runtime" to "run time" in warning message, for consistency with other messages. 2014-02-04 Ed Schonberg * 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 * 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 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index cab52638c8d4..8f43cfe9de64 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,24 @@ +2014-02-04 Gary Dismukes + + * sem_aggr.adb: Change "runtime" to "run time" in warning message, + for consistency with other messages. + +2014-02-04 Ed Schonberg + + * 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 + + * 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 * exp_ch13.adb: Minor spelling fix. diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index e006455dbc27..fae25dee0fdc 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 e563ccf8edc5..d64d0c82a93e 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 440d562ce5ce..ad74fba927b8 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 54c106db9387..8810f4db07f3 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 504ddcd38be3..6ba4c120ebd9 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 773929dcf3ab..da5c6002ac1e 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