From: Javier Miranda Date: Tue, 2 Aug 2011 10:02:23 +0000 (+0000) Subject: exp_util.adb (Safe_Prefixed_Reference): Do not consider safe an in-mode parameter... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cae81f177de95c5de06a61f769f3008925ebcb35;p=gcc.git exp_util.adb (Safe_Prefixed_Reference): Do not consider safe an in-mode parameter whose type is an access type since it... 2011-08-02 Javier Miranda * exp_util.adb (Safe_Prefixed_Reference): Do not consider safe an in-mode parameter whose type is an access type since it can be used to modify its designated object. Enforce code that handles as safe an access type that is not access-to-constant but it is the result of a previous removal of side-effects. (Remove_Side_Effects): Minor code reorganization of cases which require no action. Done to incorporate documentation on new cases uncovered working in this ticket: no action needed if this routine was invoked too early and the nodes are not yet decorated. * sem_res.adb (Resolve_Slice): Minor code cleanup replacling two calls to routine Remove_Side_Effects by calls to Force_Evaluation since they were issued with actuals that are implicitly provided by Force_Evaluation. From-SVN: r177120 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index e7e1283ce96..2ade68e6213 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,19 @@ +2011-08-02 Javier Miranda + + * exp_util.adb (Safe_Prefixed_Reference): Do not consider safe an + in-mode parameter whose type is an access type since it can be used to + modify its designated object. Enforce code that handles as safe an + access type that is not access-to-constant but it is the result of a + previous removal of side-effects. + (Remove_Side_Effects): Minor code reorganization of cases which require + no action. Done to incorporate documentation on new cases uncovered + working in this ticket: no action needed if this routine was invoked + too early and the nodes are not yet decorated. + * sem_res.adb (Resolve_Slice): Minor code cleanup replacling two calls + to routine Remove_Side_Effects by calls to Force_Evaluation since they + were issued with actuals that are implicitly provided by + Force_Evaluation. + 2011-08-02 Robert Dewar * sem_ch3.adb, sem_res.adb: Minor reformatting. diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 03e41c91441..8923702bc3c 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -4616,21 +4616,19 @@ package body Exp_Util is -- If the prefix is of an access type that is not access-to-constant, -- then this construct is a variable reference, which means it is to - -- be considered to have side effects if Variable_Ref is set True - -- Exception is an access to an entity that is a constant or an - -- in-parameter which does not come from source, and is the result - -- of a previous removal of side-effects. + -- be considered to have side effects if Variable_Ref is set True. elsif Is_Access_Type (Etype (Prefix (N))) and then not Is_Access_Constant (Etype (Prefix (N))) and then Variable_Ref then - if not Is_Entity_Name (Prefix (N)) then - return False; - else - return Ekind (Entity (Prefix (N))) = E_Constant - or else Ekind (Entity (Prefix (N))) = E_In_Parameter; - end if; + -- Exception is a prefix that is the result of a previous removal + -- of side-effects. + + return Is_Entity_Name (Prefix (N)) + and then not Comes_From_Source (Prefix (N)) + and then Ekind (Entity (Prefix (N))) = E_Constant + and then Is_Internal_Name (Chars (Entity (Prefix (N)))); -- If the prefix is an explicit dereference then this construct is a -- variable reference, which means it is to be considered to have @@ -4945,10 +4943,24 @@ package body Exp_Util is -- Start of processing for Remove_Side_Effects begin - -- If we are side effect free already or expansion is disabled, - -- there is nothing to do. + -- Handle cases in which there is nothing to do + + if not Expander_Active then + return; + + -- Cannot generate temporaries if the invocation to remove side effects + -- was issued too early and the type of the expression is not resolved + -- (this happens because routines Duplicate_Subexpr_XX implicitly invoke + -- Remove_Side_Effects). + + elsif No (Exp_Type) + or else Ekind (Exp_Type) = E_Access_Attribute_Type + then + return; + + -- No action needed for side-effect free expressions - if Side_Effect_Free (Exp) or else not Expander_Active then + elsif Side_Effect_Free (Exp) then return; end if; diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index d6a1ccfea47..a94ecc27171 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -8631,8 +8631,8 @@ package body Sem_Res is -- Ensure that side effects in the bounds are properly handled - Remove_Side_Effects (Low_Bound (Drange), Variable_Ref => True); - Remove_Side_Effects (High_Bound (Drange), Variable_Ref => True); + Force_Evaluation (Low_Bound (Drange)); + Force_Evaluation (High_Bound (Drange)); -- Do not apply the range check to nodes associated with the -- frontend expansion of the dispatch table. We first check