[PATCH] Fix -fno-automatic with variable length arrays (PR fortran/28415)
Steve Kargl
sgk@troutmask.apl.washington.edu
Thu Oct 5 18:57:00 GMT 2006
On Thu, Oct 05, 2006 at 12:38:47PM -0400, Jakub Jelinek wrote:
>
> 2006-10-05 Jakub Jelinek <jakub@redhat.com>
>
> PR fortran/28415
> * trans-decl.c (gfc_finish_var_decl): With -fno-automatic, don't
> make artificial variables or pointer to variable automatic array
> TREE_STATIC.
>
> * gfortran.dg/pr28415.f90: New test.
OK with two comments.
1) Normally, gfortran testsuite programs have names other
than the PR number. In your case, perhaps, auto_array_2.f90
> --- gcc/fortran/trans-decl.c.jj 2006-10-05 00:27:43.000000000 +0200
> +++ gcc/fortran/trans-decl.c 2006-10-05 18:09:39.000000000 +0200
> @@ -511,7 +511,14 @@ gfc_finish_var_decl (tree decl, gfc_symb
> /* Keep variables larger than max-stack-var-size off stack. */
> if (!sym->ns->proc_name->attr.recursive
> && INTEGER_CST_P (DECL_SIZE_UNIT (decl))
> - && !gfc_can_put_var_on_stack (DECL_SIZE_UNIT (decl)))
> + && !gfc_can_put_var_on_stack (DECL_SIZE_UNIT (decl))
> + /* Don't put variable length auto array pointers off stack. */
To me at least, this comment is hard to parse. I interpret
it to be "Put variable length auto array pointers on the stack".
Is this correct?
> + && (TREE_CODE (TREE_TYPE (decl)) != POINTER_TYPE
> + || sym->attr.dimension == 0
> + || sym->as->type != AS_EXPLICIT
> + || sym->attr.pointer
> + || sym->attr.allocatable)
> + && !DECL_ARTIFICIAL (decl))
> TREE_STATIC (decl) = 1;
>
> /* Handle threadprivate variables. */
> --- gcc/testsuite/gfortran.dg/pr28415.f90.jj 2006-10-05 18:25:19.000000000 +0200
> +++ gcc/testsuite/gfortran.dg/pr28415.f90 2006-10-05 18:14:14.000000000 +0200
> @@ -0,0 +1,22 @@
> +! PR fortran/28415
> +! { dg-do run }
> +! { dg-options "-O2 -fno-automatic" }
> +
> + program foo
> + integer arrlen
> + arrlen = 30
> + call bar(arrlen)
> + stop
> + end
> +
> + subroutine bar(arg)
> + integer arg
> + double precision arr(arg)
> + do i = 1, arg
> + arr(i) = 1.0d0
> + enddo
> + do i = 1, arg
> + write(*,*) i, arr(i)
> + enddo
> + return
> + end
>
> Jakub
--
Steve
More information about the Fortran
mailing list