This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[4.3 backport]: define nan as C99 builtin


Currently nanl in gcc 4.3.0 is defined as DEF_GCC_BUILTIN even
though it is a also a C99 function. This prevents appending
$LDBL128 to its symbol on darwin powerpc. This has been fixed on
gcc trunk with r132617. Attached is a backport of this patch
as well as the addition of BUILT_IN_NANL to config/darwin-ppc-ldouble-patch.def
from r132723. This completes the changes made for powerpc-apple-darwin
long double support. Tested without regression on gcc 4.3 branch.
Okay for gcc 4.3 branch?
                   Jack

2008-02-29  Uros Bizjak  <ubizjak@gmail.com>

	PR middle-end/19984
	* builtins.def (BUILT_IN_NAN): Define as c99 builtin
	using DEF_C99_BUILTIN.
	(BUILT_IN_NANF): Ditto.
	(BUILT_IN_NANL): Ditto.

testsuite/ChangeLog:

2008-02-29  Uros Bizjak  <ubizjak@gmail.com>

	PR middle-end/19984
	* gcc.dg/pr19984.c: New test.
	* gcc.dg/dfp/compare-special.h: Use _nan instead of nan as the
	name of the variable.

2008-02-29 Uros Bizjak <ubizjak@gmail.com>

	PR target/25477
	* config/darwin-ppc-ldouble-patch.def (BUILT_IN_NANL): Add.


Index: testsuite/gcc.dg/pr19984.c
===================================================================
--- testsuite/gcc.dg/pr19984.c	(revision 0)
+++ testsuite/gcc.dg/pr19984.c	(revision 0)
@@ -0,0 +1,17 @@
+/* PR c/19984 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -std=c99" } */
+
+
+double nan (const char *);
+
+const double nok = nan ("");	/* { dg-warning "(not constant)|(near initialization)" } */
+
+const double ok = __builtin_nan ("");
+
+double
+foo ()
+{
+  double ok2 = nan ("");
+  return ok2;
+}
Index: testsuite/gcc.dg/dfp/compare-special.h
===================================================================
--- testsuite/gcc.dg/dfp/compare-special.h	(revision 132762)
+++ testsuite/gcc.dg/dfp/compare-special.h	(working copy)
@@ -47,13 +47,13 @@
 DTYPE one   = PASTE(1.0, SUFFIX);
 DTYPE two   = PASTE(2.0, SUFFIX);
 
