trans-intrinsic.c (gfc_conv_intrinsic_minmaxloc): For integer maxloc initialize limit to -huge-1 rather than just -huge.

* trans-intrinsic.c (gfc_conv_intrinsic_minmaxloc): For integer
	maxloc initialize limit to -huge-1 rather than just -huge.

	* gfortran.dg/maxloc_1.f90: New test.

From-SVN: r149236
This commit is contained in:
Jakub Jelinek 2009-07-04 19:20:46 +02:00 committed by Jakub Jelinek
parent bd5b2c2d07
commit 258bd5dcfd
4 changed files with 25 additions and 2 deletions

View file

@ -1,3 +1,8 @@
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

View file

@ -2190,12 +2190,12 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op)
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);

View file

@ -1,3 +1,7 @@
2009-07-04 Jakub Jelinek <jakub@redhat.com>
* gfortran.dg/maxloc_1.f90: New test.
2009-07-04 Janus Weil <janus@gcc.gnu.org>
PR fortran/40593

View file

@ -0,0 +1,14 @@
! { 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