diff options
author | Tobias Burnus <burnus@gcc.gnu.org> | 2007-02-09 22:56:06 +0100 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2007-02-09 22:56:06 +0100 |
commit | 8811602900dc173f02161c177975be6cc4c60577 (patch) | |
tree | 8c9f83d0bcfb910fd85a30861f1369cd3b9b22fa /gcc/fortran/trans-intrinsic.c | |
parent | ff848f0e0fd0fe375b1afa9475d8144f38596685 (diff) | |
download | gcc-8811602900dc173f02161c177975be6cc4c60577.zip gcc-8811602900dc173f02161c177975be6cc4c60577.tar.gz gcc-8811602900dc173f02161c177975be6cc4c60577.tar.bz2 |
re PR fortran/30512 ([4.1 only] MAXVAL() incorrect for zero-size int arrays, and for -HUGE-1 maximum values.)
fortran/
2007-02-09 Tobias Burnus <burnus@net-b.de>
PR fortran/30512
* trans-intrinsic.c (gfc_conv_intrinsic_minmaxloc,
gfc_conv_intrinsic_minmaxval): Use HUGE-1 for most negative integer.
testsuite/
2007-02-09 Tobias Burnus <burnus@net-b.de>
PR fortran/30512
* gfortran.dg/maxlocval_1.f90: New test.
libgfortran/
2007-02-09 Thomas Koenig <Thomas.Koenig@online.de>
Tobias Burnus <burnus@net-b.de>
PR fortran/30512
* m4/iparm.m4: Use HUGE-1 for most negative integer.
* generated/maxloc1_8_i4.c: Regenerate.
* generated/maxloc0_8_i8.c: Regenerate.
* generated/maxloc1_16_i4.c: Regenerate.
* generated/maxloc0_16_i8.c: Regenerate.
* generated/maxval_i4.c: Regenerate.
* generated/maxloc1_4_i8.c: Regenerate.
* generated/maxloc0_16_i16.c: Regenerate.
* generated/maxloc1_4_i16.c: Regenerate.
* generated/maxloc0_8_i16.c: Regenerate.
* generated/maxloc0_4_i4.c: Regenerate.
* generated/maxloc1_8_i8.c: Regenerate.
* generated/maxloc0_8_i4.c: Regenerate.
* generated/maxloc0_16_i4.c: Regenerate.
* generated/maxloc1_16_i8.c: Regenerate.
* generated/maxloc1_4_i4.c: Regenerate.
* generated/maxval_i8.c: Regenerate.
* generated/maxloc0_4_i16.c: Regenerate.
* generated/maxloc1_8_i16.c: Regenerate.
* generated/maxloc0_4_i8.c: Regenerate.
* generated/maxloc1_16_i16.c: Regenerate.
* generated/maxval_i16.c: Regenerate.
From-SVN: r121777
Diffstat (limited to 'gcc/fortran/trans-intrinsic.c')
-rw-r--r-- | gcc/fortran/trans-intrinsic.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 5ad0f38..1bce128 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -1984,11 +1984,18 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, int op) gcc_unreachable (); } - /* Most negative(+HUGE) for maxval, most negative (-HUGE) for minval. */ + /* We start with the most negative possible value for MAXLOC, and the most + positive possible value for MINLOC. The most negative possible value is + -HUGE for BT_REAL and (-HUGE - 1) for BT_INTEGER; the most positive + possible value is HUGE in both cases. */ if (op == GT_EXPR) tmp = fold_build1 (NEGATE_EXPR, TREE_TYPE (tmp), tmp); gfc_add_modify_expr (&se->pre, limit, tmp); + if (op == GT_EXPR && expr->ts.type == BT_INTEGER) + tmp = build2 (MINUS_EXPR, TREE_TYPE (tmp), tmp, + build_int_cst (type, 1)); + /* Initialize the scalarizer. */ gfc_init_loopinfo (&loop); gfc_add_ss_to_loop (&loop, arrayss); @@ -2143,9 +2150,17 @@ gfc_conv_intrinsic_minmaxval (gfc_se * se, gfc_expr * expr, int op) gcc_unreachable (); } - /* Most negative(-HUGE) for maxval, most positive (-HUGE) for minval. */ + /* We start with the most negative possible value for MAXVAL, and the most + positive possible value for MINVAL. The most negative possible value is + -HUGE for BT_REAL and (-HUGE - 1) for BT_INTEGER; the most positive + possible value is HUGE in both cases. */ if (op == GT_EXPR) tmp = fold_build1 (NEGATE_EXPR, TREE_TYPE (tmp), tmp); + + if (op == GT_EXPR && expr->ts.type == BT_INTEGER) + tmp = build2 (MINUS_EXPR, TREE_TYPE (tmp), tmp, + build_int_cst (type, 1)); + gfc_add_modify_expr (&se->pre, limit, tmp); /* Walk the arguments. */ |