re PR target/58757 (Advertise the lack of denormal support on alpha without -mieee)
authorMarc Glisse <glisse@gcc.gnu.org>
Thu, 11 Sep 2014 20:55:37 +0000 (20:55 +0000)
committerMarc Glisse <glisse@gcc.gnu.org>
Thu, 11 Sep 2014 20:55:37 +0000 (20:55 +0000)
2014-09-11  Marc Glisse  <marc.glisse@inria.fr>

PR target/58757
gcc/c-family/
* c-cppbuiltin.c (builtin_define_float_constants): Correct
__*_DENORM_MIN__ without denormals.
gcc/
* ginclude/float.h (FLT_TRUE_MIN, DBL_TRUE_MIN, LDBL_TRUE_MIN):
Directly forward to __*_DENORM_MIN__.
gcc/testsuite/
* gcc.dg/c11-true_min-1.c: New testcase.

From-SVN: r215191

gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-cppbuiltin.c
gcc/ginclude/float.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/c11-true_min-1.c [new file with mode: 0644]

index c0498fac28744a5fe2f55d6a7d027a49f9a1d048..117f7f3e3788edd0d00831eb064b6fa3aae35da6 100644 (file)
@@ -1,3 +1,9 @@
+2014-09-11  Marc Glisse  <marc.glisse@inria.fr>
+
+       PR target/58757
+       * ginclude/float.h (FLT_TRUE_MIN, DBL_TRUE_MIN, LDBL_TRUE_MIN):
+       Directly forward to __*_DENORM_MIN__.
+
 2014-09-11  David Malcolm  <dmalcolm@redhat.com>
 
        * rtl.h (LABEL_REF_LABEL): New macro.
index f24696db23be572a24b9df190edaa23344352684..ca22822649ac05792f0d58173e06c132df027fd9 100644 (file)
@@ -1,3 +1,9 @@
+2014-09-11  Marc Glisse  <marc.glisse@inria.fr>
+
+       PR target/58757
+       * c-cppbuiltin.c (builtin_define_float_constants): Correct
+       __*_DENORM_MIN__ without denormals.
+
 2014-09-10  Jakub Jelinek  <jakub@redhat.com>
 
        * c-ubsan.c (ubsan_instrument_division, ubsan_instrument_shift,
index 411ca194adae075ea489cccf8c6afd380ca84b18..da20676656094f9d0e9558c353dde33b878aa7ae 100644 (file)
@@ -270,21 +270,14 @@ builtin_define_float_constants (const char *name_prefix,
       sprintf (buf, "0x1p%d", 1 - fmt->p);
   builtin_define_with_hex_fp_value (name, type, decimal_dig, buf, fp_suffix, fp_cast);
 
-  /* For C++ std::numeric_limits<T>::denorm_min.  The minimum denormalized
-     positive floating-point number, b**(emin-p).  Zero for formats that
-     don't support denormals.  */
+  /* For C++ std::numeric_limits<T>::denorm_min and C11 *_TRUE_MIN.
+     The minimum denormalized positive floating-point number, b**(emin-p).
+     The minimum normalized positive floating-point number for formats
+     that don't support denormals.  */
   sprintf (name, "__%s_DENORM_MIN__", name_prefix);
-  if (fmt->has_denorm)
-    {
-      sprintf (buf, "0x1p%d", fmt->emin - fmt->p);
-      builtin_define_with_hex_fp_value (name, type, decimal_dig,
-                                       buf, fp_suffix, fp_cast);
-    }
-  else
-    {
-      sprintf (buf, "0.0%s", fp_suffix);
-      builtin_define_with_value (name, buf, 0);
-    }
+  sprintf (buf, "0x1p%d", fmt->emin - (fmt->has_denorm ? fmt->p : 1));
+  builtin_define_with_hex_fp_value (name, type, decimal_dig,
+                                   buf, fp_suffix, fp_cast);
 
   sprintf (name, "__%s_HAS_DENORM__", name_prefix);
   builtin_define_with_value (name, fmt->has_denorm ? "1" : "0", 0);
index a8e05bfcdf71dfbe850c28d7ce273bd2f34922b9..4927f3614ad909975b6905070cc72d9c63a9d020 100644 (file)
@@ -178,21 +178,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #undef FLT_TRUE_MIN
 #undef DBL_TRUE_MIN
 #undef LDBL_TRUE_MIN
-#if __FLT_HAS_DENORM__
 #define FLT_TRUE_MIN   __FLT_DENORM_MIN__
-#else
-#define FLT_TRUE_MIN   __FLT_MIN__
-#endif
-#if __DBL_HAS_DENORM__
 #define DBL_TRUE_MIN   __DBL_DENORM_MIN__
-#else
-#define DBL_TRUE_MIN   __DBL_MIN__
-#endif
-#if __LDBL_HAS_DENORM__
 #define LDBL_TRUE_MIN  __LDBL_DENORM_MIN__
-#else
-#define LDBL_TRUE_MIN  __LDBL_MIN__
-#endif
 
 #endif /* C11 */
 
index 3f88bb66c7ee64a43b7ffa84a296f24fe451527e..3aba1c7026af64072e27dd35f37971a028ac5533 100644 (file)
@@ -1,3 +1,8 @@
+2014-09-11  Marc Glisse  <marc.glisse@inria.fr>
+
+       PR target/58757
+       * gcc.dg/c11-true_min-1.c: New testcase.
+
 2014-09-11  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/61489
 
 2014-09-11  Bernd Schmidt  <bernds@codesourcery.com>
 
-        * gcc.dg/compat/struct-by-value-13_main.c (struct_by_value_13_x):
-        Fix declaration.
-        * gcc.dg/compat/struct-by-value-16a_main.c (struct_by_value_16a_x):
-        Fix declaration.
-        * gcc.dg/compat/struct-by-value-17a_main.c (struct_by_value_17a_x):
-        Fix declaration.
-        * gcc.dg/compat/struct-by-value-18a_main.c (struct_by_value_18a_x):
-        Fix declaration.
+       * gcc.dg/compat/struct-by-value-13_main.c (struct_by_value_13_x):
+       Fix declaration.
+       * gcc.dg/compat/struct-by-value-16a_main.c (struct_by_value_16a_x):
+       Fix declaration.
+       * gcc.dg/compat/struct-by-value-17a_main.c (struct_by_value_17a_x):
+       Fix declaration.
+       * gcc.dg/compat/struct-by-value-18a_main.c (struct_by_value_18a_x):
+       Fix declaration.
 
 2014-09-10  Jan Hubicka  <hubicka@ucw.cz>
 
diff --git a/gcc/testsuite/gcc.dg/c11-true_min-1.c b/gcc/testsuite/gcc.dg/c11-true_min-1.c
new file mode 100644 (file)
index 0000000..dcb761c
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+/* { dg-options "-std=c11" } */
+
+/* Test that the smallest positive value is not 0. This needs to be true
+   even when denormals are not supported, so we do not pass any flag
+   like -mieee.  If it fails on alpha, see PR 58757.  */
+
+#include <float.h>
+
+int main(){
+  volatile float f = FLT_TRUE_MIN;
+  volatile double d = DBL_TRUE_MIN;
+  volatile long double l = LDBL_TRUE_MIN;
+  if (f == 0 || d == 0 || l == 0)
+    __builtin_abort ();
+  return 0;
+}