This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, fortran] PR29821 - Ping


Paul Thomas wrote:
Ping!

See: http://gcc.gnu.org/ml/fortran/2006-11/msg00577.html

This ice-on-valid-code fix was posted on 21st Novemeber.

Paul
:ADDPATCH fortran:

This patch and its testcase are self-explanatory. I spent a lot of time trying to fix the rules of engagement of gfc_simplify_expr, as described in its heading comment. In principle, this should return FAILURE only if an error has been found. If simplification has not occurred, it should be up to the caller to detect this. Apparently, this rule has been multiply violated and FAILURE is being used to indicate a lack of simplification. The most immediate example of this is my fault; in find_array_section, where non-constant index expressions return FAILURE. Changing this to SUCCESS fixes this problem but breaks other things. Fixing those, cascades down to cause more breakages. I therefore took a middle path and did a test in the caller, which is resolve_operator here, to see if the expression is constant before returning the result of the call to gfc_simplify_expr. In fact, I am not convinced that the result should be returned here at all - removing it breaks nothing. I would be open to the reviewer suggesting that course of action :-)

Regtested on suse10.1/amd64 - OK for trunk, 4.2 and 4.1?

Paul

2006-11-21 Paul Thomas <pault@gcc.gnu.org>

   PR fortran/29821
   * resolve.c (resolve_operator): Only return result of
   gfc_simplify_expr if expression is constant.

2006-11-21 Paul Thomas <pault@gcc.gnu.org>

   PR fortran/29821
   * gfortran.dg/parameter_array_section_1.f90: New test.

------------------------------------------------------------------------

Index: gcc/fortran/resolve.c
===================================================================
*** gcc/fortran/resolve.c (revision 118704)
--- gcc/fortran/resolve.c (working copy)
*************** resolve_operator (gfc_expr * e)
*** 2199,2205 ****
/* Attempt to simplify the expression. */
if (t == SUCCESS)
! t = gfc_simplify_expr (e, 0);
return t;
bad_op:
--- 2199,2212 ----
/* Attempt to simplify the expression. */
if (t == SUCCESS)
! {
! t = gfc_simplify_expr (e, 0);
! /* Some calls do not succeed in simplification and return FAILURE
! even though there is no error; eg. variable references to
! PARAMETER arrays. */
! if (!gfc_is_constant_expr (e))
! t = SUCCESS;
! }
return t;
bad_op:
Index: gcc/testsuite/gfortran.dg/parameter_array_section_1.f90
===================================================================
*** gcc/testsuite/gfortran.dg/parameter_array_section_1.f90 (revision 0)
--- gcc/testsuite/gfortran.dg/parameter_array_section_1.f90 (revision 0)
***************
*** 0 ****
--- 1,24 ----
+ ! { dg-do compile }
+ ! Tests the fix for PR29821, which was due to failure to simplify the
+ ! array section, since the section is not constant, provoking failure
+ ! to resolve the argument of SUM and therefore to resolve SUM itself.
+ !
+ ! Contributed by Harald Anlauf <anlauf@gmx.de>
+ !
+ module gfcbug45
+ implicit none
+ contains
+ subroutine foo + real, external :: mysum
+ integer :: i
+ real :: a
+ real, parameter :: eps(2) = (/ 1, 99 /)
+ i = 1
+ a = sum (eps(i:i+1) * eps)
+ print *, a
+ end subroutine foo
+ end module gfcbug45
+ use gfcbug45
+ call foo
+ end
+ ! { dg-final { cleanup-modules "gfcbug45" } }


------------------------------------------------------------------------

2006-11-21 Paul Thomas <pault@gcc.gnu.org>

    PR fortran/29821
    * resolve.c (resolve_operator): Only return result of
    gfc_simplify_expr if expression is constant.

2006-11-21 Paul Thomas <pault@gcc.gnu.org>

    PR fortran/29821
    * gfortran.dg/parameter_array_section_1.f90: New test.



OK


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]