[gfortran] Maybe Fix PR 17077 (Re: Adjustable array segfaults WORKAROUIND)
Paul Brook
paul@codesourcery.com
Fri Aug 20 13:34:00 GMT 2004
On Friday 20 August 2004 06:27, Canqun Yang wrote:
> 2004-08-20 Canqun Yang <canqun@nudt.edu.cn>
>
>
> PR fortran/17077
> * trans-array.c (gfc_is_automatic_array): New
> function.
> (gfc_conv_array_parameter): Don't pass address
> of the automatic array.
You proposed solution does work, however it's introducing a duplicate check
for something that has already been decided (is the array automatic). This
means we now have two places to keep this logic up to date.
I changed it to use to type of the variable to decide whether to take teh
address. This is consistent with other bits of the compiler.
Tested on i686-linux.
Applied to mainline.
Paul
2004-08-20 Paul Brook <paul@codesourcery.com>
Canqun Yang <canqun@nudt.edu.cn>
PR fortran/17077
* trans-array.c (gfc_conv_array_parameter): Pass correct pointer
for automatic arrays.
* trans-types.c (gfc_get_nodesc_array_type): Add comment.
testsuite/
* gfortran.dg/auto_array_1.f90: New test.
Index: fortran/trans-array.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/fortran/trans-array.c,v
retrieving revision 1.17
diff -u -p -r1.17 trans-array.c
--- fortran/trans-array.c 17 Aug 2004 15:34:09 -0000 1.17
+++ fortran/trans-array.c 20 Aug 2004 13:16:05 -0000
@@ -3762,10 +3762,12 @@ gfc_conv_array_parameter (gfc_se * se, g
if (!sym->attr.pointer && sym->as->type != AS_ASSUMED_SHAPE
&& !sym->attr.allocatable)
{
- if (!sym->attr.dummy)
- se->expr = gfc_build_addr_expr (NULL, tmp);
+ /* Some variables are declared directly, others are declard as
+ pointers and allocated on the heap. */
+ if (sym->attr.dummy || POINTER_TYPE_P (TREE_TYPE (tmp)))
+ se->expr = tmp;
else
- se->expr = tmp;
+ se->expr = gfc_build_addr_expr (NULL, tmp);
return;
}
if (sym->attr.allocatable)
Index: fortran/trans-types.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/fortran/trans-types.c,v
retrieving revision 1.10
diff -u -p -r1.10 trans-types.c
--- fortran/trans-types.c 18 Aug 2004 13:08:08 -0000 1.10
+++ fortran/trans-types.c 20 Aug 2004 13:27:52 -0000
@@ -750,6 +750,8 @@ gfc_get_nodesc_array_type (tree etype, g
if (packed < 3 || !known_stride)
{
+ /* For dummy arrays and automatic (heap allocated) arrays we
+ want a pointer to the array. */
type = build_pointer_type (type);
GFC_ARRAY_TYPE_P (type) = 1;
TYPE_LANG_SPECIFIC (type) = TYPE_LANG_SPECIFIC (TREE_TYPE (type));
More information about the Fortran
mailing list