+2007-01-11 Thomas Koenig <Thomas.Koenig@online.de>
+
+ PR libfortran/30415
+ * iresolve.c (gfc_resolve_maxloc): If the rank
+ of the return array is nonzero and we process an
+ integer array smaller than default kind, coerce
+ the array to default integer.
+ * iresolve.c (gfc_resolve_minloc): Likewise.
+
2007-01-11 Brooks Moses <brooks.moses@codesourcery.com>
* simplify.c: Update copyright to 2007.
else
name = "maxloc";
+ /* If the rank of the function is nonzero, we are going to call
+ a library function. Coerce the argument to one of the
+ existing library functions for this case. */
+
+ if (f->rank != 0 && array->ts.type == BT_INTEGER
+ && array->ts.kind < gfc_default_integer_kind)
+ {
+ gfc_typespec ts;
+ ts.type = BT_INTEGER;
+ ts.kind = gfc_default_integer_kind;
+ gfc_convert_type_warn (array, &ts, 2, 0);
+ }
+
f->value.function.name
= gfc_get_string (PREFIX ("%s%d_%d_%c%d"), name, dim != NULL, f->ts.kind,
gfc_type_letter (array->ts.type), array->ts.kind);
else
name = "minloc";
+ /* If the rank of the function is nonzero, we are going to call
+ a library function. Coerce the argument to one of the
+ existing library functions for this case. */
+
+ if (f->rank != 0 && array->ts.type == BT_INTEGER
+ && array->ts.kind < gfc_default_integer_kind)
+ {
+ gfc_typespec ts;
+ ts.type = BT_INTEGER;
+ ts.kind = gfc_default_integer_kind;
+ gfc_convert_type_warn (array, &ts, 2, 0);
+ }
+
f->value.function.name
= gfc_get_string (PREFIX ("%s%d_%d_%c%d"), name, dim != NULL, f->ts.kind,
gfc_type_letter (array->ts.type), array->ts.kind);
--- /dev/null
+! { dg-do link }
+! PR 30415 - minloc and maxloc for integer kinds=1 and 2 were missing
+! Test case by Harald Anlauf
+program gfcbug55
+ integer(kind=1) :: i1(4) = 1
+ integer(kind=2) :: i2(4) = 1
+ print *, minloc(i1), maxloc(i1)
+ print *, minloc(i2), maxloc(i2)
+end program gfcbug55
+