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]

Patch for PR 14635 (regression: nan not in C90)


This patch fixes bug 14635: nan functions should not be built in in
C90 mode and properly should use DEF_GCC_BUILTIN.  Bootstrapped with
no regressions on i686-pc-linux-gnu.  OK to commit to mainline and 3.4
branch?

2004-03-18  Joseph S. Myers  <jsm@polyomino.org.uk>

	PR c/14635
	* builtins.def (nan, nanf, nanl, nans, nansf, nansl): Change to
	DEF_GCC_BUILTIN.

testsuite:
2004-03-18  Joseph S. Myers  <jsm@polyomino.org.uk>

	PR c/14635
	* builtins-1.c (nan, nans): Don't test.
	* builtins-30.c: Don't use nan, nanf, nanl.
	* builtins-35.c: New test.

--- GCC/gcc/builtins.def.orig	2004-02-10 10:59:16.000000000 +0000
+++ GCC/gcc/builtins.def	2004-03-17 15:33:33.000000000 +0000
@@ -279,12 +279,12 @@
 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_LIB_BUILTIN        (BUILT_IN_NAN, "nan", BT_FN_DOUBLE_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL_1)
-DEF_LIB_BUILTIN        (BUILT_IN_NANF, "nanf", BT_FN_FLOAT_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL_1)
-DEF_LIB_BUILTIN        (BUILT_IN_NANL, "nanl", BT_FN_LONGDOUBLE_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL_1)
-DEF_LIB_BUILTIN        (BUILT_IN_NANS, "nans", BT_FN_DOUBLE_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL_1)
-DEF_LIB_BUILTIN        (BUILT_IN_NANSF, "nansf", BT_FN_FLOAT_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL_1)
-DEF_LIB_BUILTIN        (BUILT_IN_NANSL, "nansl", BT_FN_LONGDOUBLE_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL_1)
+DEF_GCC_BUILTIN        (BUILT_IN_NAN, "nan", BT_FN_DOUBLE_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL_1)
+DEF_GCC_BUILTIN        (BUILT_IN_NANF, "nanf", BT_FN_FLOAT_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL_1)
+DEF_GCC_BUILTIN        (BUILT_IN_NANL, "nanl", BT_FN_LONGDOUBLE_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL_1)
+DEF_GCC_BUILTIN        (BUILT_IN_NANS, "nans", BT_FN_DOUBLE_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL_1)
+DEF_GCC_BUILTIN        (BUILT_IN_NANSF, "nansf", BT_FN_FLOAT_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL_1)
+DEF_GCC_BUILTIN        (BUILT_IN_NANSL, "nansl", BT_FN_LONGDOUBLE_CONST_STRING, ATTR_CONST_NOTHROW_NONNULL_1)
 DEF_C99_BUILTIN        (BUILT_IN_NEARBYINT, "nearbyint", BT_FN_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_NEARBYINTF, "nearbyintf", BT_FN_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_NEARBYINTL, "nearbyintl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LIST)
--- GCC/gcc/testsuite/gcc.dg/builtins-1.c.orig	2004-02-02 11:01:30.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/builtins-1.c	2004-03-17 23:25:12.000000000 +0000
@@ -151,8 +151,6 @@
 FPTEST1RET  (lrint, long)
 FPTEST1RET  (lround, long)
 FPTEST2FPP2 (modf)
-FPTEST1ARG  (nan, char *)
-FPTEST1ARG  (nans, char *)
 FPTEST1     (nearbyint)
 FPTEST2     (nextafter)
 FPTEST2     (nexttoward)
--- GCC/gcc/testsuite/gcc.dg/builtins-30.c.orig	2004-01-24 20:46:59.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/builtins-30.c	2004-03-17 23:30:41.000000000 +0000
@@ -6,21 +6,21 @@
 
 /* A built-in function may be overridden by an old-style definition
    specifying too few arguments... */
-double nan ()
+double cos ()
 {  /* { dg-warning "shadowing built-in" } */
   return strtod ("nan", 0);
 }
 
 /* the right number, but the wrong type, arguments... */
-float nanf (foo)
+double sin (foo)
      int foo UNUSED;  /* { dg-warning "shadowing built-in" } */
 {
   return strtod ("nan", 0);
 }
 
 /* or too many arguments.  */
-long double nanl (foo, bar)
-     const char *foo UNUSED;  /* { dg-warning "shadowing built-in" } */
+long double cosl (foo, bar)
+     long double foo UNUSED;  /* { dg-warning "shadowing built-in" } */
      int bar UNUSED;
 {
   return strtod ("nan", 0);
--- GCC/gcc/testsuite/gcc.dg/builtins-35.c	2002-08-26 16:21:36.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/builtins-35.c	2004-03-18 15:07:25.000000000 +0000
@@ -0,0 +1,6 @@
+/* Test that nan functions are not built-in in C90 mode.  Bug 14635.  */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=c89" } */
+
+int nan, nanf, nanl, nans, nansf, nansl;

-- 
Joseph S. Myers
jsm@polyomino.org.uk


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