-volatile DTYPE x, y, z, nan, inf, m_inf;
+volatile DTYPE x, y, z, _nan, inf, m_inf;
 
 void
 test_compares (void)
 {
-  nan = PASTE(__builtin_nan, SUFFIX2) ("");
-  inf = PASTE(__builtin_inf, SUFFIX2) ();
+  _nan = PASTE(__builtin_nan, SUFFIX2) ("");
+  inf =  PASTE(__builtin_inf, SUFFIX2) ();
   m_inf = - PASTE(__builtin_inf, SUFFIX2) ();
 
   x = PASTE(__builtin_nan, SUFFIX2) ("");
@@ -65,14 +65,14 @@
   if (x <= two)   FAILURE ("<=", "NaN")
   if (x <= zero)  FAILURE ("<=", "NaN")
   if (x <= m_one) FAILURE ("<=", "NaN")
-  if (x <= nan)   FAILURE ("<=", "NaN")
+  if (x <= _nan)  FAILURE ("<=", "NaN")
   if (x <= inf)   FAILURE ("<=", "NaN")
   if (x <= m_inf) FAILURE ("<=", "NaN")
 
   if (two <= x)   FAILURE ("<=", "NaN")
   if (zero <= x)  FAILURE ("<=", "NaN")
   if (m_one <= x) FAILURE ("<=", "NaN")
-  if (nan <= x)   FAILURE ("<=", "NaN")
+  if (_nan <= x)  FAILURE ("<=", "NaN")
   if (inf <= x)   FAILURE ("<=", "NaN")
   if (m_inf <= x) FAILURE ("<=", "NaN")
 
@@ -102,14 +102,14 @@
   if (x < two)       FAILURE ("<", "NaN")
   if (x < zero)      FAILURE ("<", "NaN")
   if (x < m_one)     FAILURE ("<", "NaN")
-  if (x < nan)       FAILURE ("<", "NaN")
+  if (x < _nan)      FAILURE ("<", "NaN")
   if (x < inf)       FAILURE ("<", "NaN")
   if (x < m_inf)     FAILURE ("<", "NaN")
 
   if (two < x)       FAILURE ("<", "NaN")
   if (zero < x)      FAILURE ("<", "NaN")
   if (m_one < x)     FAILURE ("<", "NaN")
-  if (nan < x)       FAILURE ("<", "NaN")
+  if (_nan < x)      FAILURE ("<", "NaN")
   if (inf < x)       FAILURE ("<", "NaN")
   if (m_inf < x)     FAILURE ("<", "NaN")
 
@@ -139,14 +139,14 @@
   if (x >= two)      FAILURE (">=", "NaN")
   if (x >= zero)     FAILURE (">=", "NaN")
   if (x >= m_one)    FAILURE (">=", "NaN")
-  if (x >= nan)      FAILURE (">=", "NaN")
+  if (x >= _nan)     FAILURE (">=", "NaN")
   if (x >= inf)      FAILURE (">=", "NaN")
   if (x >= m_inf)    FAILURE (">=", "NaN")
 
   if (two >= x)      FAILURE (">=", "NaN")
   if (zero >= x)     FAILURE (">=", "NaN")
   if (m_one >= x)    FAILURE (">=", "NaN")
-  if (nan >= x)      FAILURE (">=", "NaN")
+  if (_nan >= x)     FAILURE (">=", "NaN")
   if (inf >= x)      FAILURE (">=", "NaN")
   if (m_inf >= x)    FAILURE (">=", "NaN")
 
@@ -176,14 +176,14 @@
   if (x > two)       FAILURE (">", "NaN")
   if (x > zero)      FAILURE (">", "NaN")
   if (x > m_one)     FAILURE (">", "NaN")
-  if (x > nan)       FAILURE (">", "NaN")
+  if (x > _nan)      FAILURE (">", "NaN")
   if (x > inf)       FAILURE (">", "NaN")
   if (x > m_inf)     FAILURE (">", "NaN")
 
   if (two > x)       FAILURE (">", "NaN")
   if (zero > x)      FAILURE (">", "NaN")
   if (m_one > x)     FAILURE (">", "NaN")
-  if (nan > x)       FAILURE (">", "NaN")
+  if (_nan > x)      FAILURE (">", "NaN")
   if (inf > x)       FAILURE (">", "NaN")
   if (m_inf > x)     FAILURE (">", "NaN")
 
@@ -213,14 +213,14 @@
   if (x == two)      FAILURE ("==", "NaN")
   if (x == zero)     FAILURE ("==", "NaN")
   if (x == m_one)    FAILURE ("==", "NaN")
-  if (x == nan)      FAILURE ("==", "NaN")
+  if (x == _nan)     FAILURE ("==", "NaN")
   if (x == inf)      FAILURE ("==", "NaN")
   if (x == m_inf)    FAILURE ("==", "NaN")
 
   if (two == x)      FAILURE ("==", "NaN")
   if (zero == x)     FAILURE ("==", "NaN")
   if (m_one == x)    FAILURE ("==", "NaN")
-  if (nan == x)      FAILURE ("==", "NaN")
+  if (_nan == x)     FAILURE ("==", "NaN")
   if (inf == x)      FAILURE ("==", "NaN")
   if (m_inf == x)    FAILURE ("==", "NaN")
 
@@ -250,14 +250,14 @@
   if (!(x != two))   FAILURE ("!=", "NaN")
   if (!(x != zero))  FAILURE ("!=", "NaN")
   if (!(x != m_one)) FAILURE ("!=", "NaN")
-  if (!(x != nan))   FAILURE ("!=", "NaN")
+  if (!(x != _nan))  FAILURE ("!=", "NaN")
   if (!(x != inf))   FAILURE ("!=", "NaN")
   if (!(x != m_inf)) FAILURE ("!=", "NaN")
 
   if (!(two != x))   FAILURE ("!=", "NaN")
   if (!(zero != x))  FAILURE ("!=", "NaN")
   if (!(m_one != x)) FAILURE ("!=", "NaN")
-  if (!(nan != x))   FAILURE ("!=", "NaN")
+  if (!(_nan != x))  FAILURE ("!=", "NaN")
   if (!(inf != x))   FAILURE ("!=", "NaN")
   if (!(m_inf != x)) FAILURE ("!=", "NaN")
 
Index: builtins.def
===================================================================
--- builtins.def	(revision 132762)
+++ builtins.def	(working copy)
@@ -336,9 +336,9 @@
 DEF_LIB_BUILTIN        (BUILT_IN_MODF, "modf", BT_FN_DOUBLE_DOUBLE_DOUBLEPTR, ATTR_MATHFN_FPROUNDING_STORE)
 DEF_C99_C90RES_BUILTIN (BUILT_IN_MODFF, "modff", BT_FN_FLOAT_FLOAT_FLOATPTR, ATTR_MATHFN_FPROUNDING_STORE)
 DEF_C99_C90RES_BUILTIN (BUILT_IN_MODFL, "modfl", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLEPTR, ATTR_MATHFN_FPROUNDING_STORE)
-DEF_GCC_BUILTIN        (BUILT_IN_NAN, "nan", BT_FN_DOUBLE_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
-DEF_GCC_BUILTIN        (BUILT_IN_NANF, "nanf", BT_FN_FLOAT_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
-DEF_GCC_BUILTIN        (BUILT_IN_NANL, "nanl", BT_FN_LONGDOUBLE_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
+DEF_C99_BUILTIN        (BUILT_IN_NAN, "nan", BT_FN_DOUBLE_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
+DEF_C99_BUILTIN        (BUILT_IN_NANF, "nanf", BT_FN_FLOAT_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
+DEF_C99_BUILTIN        (BUILT_IN_NANL, "nanl", BT_FN_LONGDOUBLE_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
 DEF_GCC_BUILTIN        (BUILT_IN_NAND32, "nand32", BT_FN_DFLOAT32_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
 DEF_GCC_BUILTIN        (BUILT_IN_NAND64, "nand64", BT_FN_DFLOAT64_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
 DEF_GCC_BUILTIN        (BUILT_IN_NAND128, "nand128", BT_FN_DFLOAT128_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL)
Index: config/darwin-ppc-ldouble-patch.def
===================================================================
--- config/darwin-ppc-ldouble-patch.def	(revision 132762)
+++ config/darwin-ppc-ldouble-patch.def	(working copy)
@@ -59,6 +59,7 @@
 PATCH_BUILTIN (BUILT_IN_LRINTL)
 PATCH_BUILTIN (BUILT_IN_LROUNDL)
 PATCH_BUILTIN (BUILT_IN_MODFL)
+PATCH_BUILTIN (BUILT_IN_NANL)
 PATCH_BUILTIN (BUILT_IN_NEARBYINTL)
 PATCH_BUILTIN (BUILT_IN_NEXTAFTERL)
 PATCH_BUILTIN (BUILT_IN_NEXTTOWARDL)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]