This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [rfa] fix reshape for 64-bit
- From: Richard Henderson <rth at twiddle dot net>
- To: Steven Bosscher <stevenb at suse dot de>
- Cc: fortran at gcc dot gnu dot org, Richard Henderson <rth at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Tue, 7 Dec 2004 01:38:01 -0800
- Subject: Re: [rfa] fix reshape for 64-bit
- References: <20041207065547.GA20109@redhat.com> <200412070846.51827.stevenb@suse.de>
On Tue, Dec 07, 2004 at 08:46:51AM +0100, Steven Bosscher wrote:
> I think we want gfc_convert_type_warn (shape, &ts, 2, 0) here: No warning
> if there has to be a type conversion. (Yes, the naming of these two
> functions is confusing).
Like so?
r~
* intrinsic.c (gfc_convert_type_warn): Copy shape too.
* iresolve.c (gfc_resolve_cshift): Use gfc_convert_type_warn.
(gfc_resolve_eoshift): Likewise.
(gfc_resolve_reshape): Convert SHAPE and ORDER parameters
to index_kind.
Index: intrinsic.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/intrinsic.c,v
retrieving revision 1.32
diff -c -p -d -u -r1.32 intrinsic.c
--- intrinsic.c 2 Dec 2004 04:10:24 -0000 1.32
+++ intrinsic.c 7 Dec 2004 09:33:36 -0000
@@ -3014,6 +3014,7 @@ gfc_convert_type_warn (gfc_expr * expr,
locus old_where;
gfc_expr *new;
int rank;
+ mpz_t *shape;
from_ts = expr->ts; /* expr->ts gets clobbered */
@@ -3050,6 +3051,8 @@ gfc_convert_type_warn (gfc_expr * expr,
/* 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;
@@ -3058,6 +3061,7 @@ gfc_convert_type_warn (gfc_expr * expr,
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 -u -r1.23 iresolve.c
--- iresolve.c 2 Dec 2004 04:10:24 -0000 1.23
+++ iresolve.c 7 Dec 2004 09:33:36 -0000
@@ -421,7 +421,7 @@ gfc_resolve_cshift (gfc_expr * f, gfc_ex
gfc_resolve_index (dim, 1);
/* Convert dim to shift's kind, so we don't need so many variations. */
if (dim->ts.kind != shift->ts.kind)
- gfc_convert_type (dim, &shift->ts, 2);
+ gfc_convert_type_warn (dim, &shift->ts, 2, 0);
}
f->value.function.name =
gfc_get_string ("__cshift%d_%d", n, shift->ts.kind);
@@ -510,7 +510,7 @@ gfc_resolve_eoshift (gfc_expr * f, gfc_e
/* Convert dim to the same type as shift, so we don't need quite so many
variations. */
if (dim != NULL && dim->ts.kind != shift->ts.kind)
- gfc_convert_type (dim, &shift->ts, 2);
+ gfc_convert_type_warn (dim, &shift->ts, 2, 0);
f->value.function.name =
gfc_get_string ("__eoshift%d_%d", n, shift->ts.kind);
@@ -1172,6 +1172,17 @@ gfc_resolve_reshape (gfc_expr * f, gfc_e
c = c->next;
}
}
+
+ /* Force-convert both SHAPE and ORDER to index_kind so that we don't need
+ so many runtime variations. */
+ if (shape->ts.kind != gfc_index_integer_kind)
+ {
+ gfc_typespec ts = shape->ts;
+ ts.kind = gfc_index_integer_kind;
+ gfc_convert_type_warn (shape, &ts, 2, 0);
+ }
+ if (order && order->ts.kind != gfc_index_integer_kind)
+ gfc_convert_type_warn (order, &shape->ts, 2, 0);
}