[rfa] fix reshape for 64-bit

Richard Henderson rth@redhat.com
Tue Dec 7 06:56:00 GMT 2004


Thanks to Tobias for the pointer to gfc_convert_type.

The change to gfc_convert_type_warn to copy the shape (if any)
is due to this routine being called twice, once during initial
resolution, and once during a simplify pass.  On the second pass
we'd abort because gfc_array_size couldn't determine the shape
of the SHAPE argument.  It seems like information we'd want to
be preserving about an array operation anyway.

Tested on alpha-linux, where it fixes ~5 sets of failures.

Ok?


r~


Index: intrinsic.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/intrinsic.c,v
retrieving revision 1.32
diff -c -p -d -r1.32 intrinsic.c
*** intrinsic.c	2 Dec 2004 04:10:24 -0000	1.32
--- intrinsic.c	7 Dec 2004 06:49:48 -0000
*************** gfc_convert_type_warn (gfc_expr * expr, 
*** 3014,3019 ****
--- 3014,3020 ----
    locus old_where;
    gfc_expr *new;
    int rank;
+   mpz_t *shape;
  
    from_ts = expr->ts;		/* expr->ts gets clobbered */
  
*************** gfc_convert_type_warn (gfc_expr * expr, 
*** 3050,3055 ****
--- 3051,3058 ----
    /* Insert a pre-resolved function call to the right function.  */
    old_where = expr->where;
    rank = expr->rank;
+   shape = expr->shape;
+ 
    new = gfc_get_expr ();
    *new = *expr;
  
*************** gfc_convert_type_warn (gfc_expr * expr, 
*** 3058,3063 ****
--- 3061,3067 ----
    new->value.function.isym = sym;
    new->where = old_where;
    new->rank = rank;
+   new->shape = gfc_copy_shape (shape, rank);
  
    *expr = *new;
  
Index: iresolve.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/iresolve.c,v
retrieving revision 1.23
diff -c -p -d -r1.23 iresolve.c
*** iresolve.c	2 Dec 2004 04:10:24 -0000	1.23
--- iresolve.c	7 Dec 2004 06:49:48 -0000
*************** gfc_resolve_reshape (gfc_expr * f, gfc_e
*** 1172,1177 ****
--- 1172,1186 ----
  	  c = c->next;
  	}
      }
+ 
+   if (shape->ts.kind != gfc_index_integer_kind)
+     {
+       gfc_typespec ts = shape->ts;
+       ts.kind = gfc_index_integer_kind;
+       gfc_convert_type (shape, &ts, 2);
+     }
+   if (order && order->ts.kind != gfc_index_integer_kind)
+     gfc_convert_type (order, &shape->ts, 2);
  }
  
  



More information about the Fortran mailing list