re PR c/34252 (DEC32_MIN_EXP, DEC32_MAX_EXP don't match TR 24732)
authorJanis Johnson <janis187@us.ibm.com>
Tue, 6 Jan 2009 19:02:41 +0000 (19:02 +0000)
committerJanis Johnson <janis@gcc.gnu.org>
Tue, 6 Jan 2009 19:02:41 +0000 (19:02 +0000)
gcc/
PR c/34252
* ginclude/float.h: Rename DECnn_DEN to DECnn_SUBNORMAL_MIN.
* real.c (decimal_single_format): Correct values of emin and emax.
(decimal_double_format): Ditto.
(decimal_quad_format): Ditto.
* c-cppbuiltin.c (builtin_define_decimal_float_constants): Adjust
computation of DECnn_MIN and DECnn_MAX for corrected values of
emin and emax.  Define __DECnn_SUBNORMAL_MIN__ instead of
__DECnn_MIN__, and adjust its computation for the corrected value
of emin.

gcc/testsuite/
PR c/34252
* gcc.dg/dfp/decfloat-constants.c: Check for DECnn_SUBNORMAL_MIN
instead of DECnn_DEN.  Support -DDBG to list lines that fail.

From-SVN: r143128

gcc/ChangeLog
gcc/c-cppbuiltin.c
gcc/ginclude/float.h
gcc/real.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/dfp/decfloat-constants.c

index 2690bd193aaf108e2601bf5026367689d594b479..80fd4d09a9112032106bf2d4747a88ef0cfd366c 100644 (file)
@@ -1,3 +1,16 @@
+2009-01-06  Janis Johnson  <janis187@us.ibm.com>
+
+       PR c/34252
+       * ginclude/float.h: Rename DECnn_DEN to DECnn_SUBNORMAL_MIN.
+       * real.c (decimal_single_format): Correct values of emin and emax.
+       (decimal_double_format): Ditto.
+       (decimal_quad_format): Ditto.
+       * c-cppbuiltin.c (builtin_define_decimal_float_constants): Adjust
+       computation of DECnn_MIN and DECnn_MAX for corrected values of
+       emin and emax.  Define __DECnn_SUBNORMAL_MIN__ instead of
+       __DECnn_MIN__, and adjust its computation for the corrected value
+       of emin.
+
 2009-01-06  Jan Hubicka  <jh@suse.cz>
 
        PR target/38744
index f1a454fed9a59658194d2f854bcc279148c0b279..58b1796e797e7e0e71c0e650d927f2e35b438dc2 100644 (file)
@@ -1,5 +1,5 @@
 /* Define builtin-in macros for the C family front ends.
-   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -279,7 +279,7 @@ builtin_define_decimal_float_constants (const char *name_prefix,
 
   /* Compute the minimum representable value.  */
   sprintf (name, "__%s_MIN__", name_prefix);
-  sprintf (buf, "1E%d%s", fmt->emin, suffix);
+  sprintf (buf, "1E%d%s", fmt->emin - 1, suffix);
   builtin_define_with_value (name, buf, 0); 
 
   /* Compute the maximum representable value.  */
@@ -292,8 +292,9 @@ builtin_define_decimal_float_constants (const char *name_prefix,
        *p++ = '.';
     }
   *p = 0;
-  /* fmt->p plus 1, to account for the decimal point.  */
-  sprintf (&buf[fmt->p + 1], "E%d%s", fmt->emax, suffix); 
+  /* fmt->p plus 1, to account for the decimal point and fmt->emax
+     minus 1 because the digits are nines, not 1.0.  */
+  sprintf (&buf[fmt->p + 1], "E%d%s", fmt->emax - 1, suffix); 
   builtin_define_with_value (name, buf, 0);
 
   /* Compute epsilon (the difference between 1 and least value greater
@@ -302,8 +303,8 @@ builtin_define_decimal_float_constants (const char *name_prefix,
   sprintf (buf, "1E-%d%s", fmt->p - 1, suffix);
   builtin_define_with_value (name, buf, 0);
 
-  /* Minimum denormalized positive decimal value.  */
-  sprintf (name, "__%s_DEN__", name_prefix);
+  /* Minimum subnormal positive decimal value.  */
+  sprintf (name, "__%s_SUBNORMAL_MIN__", name_prefix);
   p = buf;
   for (digits = fmt->p; digits > 1; digits--)
     {
@@ -312,7 +313,7 @@ builtin_define_decimal_float_constants (const char *name_prefix,
        *p++ = '.';
     }
   *p = 0;
-  sprintf (&buf[fmt->p], "1E%d%s", fmt->emin, suffix); 
+  sprintf (&buf[fmt->p], "1E%d%s", fmt->emin - 1, suffix); 
   builtin_define_with_value (name, buf, 0);
 }
 
index 5d9f918e8388e27dcf2ecf7c143e1c37cd1653ec..e6b1bfbb184406b7f986298fe368191713c2aa60 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2007, 2009 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -214,13 +214,13 @@ Boston, MA 02110-1301, USA.  */
 #define DEC64_MIN      __DEC64_MIN__
 #define DEC128_MIN     __DEC128_MIN__
 
-/* Minimum denormalized positive floating-point number. */
-#undef DEC32_DEN
-#undef DEC64_DEN
-#undef DEC128_DEN
-#define DEC32_DEN       __DEC32_DEN__
-#define DEC64_DEN       __DEC64_DEN__
-#define DEC128_DEN      __DEC128_DEN__
+/* Minimum subnormal positive floating-point number. */
+#undef DEC32_SUBNORMAL_MIN
+#undef DEC64_SUBNORMAL_MIN
+#undef DEC128_SUBNORMAL_MIN
+#define DEC32_SUBNORMAL_MIN       __DEC32_SUBNORMAL_MIN__
+#define DEC64_SUBNORMAL_MIN       __DEC64_SUBNORMAL_MIN__
+#define DEC128_SUBNORMAL_MIN      __DEC128_SUBNORMAL_MIN__
 
 /* The floating-point expression evaluation method.
          -1  indeterminate
index c5a16a867e1c4a8f0b12d269dc82b05d3f6a9e77..d26b0cbd0c9e379574db015b365b03b7e7f865bb 100644 (file)
@@ -1,6 +1,6 @@
 /* real.c - software floating point emulation.
-   Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2002, 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002,
+   2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Stephen L. Moshier (moshier@world.std.com).
    Re-written by Richard Henderson <rth@redhat.com>
 
@@ -4447,8 +4447,8 @@ const struct real_format decimal_single_format =
     10, 
     7,
     7,
-    -95,
-    96,
+    -94,
+    97,
     31,
     31,
     false,
@@ -4469,8 +4469,8 @@ const struct real_format decimal_double_format =
     10,
     16,
     16,
-    -383,
-    384,
+    -382,
+    385,
     63,
     63,
     false,
@@ -4491,8 +4491,8 @@ const struct real_format decimal_quad_format =
     10,
     34,
     34,
-    -6143,
-    6144,
+    -6142,
+    6145,
     127,
     127,
     false,
index c1ec07e9345ccfa055eb6de301f2e7459d5848fb..07c2de13e5a687b39582744cf0c1dc8f406f6634 100644 (file)
@@ -1,3 +1,9 @@
+2009-01-06  Janis Johnson  <janis187@us.ibm.com>
+
+       PR c/34252
+       * gcc.dg/dfp/decfloat-constants.c: Check for DECnn_SUBNORMAL_MIN
+       instead of DECnn_DEN.  Support -DDBG to list lines that fail.
+
 2009-01-06  Dominique Dhumieres  <dominiq@lps.ens.fr>
 
        * gfortran.dg/implicit_12.f90: Add space around dg directive.
index 87c9849ac9b882998a8187ade4c8fd9abc8e6289..ec9d3816706b9a53a43ebcfa5f4900e8aaabf8be 100644 (file)
 #include <float.h>
 
 extern void abort (void);
+static int failcnt;
+
+/* Support compiling the test to report individual failures; default is
+   to abort as soon as a check fails.  */
+#ifdef DBG
+#include <stdio.h>
+#define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
+#else
+#define FAILURE abort ();
+#endif
 
 int main ()
 {
-  if (DEC32_MANT_DIG != 7) abort();
-  if (DEC64_MANT_DIG != 16) abort();
-  if (DEC128_MANT_DIG != 34) abort();
+  if (DEC32_MANT_DIG != 7) FAILURE
+  if (DEC64_MANT_DIG != 16) FAILURE
+  if (DEC128_MANT_DIG != 34) FAILURE
 
-  if (DEC32_MIN_EXP != -95) abort();
-  if (DEC64_MIN_EXP != -383) abort();
-  if (DEC128_MIN_EXP != -6143) abort();
+  if (DEC32_MIN_EXP != -94) FAILURE
+  if (DEC64_MIN_EXP != -382) FAILURE
+  if (DEC128_MIN_EXP != -6142) FAILURE
 
-  if (DEC32_MAX_EXP != 96) abort();
-  if (DEC64_MAX_EXP != 384) abort();
-  if (DEC128_MAX_EXP != 6144) abort();
+  if (DEC32_MAX_EXP != 97) FAILURE
+  if (DEC64_MAX_EXP != 385) FAILURE
+  if (DEC128_MAX_EXP != 6145) FAILURE
 
-  if (DEC32_MAX != 9.999999E96DF) abort();
-  if (DEC64_MAX != 9.999999999999999E384DD) abort();
-  if (DEC128_MAX != 9.999999999999999999999999999999999E6144DL) abort();
+  if (DEC32_MAX != 9.999999E96DF) FAILURE
+  if (DEC64_MAX != 9.999999999999999E384DD) FAILURE
+  if (DEC128_MAX != 9.999999999999999999999999999999999E6144DL) FAILURE
 
-  if (DEC32_EPSILON != 1E-6DF) abort();
-  if (DEC64_EPSILON != 1E-15DD) abort();
-  if (DEC128_EPSILON != 1E-33DL) abort();
+  if (DEC32_EPSILON != 1E-6DF) FAILURE
+  if (DEC64_EPSILON != 1E-15DD) FAILURE
+  if (DEC128_EPSILON != 1E-33DL) FAILURE
   
-  if (DEC32_MIN != 1E-95DF) abort();
-  if (DEC64_MIN != 1E-383DD) abort();
-  if (DEC128_MIN != 1E-6143DL) abort();
+  if (DEC32_MIN != 1E-95DF) FAILURE
+  if (DEC64_MIN != 1E-383DD) FAILURE
+  if (DEC128_MIN != 1E-6143DL) FAILURE
+
+  if (DEC32_SUBNORMAL_MIN != 0.000001E-95DF) FAILURE
+  if (DEC64_SUBNORMAL_MIN != 0.000000000000001E-383DD) FAILURE
+  if (DEC128_SUBNORMAL_MIN != 0.000000000000000000000000000000001E-6143DL)
+    FAILURE
 
-  if (DEC32_DEN != 0.000001E-95DF) abort();
-  if (DEC64_DEN != 0.000000000000001E-383DD) abort();
-  if (DEC128_DEN != 0.000000000000000000000000000000001E-6143DL) abort();
+  if (failcnt != 0)
+    abort ();
 
   return 0;
 }