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] PR fortran/58989


Hi Steve,

It looks good to me - OK for trunk.

Thanks for the patch.

Paul

On 5 November 2013 18:07, Steve Kargl <sgk@troutmask.apl.washington.edu> wrote:
> The inlined patch fixes a problem where an array constructor
> is used as the shape argument in RESHAPE.  The patch is
> straightforward and self-explanatory.
> Regression tested on x86_64-*-freebsd11
> Ok?
>
> 2013-11-05  Steven G. Kargl <kargl@gcc.gnu.org>
>
>         PR fortran/58989
>         * check.c (gfc_check_reshape): ensure that shape is a constant
>         expression.
>
> 2013-11-05  Steven G. Kargl <kargl@gcc.gnu.org>
>
>         PR fortran/58989
>         * gfortran.dg/reshape_6.f90: New test.
>
>
> Index: gcc/fortran/check.c
> ===================================================================
> --- gcc/fortran/check.c (revision 204372)
> +++ gcc/fortran/check.c (working copy)
> @@ -3277,7 +3277,7 @@ gfc_check_reshape (gfc_expr *source, gfc
>                  "than %d elements", &shape->where, GFC_MAX_DIMENSIONS);
>        return false;
>      }
> -  else if (shape->expr_type == EXPR_ARRAY)
> +  else if (shape->expr_type == EXPR_ARRAY && gfc_is_constant_expr (shape))
>      {
>        gfc_expr *e;
>        int i, extent;
> Index: gcc/testsuite/gfortran.dg/reshape_6.f90
> ===================================================================
> --- gcc/testsuite/gfortran.dg/reshape_6.f90     (revision 0)
> +++ gcc/testsuite/gfortran.dg/reshape_6.f90     (working copy)
> @@ -0,0 +1,19 @@
> +! { dg-do compile }
> +! PR fortran/58989
> +!
> +program test
> +
> +  real(8), dimension(4,4) :: fluxes
> +  real(8), dimension(2,2,2,2) :: f
> +  integer, dimension(3) :: dmmy
> +  integer, parameter :: indx(4)=(/2,2,2,2/)
> +
> +  fluxes = 1
> +
> +  dmmy = (/2,2,2/)
> +
> +  f = reshape(fluxes,(/dmmy,2/))  ! Caused an ICE
> +  f = reshape(fluxes,(/2,2,2,2/)) ! Works as expected
> +  f = reshape(fluxes,indx)        ! Works as expected
> +
> +end program test
> --
> Steve



-- 
The knack of flying is learning how to throw yourself at the ground and miss.
       --Hitchhikers Guide to the Galaxy


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