aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/iresolve.c
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <coudert@clipper.ens.fr>2005-11-27 15:01:36 +0100
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2005-11-27 14:01:36 +0000
commit991bb832494d3e422ef703e317cd0dc21ab74ac3 (patch)
treec6f3cbda99666c39f12216bd3f642f6df5fcb01c /gcc/fortran/iresolve.c
parentb604fe9b84e41f387222758a300dce02a39a6b1b (diff)
downloadgcc-991bb832494d3e422ef703e317cd0dc21ab74ac3.zip
gcc-991bb832494d3e422ef703e317cd0dc21ab74ac3.tar.gz
gcc-991bb832494d3e422ef703e317cd0dc21ab74ac3.tar.bz2
re PR fortran/23912 (MOD function requires same kind arguments)
PR fortran/23912 * iresolve.c (gfc_resolve_dim, gfc_resolve_mod, gfc_resolve_modulo): When arguments have different kinds, fold the lower one to the largest kind. * check.c (gfc_check_a_p): Arguments of different kinds is not a hard error, but an extension. * simplify.c (gfc_simplify_dim, gfc_simplify_mod, gfc_simplify_modulo): When arguments have different kinds, fold the lower one to the largest kind. * gfortran.dg/modulo_1.f90: New test. From-SVN: r107566
Diffstat (limited to 'gcc/fortran/iresolve.c')
-rw-r--r--gcc/fortran/iresolve.c62
1 files changed, 49 insertions, 13 deletions
diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c
index de3c271..e154a34 100644
--- a/gcc/fortran/iresolve.c
+++ b/gcc/fortran/iresolve.c
@@ -523,12 +523,24 @@ gfc_resolve_dble (gfc_expr * f, gfc_expr * a)
void
-gfc_resolve_dim (gfc_expr * f, gfc_expr * x,
- gfc_expr * y ATTRIBUTE_UNUSED)
+gfc_resolve_dim (gfc_expr * f, gfc_expr * a, gfc_expr * p)
{
- f->ts = x->ts;
+ f->ts.type = a->ts.type;
+ if (p != NULL)
+ f->ts.kind = gfc_kind_max (a,p);
+ else
+ f->ts.kind = a->ts.kind;
+
+ if (p != NULL && a->ts.kind != p->ts.kind)
+ {
+ if (a->ts.kind == gfc_kind_max (a,p))
+ gfc_convert_type(p, &a->ts, 2);
+ else
+ gfc_convert_type(a, &p->ts, 2);
+ }
+
f->value.function.name =
- gfc_get_string ("__dim_%c%d", gfc_type_letter (x->ts.type), x->ts.kind);
+ gfc_get_string ("__dim_%c%d", gfc_type_letter (f->ts.type), f->ts.kind);
}
@@ -1179,23 +1191,47 @@ gfc_resolve_minval (gfc_expr * f, gfc_expr * array, gfc_expr * dim,
void
-gfc_resolve_mod (gfc_expr * f, gfc_expr * a,
- gfc_expr * p ATTRIBUTE_UNUSED)
+gfc_resolve_mod (gfc_expr * f, gfc_expr * a, gfc_expr * p)
{
- f->ts = a->ts;
+ f->ts.type = a->ts.type;
+ if (p != NULL)
+ f->ts.kind = gfc_kind_max (a,p);
+ else
+ f->ts.kind = a->ts.kind;
+
+ if (p != NULL && a->ts.kind != p->ts.kind)
+ {
+ if (a->ts.kind == gfc_kind_max (a,p))
+ gfc_convert_type(p, &a->ts, 2);
+ else
+ gfc_convert_type(a, &p->ts, 2);
+ }
+
f->value.function.name =
- gfc_get_string ("__mod_%c%d", gfc_type_letter (a->ts.type), a->ts.kind);
+ gfc_get_string ("__mod_%c%d", gfc_type_letter (f->ts.type), f->ts.kind);
}
void
-gfc_resolve_modulo (gfc_expr * f, gfc_expr * a,
- gfc_expr * p ATTRIBUTE_UNUSED)
+gfc_resolve_modulo (gfc_expr * f, gfc_expr * a, gfc_expr * p)
{
- f->ts = a->ts;
+ f->ts.type = a->ts.type;
+ if (p != NULL)
+ f->ts.kind = gfc_kind_max (a,p);
+ else
+ f->ts.kind = a->ts.kind;
+
+ if (p != NULL && a->ts.kind != p->ts.kind)
+ {
+ if (a->ts.kind == gfc_kind_max (a,p))
+ gfc_convert_type(p, &a->ts, 2);
+ else
+ gfc_convert_type(a, &p->ts, 2);
+ }
+
f->value.function.name =
- gfc_get_string ("__modulo_%c%d", gfc_type_letter (a->ts.type),
- a->ts.kind);
+ gfc_get_string ("__modulo_%c%d", gfc_type_letter (f->ts.type),
+ f->ts.kind);
}
void