fortran/
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Feb 2007 21:56:06 +0000 (21:56 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Feb 2007 21:56:06 +0000 (21:56 +0000)
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

27 files changed:
gcc/fortran/ChangeLog
gcc/fortran/trans-intrinsic.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/maxlocval_1.f90 [new file with mode: 0644]
libgfortran/ChangeLog
libgfortran/generated/maxloc0_16_i16.c
libgfortran/generated/maxloc0_16_i4.c
libgfortran/generated/maxloc0_16_i8.c
libgfortran/generated/maxloc0_4_i16.c
libgfortran/generated/maxloc0_4_i4.c
libgfortran/generated/maxloc0_4_i8.c
libgfortran/generated/maxloc0_8_i16.c
libgfortran/generated/maxloc0_8_i4.c
libgfortran/generated/maxloc0_8_i8.c
libgfortran/generated/maxloc1_16_i16.c
libgfortran/generated/maxloc1_16_i4.c
libgfortran/generated/maxloc1_16_i8.c
libgfortran/generated/maxloc1_4_i16.c
libgfortran/generated/maxloc1_4_i4.c
libgfortran/generated/maxloc1_4_i8.c
libgfortran/generated/maxloc1_8_i16.c
libgfortran/generated/maxloc1_8_i4.c
libgfortran/generated/maxloc1_8_i8.c
libgfortran/generated/maxval_i16.c
libgfortran/generated/maxval_i4.c
libgfortran/generated/maxval_i8.c
libgfortran/m4/iparm.m4

index e501db6..da36985 100644 (file)
@@ -1,3 +1,9 @@
+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
index 5ad0f38..1bce128 100644 (file)
@@ -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.  */
index a485412..433172e 100644 (file)
@@ -1,3 +1,8 @@
+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.
diff --git a/gcc/testsuite/gfortran.dg/maxlocval_1.f90 b/gcc/testsuite/gfortran.dg/maxlocval_1.f90
new file mode 100644 (file)
index 0000000..11a92ca
--- /dev/null
@@ -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
index 428d49a..2b5c26f 100644 (file)
@@ -1,3 +1,30 @@
+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
index 04ebbd4..82571c4 100644 (file)
@@ -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)
     {
index 4362fa8..fe46afb 100644 (file)
@@ -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)
     {
index aeb0aed..82ff74f 100644 (file)
@@ -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)
     {
index 6d05291..1cbab8c 100644 (file)
@@ -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)
     {
index 16ee31e..a1ba2ae 100644 (file)
@@ -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)
     {
index 58c6509..82011f9 100644 (file)
@@ -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)
     {
index 4400a5b..69b4015 100644 (file)
@@ -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)
     {
index 0d96ff3..b6ccff6 100644 (file)
@@ -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)
     {
index e749956..5ab944c 100644 (file)
@@ -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)
     {
index c01a006..14db8dd 100644 (file)
@@ -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;
index dd0739c..63b6f46 100644 (file)
@@ -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;
index c18a8e5..3b6a6ef 100644 (file)
@@ -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;
index 0c8a0cc..0848c44 100644 (file)
@@ -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;
index 83131ff..15f1243 100644 (file)
@@ -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;
index bb553eb..2a2f37c 100644 (file)
@@ -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;
index d4bff32..17c73ce 100644 (file)
@@ -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;
index 9225f13..a4f3645 100644 (file)
@@ -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;
index c0179cd..587ddc6 100644 (file)
@@ -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;
index 8bdab56..f5df1e1 100644 (file)
@@ -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
index ba5b310..7b01617 100644 (file)
@@ -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
index ee6a5d2..cb83c5a 100644 (file)
@@ -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
index 9509621..acd3d2c 100644 (file)
@@ -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