diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e501db6359b..da3698537c3 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2007-02-09 Tobias Burnus + + PR fortran/30512 + * trans-intrinsic.c (gfc_conv_intrinsic_minmaxloc, + gfc_conv_intrinsic_minmaxval): Use HUGE-1 for most negative integer. + 2007-02-09 Francois-Xavier Coudert PR fortran/30720 diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 5ad0f3826ce..1bce128d976 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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a485412836d..433172ef080 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-02-09 Tobias Burnus + + PR fortran/30512 + * gfortran.dg/maxlocval_1.f90: New test. + 2007-02-09 Roger Sayle * gcc.target/ia64/builtin_bswap-1.c: New test case. diff --git a/gcc/testsuite/gfortran.dg/maxlocval_1.f90 b/gcc/testsuite/gfortran.dg/maxlocval_1.f90 new file mode 100644 index 00000000000..11a92ca7725 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/maxlocval_1.f90 @@ -0,0 +1,44 @@ +! { dg-do run } +! Check that maxval uses for integers HUGE()-1. +! PR fortran/30512 + +program main +implicit none +integer(1) :: i1(3), a1(3:2) +integer(2) :: i2(3), a2(3:2) +integer(4) :: i4(3), a4(3:2) +integer(8) :: i8(3), a8(3:2) + +integer(kind=4), allocatable :: a(:,:) +integer(kind=8), allocatable :: b(:,:) + +logical :: msk(3) +msk = .false. + +i1 = 1 +i2 = 1 +i4 = 1 +i8 = 1 + +if(-huge(i1)-1_1 /= maxval(i1, msk)) call abort() ! { dg-warning "outside symmetric range implied by Standard Fortran" } +if(-huge(a1)-1_1 /= maxval(a1)) call abort() ! { dg-warning "outside symmetric range implied by Standard Fortran" } + +if(-huge(i2)-1_2 /= maxval(i2, msk)) call abort() ! { dg-warning "outside symmetric range implied by Standard Fortran" } +if(-huge(a2)-1_2 /= maxval(a2)) call abort() ! { dg-warning "outside symmetric range implied by Standard Fortran" } + +if(-huge(i4)-1_4 /= maxval(i4, msk)) call abort() ! { dg-warning "outside symmetric range implied by Standard Fortran" } +if(-huge(a4)-1_4 /= maxval(a4)) call abort() ! { dg-warning "outside symmetric range implied by Standard Fortran" } + +if(-huge(i8)-1_4 /= maxval(i8, msk)) call abort() ! { dg-warning "outside symmetric range implied by Standard Fortran" } +if(-huge(a8)-1_4 /= maxval(a8)) call abort() ! { dg-warning "outside symmetric range implied by Standard Fortran" } + +allocate (a(0:-1,1:1)) +allocate (b(0:-1,1:1)) + +if(any(maxval(a,dim=1) /= -huge(a)-1_4)) call abort() ! { dg-warning "outside symmetric range implied by Standard Fortran" } +if(any(minval(a,dim=1) /= huge(a) )) call abort() + +if(any(maxval(b,dim=1) /= -huge(b)-1_8)) call abort() ! { dg-warning "outside symmetric range implied by Standard Fortran" } +if(any(minval(b,dim=1) /= huge(b) )) call abort() + +end program main diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 428d49a4d37..2b5c26f2436 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,30 @@ +2007-02-09 Thomas Koenig + Tobias Burnus + + 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. + 2007-02-04 Francois-Xavier Coudert PR fortran/30611 diff --git a/libgfortran/generated/maxloc0_16_i16.c b/libgfortran/generated/maxloc0_16_i16.c index 04ebbd4fdc1..82571c435e0 100644 --- a/libgfortran/generated/maxloc0_16_i16.c +++ b/libgfortran/generated/maxloc0_16_i16.c @@ -103,7 +103,7 @@ maxloc0_16_i16 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 maxval; - maxval = -GFC_INTEGER_16_HUGE; + maxval = (-GFC_INTEGER_16_HUGE-1); while (base) { @@ -227,7 +227,7 @@ mmaxloc0_16_i16 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 maxval; - maxval = -GFC_INTEGER_16_HUGE; + maxval = (-GFC_INTEGER_16_HUGE-1); while (base) { diff --git a/libgfortran/generated/maxloc0_16_i4.c b/libgfortran/generated/maxloc0_16_i4.c index 4362fa889b5..fe46afbbb67 100644 --- a/libgfortran/generated/maxloc0_16_i4.c +++ b/libgfortran/generated/maxloc0_16_i4.c @@ -103,7 +103,7 @@ maxloc0_16_i4 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_4 maxval; - maxval = -GFC_INTEGER_4_HUGE; + maxval = (-GFC_INTEGER_4_HUGE-1); while (base) { @@ -227,7 +227,7 @@ mmaxloc0_16_i4 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_4 maxval; - maxval = -GFC_INTEGER_4_HUGE; + maxval = (-GFC_INTEGER_4_HUGE-1); while (base) { diff --git a/libgfortran/generated/maxloc0_16_i8.c b/libgfortran/generated/maxloc0_16_i8.c index aeb0aedcb29..82ff74fa71e 100644 --- a/libgfortran/generated/maxloc0_16_i8.c +++ b/libgfortran/generated/maxloc0_16_i8.c @@ -103,7 +103,7 @@ maxloc0_16_i8 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_8 maxval; - maxval = -GFC_INTEGER_8_HUGE; + maxval = (-GFC_INTEGER_8_HUGE-1); while (base) { @@ -227,7 +227,7 @@ mmaxloc0_16_i8 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_8 maxval; - maxval = -GFC_INTEGER_8_HUGE; + maxval = (-GFC_INTEGER_8_HUGE-1); while (base) { diff --git a/libgfortran/generated/maxloc0_4_i16.c b/libgfortran/generated/maxloc0_4_i16.c index 6d052911f44..1cbab8caf32 100644 --- a/libgfortran/generated/maxloc0_4_i16.c +++ b/libgfortran/generated/maxloc0_4_i16.c @@ -103,7 +103,7 @@ maxloc0_4_i16 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_16 maxval; - maxval = -GFC_INTEGER_16_HUGE; + maxval = (-GFC_INTEGER_16_HUGE-1); while (base) { @@ -227,7 +227,7 @@ mmaxloc0_4_i16 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_16 maxval; - maxval = -GFC_INTEGER_16_HUGE; + maxval = (-GFC_INTEGER_16_HUGE-1); while (base) { diff --git a/libgfortran/generated/maxloc0_4_i4.c b/libgfortran/generated/maxloc0_4_i4.c index 16ee31ede31..a1ba2ae29ca 100644 --- a/libgfortran/generated/maxloc0_4_i4.c +++ b/libgfortran/generated/maxloc0_4_i4.c @@ -103,7 +103,7 @@ maxloc0_4_i4 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 maxval; - maxval = -GFC_INTEGER_4_HUGE; + maxval = (-GFC_INTEGER_4_HUGE-1); while (base) { @@ -227,7 +227,7 @@ mmaxloc0_4_i4 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 maxval; - maxval = -GFC_INTEGER_4_HUGE; + maxval = (-GFC_INTEGER_4_HUGE-1); while (base) { diff --git a/libgfortran/generated/maxloc0_4_i8.c b/libgfortran/generated/maxloc0_4_i8.c index 58c6509d23d..82011f90e0f 100644 --- a/libgfortran/generated/maxloc0_4_i8.c +++ b/libgfortran/generated/maxloc0_4_i8.c @@ -103,7 +103,7 @@ maxloc0_4_i8 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_8 maxval; - maxval = -GFC_INTEGER_8_HUGE; + maxval = (-GFC_INTEGER_8_HUGE-1); while (base) { @@ -227,7 +227,7 @@ mmaxloc0_4_i8 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_8 maxval; - maxval = -GFC_INTEGER_8_HUGE; + maxval = (-GFC_INTEGER_8_HUGE-1); while (base) { diff --git a/libgfortran/generated/maxloc0_8_i16.c b/libgfortran/generated/maxloc0_8_i16.c index 4400a5b52f4..69b4015d136 100644 --- a/libgfortran/generated/maxloc0_8_i16.c +++ b/libgfortran/generated/maxloc0_8_i16.c @@ -103,7 +103,7 @@ maxloc0_8_i16 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_16 maxval; - maxval = -GFC_INTEGER_16_HUGE; + maxval = (-GFC_INTEGER_16_HUGE-1); while (base) { @@ -227,7 +227,7 @@ mmaxloc0_8_i16 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_16 maxval; - maxval = -GFC_INTEGER_16_HUGE; + maxval = (-GFC_INTEGER_16_HUGE-1); while (base) { diff --git a/libgfortran/generated/maxloc0_8_i4.c b/libgfortran/generated/maxloc0_8_i4.c index 0d96ff3636d..b6ccff6a096 100644 --- a/libgfortran/generated/maxloc0_8_i4.c +++ b/libgfortran/generated/maxloc0_8_i4.c @@ -103,7 +103,7 @@ maxloc0_8_i4 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_4 maxval; - maxval = -GFC_INTEGER_4_HUGE; + maxval = (-GFC_INTEGER_4_HUGE-1); while (base) { @@ -227,7 +227,7 @@ mmaxloc0_8_i4 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_4 maxval; - maxval = -GFC_INTEGER_4_HUGE; + maxval = (-GFC_INTEGER_4_HUGE-1); while (base) { diff --git a/libgfortran/generated/maxloc0_8_i8.c b/libgfortran/generated/maxloc0_8_i8.c index e7499568d4b..5ab944c25e9 100644 --- a/libgfortran/generated/maxloc0_8_i8.c +++ b/libgfortran/generated/maxloc0_8_i8.c @@ -103,7 +103,7 @@ maxloc0_8_i8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 maxval; - maxval = -GFC_INTEGER_8_HUGE; + maxval = (-GFC_INTEGER_8_HUGE-1); while (base) { @@ -227,7 +227,7 @@ mmaxloc0_8_i8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 maxval; - maxval = -GFC_INTEGER_8_HUGE; + maxval = (-GFC_INTEGER_8_HUGE-1); while (base) { diff --git a/libgfortran/generated/maxloc1_16_i16.c b/libgfortran/generated/maxloc1_16_i16.c index c01a006f8ea..14db8ddd859 100644 --- a/libgfortran/generated/maxloc1_16_i16.c +++ b/libgfortran/generated/maxloc1_16_i16.c @@ -140,7 +140,7 @@ maxloc1_16_i16 (gfc_array_i16 * const restrict retarray, { GFC_INTEGER_16 maxval; - maxval = -GFC_INTEGER_16_HUGE; + maxval = (-GFC_INTEGER_16_HUGE-1); result = 0; if (len <= 0) *dest = 0; @@ -315,7 +315,7 @@ mmaxloc1_16_i16 (gfc_array_i16 * const restrict retarray, { GFC_INTEGER_16 maxval; - maxval = -GFC_INTEGER_16_HUGE; + maxval = (-GFC_INTEGER_16_HUGE-1); result = 0; if (len <= 0) *dest = 0; diff --git a/libgfortran/generated/maxloc1_16_i4.c b/libgfortran/generated/maxloc1_16_i4.c index dd0739c5915..63b6f463f2f 100644 --- a/libgfortran/generated/maxloc1_16_i4.c +++ b/libgfortran/generated/maxloc1_16_i4.c @@ -140,7 +140,7 @@ maxloc1_16_i4 (gfc_array_i16 * const restrict retarray, { GFC_INTEGER_4 maxval; - maxval = -GFC_INTEGER_4_HUGE; + maxval = (-GFC_INTEGER_4_HUGE-1); result = 0; if (len <= 0) *dest = 0; @@ -315,7 +315,7 @@ mmaxloc1_16_i4 (gfc_array_i16 * const restrict retarray, { GFC_INTEGER_4 maxval; - maxval = -GFC_INTEGER_4_HUGE; + maxval = (-GFC_INTEGER_4_HUGE-1); result = 0; if (len <= 0) *dest = 0; diff --git a/libgfortran/generated/maxloc1_16_i8.c b/libgfortran/generated/maxloc1_16_i8.c index c18a8e5a791..3b6a6ef1492 100644 --- a/libgfortran/generated/maxloc1_16_i8.c +++ b/libgfortran/generated/maxloc1_16_i8.c @@ -140,7 +140,7 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray, { GFC_INTEGER_8 maxval; - maxval = -GFC_INTEGER_8_HUGE; + maxval = (-GFC_INTEGER_8_HUGE-1); result = 0; if (len <= 0) *dest = 0; @@ -315,7 +315,7 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, { GFC_INTEGER_8 maxval; - maxval = -GFC_INTEGER_8_HUGE; + maxval = (-GFC_INTEGER_8_HUGE-1); result = 0; if (len <= 0) *dest = 0; diff --git a/libgfortran/generated/maxloc1_4_i16.c b/libgfortran/generated/maxloc1_4_i16.c index 0c8a0cc33c6..0848c44fdca 100644 --- a/libgfortran/generated/maxloc1_4_i16.c +++ b/libgfortran/generated/maxloc1_4_i16.c @@ -140,7 +140,7 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray, { GFC_INTEGER_16 maxval; - maxval = -GFC_INTEGER_16_HUGE; + maxval = (-GFC_INTEGER_16_HUGE-1); result = 0; if (len <= 0) *dest = 0; @@ -315,7 +315,7 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, { GFC_INTEGER_16 maxval; - maxval = -GFC_INTEGER_16_HUGE; + maxval = (-GFC_INTEGER_16_HUGE-1); result = 0; if (len <= 0) *dest = 0; diff --git a/libgfortran/generated/maxloc1_4_i4.c b/libgfortran/generated/maxloc1_4_i4.c index 83131ffd33b..15f1243babf 100644 --- a/libgfortran/generated/maxloc1_4_i4.c +++ b/libgfortran/generated/maxloc1_4_i4.c @@ -140,7 +140,7 @@ maxloc1_4_i4 (gfc_array_i4 * const restrict retarray, { GFC_INTEGER_4 maxval; - maxval = -GFC_INTEGER_4_HUGE; + maxval = (-GFC_INTEGER_4_HUGE-1); result = 0; if (len <= 0) *dest = 0; @@ -315,7 +315,7 @@ mmaxloc1_4_i4 (gfc_array_i4 * const restrict retarray, { GFC_INTEGER_4 maxval; - maxval = -GFC_INTEGER_4_HUGE; + maxval = (-GFC_INTEGER_4_HUGE-1); result = 0; if (len <= 0) *dest = 0; diff --git a/libgfortran/generated/maxloc1_4_i8.c b/libgfortran/generated/maxloc1_4_i8.c index bb553eb884e..2a2f37ca4d0 100644 --- a/libgfortran/generated/maxloc1_4_i8.c +++ b/libgfortran/generated/maxloc1_4_i8.c @@ -140,7 +140,7 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray, { GFC_INTEGER_8 maxval; - maxval = -GFC_INTEGER_8_HUGE; + maxval = (-GFC_INTEGER_8_HUGE-1); result = 0; if (len <= 0) *dest = 0; @@ -315,7 +315,7 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, { GFC_INTEGER_8 maxval; - maxval = -GFC_INTEGER_8_HUGE; + maxval = (-GFC_INTEGER_8_HUGE-1); result = 0; if (len <= 0) *dest = 0; diff --git a/libgfortran/generated/maxloc1_8_i16.c b/libgfortran/generated/maxloc1_8_i16.c index d4bff32de4e..17c73ce2955 100644 --- a/libgfortran/generated/maxloc1_8_i16.c +++ b/libgfortran/generated/maxloc1_8_i16.c @@ -140,7 +140,7 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray, { GFC_INTEGER_16 maxval; - maxval = -GFC_INTEGER_16_HUGE; + maxval = (-GFC_INTEGER_16_HUGE-1); result = 0; if (len <= 0) *dest = 0; @@ -315,7 +315,7 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, { GFC_INTEGER_16 maxval; - maxval = -GFC_INTEGER_16_HUGE; + maxval = (-GFC_INTEGER_16_HUGE-1); result = 0; if (len <= 0) *dest = 0; diff --git a/libgfortran/generated/maxloc1_8_i4.c b/libgfortran/generated/maxloc1_8_i4.c index 9225f13c791..a4f36452b63 100644 --- a/libgfortran/generated/maxloc1_8_i4.c +++ b/libgfortran/generated/maxloc1_8_i4.c @@ -140,7 +140,7 @@ maxloc1_8_i4 (gfc_array_i8 * const restrict retarray, { GFC_INTEGER_4 maxval; - maxval = -GFC_INTEGER_4_HUGE; + maxval = (-GFC_INTEGER_4_HUGE-1); result = 0; if (len <= 0) *dest = 0; @@ -315,7 +315,7 @@ mmaxloc1_8_i4 (gfc_array_i8 * const restrict retarray, { GFC_INTEGER_4 maxval; - maxval = -GFC_INTEGER_4_HUGE; + maxval = (-GFC_INTEGER_4_HUGE-1); result = 0; if (len <= 0) *dest = 0; diff --git a/libgfortran/generated/maxloc1_8_i8.c b/libgfortran/generated/maxloc1_8_i8.c index c0179cd8b7a..587ddc657f9 100644 --- a/libgfortran/generated/maxloc1_8_i8.c +++ b/libgfortran/generated/maxloc1_8_i8.c @@ -140,7 +140,7 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray, { GFC_INTEGER_8 maxval; - maxval = -GFC_INTEGER_8_HUGE; + maxval = (-GFC_INTEGER_8_HUGE-1); result = 0; if (len <= 0) *dest = 0; @@ -315,7 +315,7 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, { GFC_INTEGER_8 maxval; - maxval = -GFC_INTEGER_8_HUGE; + maxval = (-GFC_INTEGER_8_HUGE-1); result = 0; if (len <= 0) *dest = 0; diff --git a/libgfortran/generated/maxval_i16.c b/libgfortran/generated/maxval_i16.c index 8bdab56d54d..f5df1e1b394 100644 --- a/libgfortran/generated/maxval_i16.c +++ b/libgfortran/generated/maxval_i16.c @@ -138,9 +138,9 @@ maxval_i16 (gfc_array_i16 * const restrict retarray, src = base; { - result = -GFC_INTEGER_16_HUGE; + result = (-GFC_INTEGER_16_HUGE-1); if (len <= 0) - *dest = -GFC_INTEGER_16_HUGE; + *dest = (-GFC_INTEGER_16_HUGE-1); else { for (n = 0; n < len; n++, src += delta) @@ -308,9 +308,9 @@ mmaxval_i16 (gfc_array_i16 * const restrict retarray, msrc = mbase; { - result = -GFC_INTEGER_16_HUGE; + result = (-GFC_INTEGER_16_HUGE-1); if (len <= 0) - *dest = -GFC_INTEGER_16_HUGE; + *dest = (-GFC_INTEGER_16_HUGE-1); else { for (n = 0; n < len; n++, src += delta, msrc += mdelta) @@ -404,7 +404,7 @@ smaxval_i16 (gfc_array_i16 * const restrict retarray, dest = retarray->data; for (n = 0; n < rank; n++) - dest[n * dstride] = -GFC_INTEGER_16_HUGE ; + dest[n * dstride] = (-GFC_INTEGER_16_HUGE-1) ; } #endif diff --git a/libgfortran/generated/maxval_i4.c b/libgfortran/generated/maxval_i4.c index ba5b3106841..7b01617edd1 100644 --- a/libgfortran/generated/maxval_i4.c +++ b/libgfortran/generated/maxval_i4.c @@ -138,9 +138,9 @@ maxval_i4 (gfc_array_i4 * const restrict retarray, src = base; { - result = -GFC_INTEGER_4_HUGE; + result = (-GFC_INTEGER_4_HUGE-1); if (len <= 0) - *dest = -GFC_INTEGER_4_HUGE; + *dest = (-GFC_INTEGER_4_HUGE-1); else { for (n = 0; n < len; n++, src += delta) @@ -308,9 +308,9 @@ mmaxval_i4 (gfc_array_i4 * const restrict retarray, msrc = mbase; { - result = -GFC_INTEGER_4_HUGE; + result = (-GFC_INTEGER_4_HUGE-1); if (len <= 0) - *dest = -GFC_INTEGER_4_HUGE; + *dest = (-GFC_INTEGER_4_HUGE-1); else { for (n = 0; n < len; n++, src += delta, msrc += mdelta) @@ -404,7 +404,7 @@ smaxval_i4 (gfc_array_i4 * const restrict retarray, dest = retarray->data; for (n = 0; n < rank; n++) - dest[n * dstride] = -GFC_INTEGER_4_HUGE ; + dest[n * dstride] = (-GFC_INTEGER_4_HUGE-1) ; } #endif diff --git a/libgfortran/generated/maxval_i8.c b/libgfortran/generated/maxval_i8.c index ee6a5d2d87c..cb83c5a1e6a 100644 --- a/libgfortran/generated/maxval_i8.c +++ b/libgfortran/generated/maxval_i8.c @@ -138,9 +138,9 @@ maxval_i8 (gfc_array_i8 * const restrict retarray, src = base; { - result = -GFC_INTEGER_8_HUGE; + result = (-GFC_INTEGER_8_HUGE-1); if (len <= 0) - *dest = -GFC_INTEGER_8_HUGE; + *dest = (-GFC_INTEGER_8_HUGE-1); else { for (n = 0; n < len; n++, src += delta) @@ -308,9 +308,9 @@ mmaxval_i8 (gfc_array_i8 * const restrict retarray, msrc = mbase; { - result = -GFC_INTEGER_8_HUGE; + result = (-GFC_INTEGER_8_HUGE-1); if (len <= 0) - *dest = -GFC_INTEGER_8_HUGE; + *dest = (-GFC_INTEGER_8_HUGE-1); else { for (n = 0; n < len; n++, src += delta, msrc += mdelta) @@ -404,7 +404,7 @@ smaxval_i8 (gfc_array_i8 * const restrict retarray, dest = retarray->data; for (n = 0; n < rank; n++) - dest[n * dstride] = -GFC_INTEGER_8_HUGE ; + dest[n * dstride] = (-GFC_INTEGER_8_HUGE-1) ; } #endif diff --git a/libgfortran/m4/iparm.m4 b/libgfortran/m4/iparm.m4 index 950962113b0..acd3d2ce604 100644 --- a/libgfortran/m4/iparm.m4 +++ b/libgfortran/m4/iparm.m4 @@ -28,6 +28,6 @@ define_type(rtype, rtype_tmp)dnl define(rtype_qual,`_'rtype_kind)dnl ')dnl define(atype_max, atype_name`_HUGE')dnl -define(atype_min, `-'atype_max)dnl +define(atype_min,ifelse(regexp(file, `_\(.\)[0-9]*\.c$', `\1'),`i',`(-'atype_max`-1)',`-'atype_max))dnl define(name, regexp(regexp(file, `[^/]*$', `\&'), `^\([^_]*\)_', `\1'))dnl define(rtype_ccode,ifelse(rtype_letter,`i',rtype_kind,rtype_code))dnl