+2009-07-04 Jakub Jelinek <jakub@redhat.com>
+
+ * trans-intrinsic.c (gfc_conv_intrinsic_minmaxloc): For integer
+ maxloc initialize limit to -huge-1 rather than just -huge.
+
2009-07-04 Janus Weil <janus@gcc.gnu.org>
PR fortran/40593
possible value is HUGE in both cases. */
if (op == GT_EXPR)
tmp = fold_build1 (NEGATE_EXPR, TREE_TYPE (tmp), tmp);
- gfc_add_modify (&se->pre, limit, tmp);
-
if (op == GT_EXPR && expr->ts.type == BT_INTEGER)
tmp = fold_build2 (MINUS_EXPR, TREE_TYPE (tmp), tmp,
build_int_cst (type, 1));
+ gfc_add_modify (&se->pre, limit, tmp);
+
/* Initialize the scalarizer. */
gfc_init_loopinfo (&loop);
gfc_add_ss_to_loop (&loop, arrayss);
--- /dev/null
+! { dg-do run }
+ integer :: a(3), n
+ a(1) = -huge(n)
+ a(2) = -huge(n)
+ a(3) = -huge(n)
+ a(1) = a(1) - 1
+ a(2) = a(2) - 1
+ a(3) = a(3) - 1
+ n = maxloc (a, dim = 1)
+ if (n .ne. 1) call abort
+ a(2) = -huge(n)
+ n = maxloc (a, dim = 1)
+ if (n .ne. 2) call abort
+end