From 62be5d0aad9a968382ad5299f47189ca2a8faa59 Mon Sep 17 00:00:00 2001 From: Javier Miranda Date: Tue, 2 Aug 2011 10:44:29 +0000 Subject: [PATCH] sem_ch5.adb (Analyze_Iteration_Scheme): Fix typo. 2011-08-02 Javier Miranda * sem_ch5.adb (Analyze_Iteration_Scheme): Fix typo. * gcc-interface/Make-lang.in: Update dependencies. 2011-08-02 Javier Miranda * sem_util.ads, sem_util.adb (Is_Variable): Add a new formal to determine if the analysis is performed using N or Original_Node (N). * exp_util.adb (Side_Effect_Free): Code cleanup since the new functionality of routine Is_Variable avoids code duplication. * checks.adb (Determine_Range): Handle temporaries generated by Remove_Side_Effects. 2011-08-02 Javier Miranda * exp_ch4.adb (Expand_N_Quantified_Expression): Force reanalysis and expansion of the condition. Required since the previous analysis was done with expansion disabled (see Resolve_Quantified_Expression) and hence checks were not inserted and record comparisons have not been expanded. From-SVN: r177132 --- gcc/ada/ChangeLog | 22 ++++++++++++++++++++++ gcc/ada/checks.adb | 14 ++++++++++++++ gcc/ada/exp_ch4.adb | 7 +++++++ gcc/ada/exp_util.adb | 22 +--------------------- gcc/ada/gcc-interface/Make-lang.in | 29 +++++++++++++++-------------- gcc/ada/sem_ch5.adb | 2 +- gcc/ada/sem_util.adb | 25 +++++++++++++++++-------- gcc/ada/sem_util.ads | 7 ++++++- 8 files changed, 83 insertions(+), 45 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index f9e1bda9c21..c60ff137195 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,25 @@ +2011-08-02 Javier Miranda + + * sem_ch5.adb (Analyze_Iteration_Scheme): Fix typo. + * gcc-interface/Make-lang.in: Update dependencies. + +2011-08-02 Javier Miranda + + * sem_util.ads, sem_util.adb (Is_Variable): Add a new formal to + determine if the analysis is performed using N or Original_Node (N). + * exp_util.adb (Side_Effect_Free): Code cleanup since the new + functionality of routine Is_Variable avoids code duplication. + * checks.adb (Determine_Range): Handle temporaries generated by + Remove_Side_Effects. + +2011-08-02 Javier Miranda + + * exp_ch4.adb (Expand_N_Quantified_Expression): Force reanalysis and + expansion of the condition. Required since the previous analysis was + done with expansion disabled (see Resolve_Quantified_Expression) and + hence checks were not inserted and record comparisons have not been + expanded. + 2011-08-02 Ed Falis * s-taprop-vxworks.adb, s-intman-vxworks.adb, s-intman-vxworks.ads: diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index a1a91b6d7a3..cfd5fc7a49b 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -3087,6 +3087,20 @@ package body Checks is -- Start of processing for Determine_Range begin + -- For temporary constants internally generated to remove side effects + -- we must use the corresponding expression to determine the range of + -- the expression. + + if Is_Entity_Name (N) + and then Nkind (Parent (Entity (N))) = N_Object_Declaration + and then Ekind (Entity (N)) = E_Constant + and then Is_Internal_Name (Chars (Entity (N))) + then + Determine_Range + (Expression (Parent (Entity (N))), OK, Lo, Hi, Assume_Valid); + return; + end if; + -- Prevent junk warnings by initializing range variables Lo := No_Uint; diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index c8ba5e57c79..09d9e75f596 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -7502,6 +7502,13 @@ package body Exp_Ch4 is Cond := Relocate_Node (Condition (N)); + -- Reset flag analyzed in the condition to force its analysis. Required + -- since the previous analysis was done with expansion disabled (see + -- Resolve_Quantified_Expression) and hence checks were not inserted + -- and record comparisons have not been expanded. + + Reset_Analyzed_Flags (Cond); + if Is_Universal then Cond := Make_Op_Not (Loc, Cond); end if; diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 80c806c7ae4..9a5eef05b6e 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -4692,32 +4692,12 @@ package body Exp_Util is if Is_Entity_Name (N) then - -- If the entity is a constant, it is definitely side effect free. - -- Note that the test of Is_Variable (N) below might be expected - -- to catch this case, but it does not, because this test goes to - -- the original tree, and we may have already rewritten a variable - -- node with a constant as a result of an earlier Force_Evaluation - -- call. - - if Ekind_In (Entity (N), E_Constant, E_In_Parameter) then - return True; - - -- Functions are not side effect free - - elsif Ekind (Entity (N)) = E_Function then - return False; - -- Variables are considered to be a side effect if Variable_Ref -- is set or if we have a volatile reference and Name_Req is off. -- If Name_Req is True then we can't help returning a name which -- effectively allows multiple references in any case. - -- Need comment for Is_True_Constant test below ??? - - elsif Is_Variable (N) - or else (Ekind (Entity (N)) = E_Variable - and then not Is_True_Constant (Entity (N))) - then + if Is_Variable (N, Use_Original_Node => False) then return not Variable_Ref and then (not Is_Volatile_Reference (N) or else Name_Req); diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in index 7e43d966f98..b5cc34ee22d 100644 --- a/gcc/ada/gcc-interface/Make-lang.in +++ b/gcc/ada/gcc-interface/Make-lang.in @@ -3574,20 +3574,21 @@ ada/sem_ch5.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/atree.adb ada/casing.ads ada/checks.ads ada/checks.adb \ ada/csets.ads ada/debug.ads ada/debug_a.ads ada/einfo.ads ada/einfo.adb \ ada/elists.ads ada/err_vars.ads ada/errout.ads ada/erroutc.ads \ - ada/eval_fat.ads ada/exp_ch11.ads ada/exp_ch2.ads ada/exp_ch4.ads \ - ada/exp_ch6.ads ada/exp_ch7.ads ada/exp_code.ads ada/exp_disp.ads \ - ada/exp_pakd.ads ada/exp_tss.ads ada/exp_util.ads ada/expander.ads \ - ada/fname.ads ada/freeze.ads ada/get_targ.ads ada/gnat.ads \ - ada/g-hesorg.ads ada/g-htable.ads ada/hostparm.ads ada/interfac.ads \ - ada/itypes.ads ada/lib.ads ada/lib-xref.ads ada/namet.ads ada/namet.adb \ - ada/nlists.ads ada/nlists.adb ada/nmake.ads ada/nmake.adb ada/opt.ads \ - ada/output.ads ada/par_sco.ads ada/restrict.ads ada/rident.ads \ - ada/rtsfind.ads ada/scans.ads ada/sem.ads ada/sem_aggr.ads \ - ada/sem_attr.ads ada/sem_aux.ads ada/sem_case.ads ada/sem_case.adb \ - ada/sem_cat.ads ada/sem_ch13.ads ada/sem_ch3.ads ada/sem_ch4.ads \ - ada/sem_ch5.ads ada/sem_ch5.adb ada/sem_ch6.ads ada/sem_ch8.ads \ - ada/sem_disp.ads ada/sem_dist.ads ada/sem_elab.ads ada/sem_elim.ads \ - ada/sem_eval.ads ada/sem_eval.adb ada/sem_intr.ads ada/sem_res.ads \ + ada/eval_fat.ads ada/exp_aggr.ads ada/exp_ch11.ads ada/exp_ch2.ads \ + ada/exp_ch4.ads ada/exp_ch6.ads ada/exp_ch7.ads ada/exp_code.ads \ + ada/exp_disp.ads ada/exp_pakd.ads ada/exp_tss.ads ada/exp_util.ads \ + ada/exp_util.adb ada/expander.ads ada/fname.ads ada/freeze.ads \ + ada/get_targ.ads ada/gnat.ads ada/g-hesorg.ads ada/g-htable.ads \ + ada/hostparm.ads ada/inline.ads ada/interfac.ads ada/itypes.ads \ + ada/lib.ads ada/lib-xref.ads ada/namet.ads ada/namet.adb ada/nlists.ads \ + ada/nlists.adb ada/nmake.ads ada/nmake.adb ada/opt.ads ada/output.ads \ + ada/par_sco.ads ada/restrict.ads ada/rident.ads ada/rtsfind.ads \ + ada/scans.ads ada/sem.ads ada/sem_aggr.ads ada/sem_attr.ads \ + ada/sem_aux.ads ada/sem_case.ads ada/sem_case.adb ada/sem_cat.ads \ + ada/sem_ch13.ads ada/sem_ch3.ads ada/sem_ch4.ads ada/sem_ch5.ads \ + ada/sem_ch5.adb ada/sem_ch6.ads ada/sem_ch8.ads ada/sem_disp.ads \ + ada/sem_dist.ads ada/sem_elab.ads ada/sem_elim.ads ada/sem_eval.ads \ + ada/sem_eval.adb ada/sem_intr.ads ada/sem_prag.ads ada/sem_res.ads \ ada/sem_res.adb ada/sem_type.ads ada/sem_util.ads ada/sem_util.adb \ ada/sem_warn.ads ada/sem_warn.adb ada/sinfo.ads ada/sinfo.adb \ ada/sinfo-cn.ads ada/sinput.ads ada/snames.ads ada/sprint.ads \ diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index c665c2d04c3..4c6c9a26b55 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -1602,7 +1602,7 @@ package body Sem_Ch5 is -- proper trace of the value, useful in optimizations that get rid -- of junk range checks. - if not Has_Call_Using_Secondary_Stack (N) then + if not Has_Call_Using_Secondary_Stack (Original_Bound) then Force_Evaluation (Original_Bound); return Original_Bound; end if; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 1ef8b833729..8f285d78e49 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -7508,14 +7508,11 @@ package body Sem_Util is -- Is_Variable -- ----------------- - function Is_Variable (N : Node_Id) return Boolean is - - Orig_Node : constant Node_Id := Original_Node (N); - -- We do the test on the original node, since this is basically a test - -- of syntactic categories, so it must not be disturbed by whatever - -- rewriting might have occurred. For example, an aggregate, which is - -- certainly NOT a variable, could be turned into a variable by - -- expansion. + function Is_Variable + (N : Node_Id; + Use_Original_Node : Boolean := True) return Boolean + is + Orig_Node : Node_Id; function In_Protected_Function (E : Entity_Id) return Boolean; -- Within a protected function, the private components of the enclosing @@ -7580,6 +7577,18 @@ package body Sem_Util is -- Start of processing for Is_Variable begin + -- Check if we perform the test on the original node since this may be a + -- test of syntactic categories which must not be disturbed by whatever + -- rewriting might have occurred. For example, an aggregate, which is + -- certainly NOT a variable, could be turned into a variable by + -- expansion. + + if Use_Original_Node then + Orig_Node := Original_Node (N); + else + Orig_Node := N; + end if; + -- Definitely OK if Assignment_OK is set. Since this is something that -- only gets set for expanded nodes, the test is on N, not Orig_Node. diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index d10b53f982a..6625d3fc878 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -866,13 +866,18 @@ package Sem_Util is -- object used to represent access-to-subprogram types. This is only -- relevant to CIL, will always return false for other targets. - function Is_Variable (N : Node_Id) return Boolean; + function Is_Variable + (N : Node_Id; + Use_Original_Node : Boolean := True) return Boolean; -- Determines if the tree referenced by N represents a variable, i.e. can -- appear on the left side of an assignment. There is one situation (formal -- parameters) in which non-tagged type conversions are also considered -- variables, but Is_Variable returns False for such cases, since it has -- no knowledge of the context. Note that this is the point at which -- Assignment_OK is checked, and True is returned for any tree thus marked. + -- Use_Original_Node is used to perform the test on Original_Node (N). By + -- default is True since this routine is commonly invoked as part of the + -- semantic analysis and it must not be disturbed by the rewriten nodes. function Is_Visibly_Controlled (T : Entity_Id) return Boolean; -- Check whether T is derived from a visibly controlled type. This is true -- 2.30.2