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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121777
138bc75d-0d04-0410-961f-
82ee72b054a4
+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.
+
2007-02-09 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR fortran/30720
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);
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. */
+2007-02-09 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/30512
+ * gfortran.dg/maxlocval_1.f90: New test.
+
2007-02-09 Roger Sayle <roger@eyesopen.com>
* gcc.target/ia64/builtin_bswap-1.c: New test case.
--- /dev/null
+! { 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
+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.
+
2007-02-04 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR fortran/30611
GFC_INTEGER_16 maxval;
- maxval = -GFC_INTEGER_16_HUGE;
+ maxval = (-GFC_INTEGER_16_HUGE-1);
while (base)
{
GFC_INTEGER_16 maxval;
- maxval = -GFC_INTEGER_16_HUGE;
+ maxval = (-GFC_INTEGER_16_HUGE-1);
while (base)
{
GFC_INTEGER_4 maxval;
- maxval = -GFC_INTEGER_4_HUGE;
+ maxval = (-GFC_INTEGER_4_HUGE-1);
while (base)
{
GFC_INTEGER_4 maxval;
- maxval = -GFC_INTEGER_4_HUGE;
+ maxval = (-GFC_INTEGER_4_HUGE-1);
while (base)
{
GFC_INTEGER_8 maxval;
- maxval = -GFC_INTEGER_8_HUGE;
+ maxval = (-GFC_INTEGER_8_HUGE-1);
while (base)
{
GFC_INTEGER_8 maxval;
- maxval = -GFC_INTEGER_8_HUGE;
+ maxval = (-GFC_INTEGER_8_HUGE-1);
while (base)
{
GFC_INTEGER_16 maxval;
- maxval = -GFC_INTEGER_16_HUGE;
+ maxval = (-GFC_INTEGER_16_HUGE-1);
while (base)
{
GFC_INTEGER_16 maxval;
- maxval = -GFC_INTEGER_16_HUGE;
+ maxval = (-GFC_INTEGER_16_HUGE-1);
while (base)
{
GFC_INTEGER_4 maxval;
- maxval = -GFC_INTEGER_4_HUGE;
+ maxval = (-GFC_INTEGER_4_HUGE-1);
while (base)
{
GFC_INTEGER_4 maxval;
- maxval = -GFC_INTEGER_4_HUGE;
+ maxval = (-GFC_INTEGER_4_HUGE-1);
while (base)
{
GFC_INTEGER_8 maxval;
- maxval = -GFC_INTEGER_8_HUGE;
+ maxval = (-GFC_INTEGER_8_HUGE-1);
while (base)
{
GFC_INTEGER_8 maxval;
- maxval = -GFC_INTEGER_8_HUGE;
+ maxval = (-GFC_INTEGER_8_HUGE-1);
while (base)
{
GFC_INTEGER_16 maxval;
- maxval = -GFC_INTEGER_16_HUGE;
+ maxval = (-GFC_INTEGER_16_HUGE-1);
while (base)
{
GFC_INTEGER_16 maxval;
- maxval = -GFC_INTEGER_16_HUGE;
+ maxval = (-GFC_INTEGER_16_HUGE-1);
while (base)
{
GFC_INTEGER_4 maxval;
- maxval = -GFC_INTEGER_4_HUGE;
+ maxval = (-GFC_INTEGER_4_HUGE-1);
while (base)
{
GFC_INTEGER_4 maxval;
- maxval = -GFC_INTEGER_4_HUGE;
+ maxval = (-GFC_INTEGER_4_HUGE-1);
while (base)
{
GFC_INTEGER_8 maxval;
- maxval = -GFC_INTEGER_8_HUGE;
+ maxval = (-GFC_INTEGER_8_HUGE-1);
while (base)
{
GFC_INTEGER_8 maxval;
- maxval = -GFC_INTEGER_8_HUGE;
+ maxval = (-GFC_INTEGER_8_HUGE-1);
while (base)
{
{
GFC_INTEGER_16 maxval;
- maxval = -GFC_INTEGER_16_HUGE;
+ maxval = (-GFC_INTEGER_16_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_16 maxval;
- maxval = -GFC_INTEGER_16_HUGE;
+ maxval = (-GFC_INTEGER_16_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_4 maxval;
- maxval = -GFC_INTEGER_4_HUGE;
+ maxval = (-GFC_INTEGER_4_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_4 maxval;
- maxval = -GFC_INTEGER_4_HUGE;
+ maxval = (-GFC_INTEGER_4_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_8 maxval;
- maxval = -GFC_INTEGER_8_HUGE;
+ maxval = (-GFC_INTEGER_8_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_8 maxval;
- maxval = -GFC_INTEGER_8_HUGE;
+ maxval = (-GFC_INTEGER_8_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_16 maxval;
- maxval = -GFC_INTEGER_16_HUGE;
+ maxval = (-GFC_INTEGER_16_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_16 maxval;
- maxval = -GFC_INTEGER_16_HUGE;
+ maxval = (-GFC_INTEGER_16_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_4 maxval;
- maxval = -GFC_INTEGER_4_HUGE;
+ maxval = (-GFC_INTEGER_4_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_4 maxval;
- maxval = -GFC_INTEGER_4_HUGE;
+ maxval = (-GFC_INTEGER_4_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_8 maxval;
- maxval = -GFC_INTEGER_8_HUGE;
+ maxval = (-GFC_INTEGER_8_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_8 maxval;
- maxval = -GFC_INTEGER_8_HUGE;
+ maxval = (-GFC_INTEGER_8_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_16 maxval;
- maxval = -GFC_INTEGER_16_HUGE;
+ maxval = (-GFC_INTEGER_16_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_16 maxval;
- maxval = -GFC_INTEGER_16_HUGE;
+ maxval = (-GFC_INTEGER_16_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_4 maxval;
- maxval = -GFC_INTEGER_4_HUGE;
+ maxval = (-GFC_INTEGER_4_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_4 maxval;
- maxval = -GFC_INTEGER_4_HUGE;
+ maxval = (-GFC_INTEGER_4_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_8 maxval;
- maxval = -GFC_INTEGER_8_HUGE;
+ maxval = (-GFC_INTEGER_8_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
{
GFC_INTEGER_8 maxval;
- maxval = -GFC_INTEGER_8_HUGE;
+ maxval = (-GFC_INTEGER_8_HUGE-1);
result = 0;
if (len <= 0)
*dest = 0;
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)
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)
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
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)
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)
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
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)
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)
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
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