diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/c-cppbuiltin.c | 5 | ||||
-rw-r--r-- | gcc/cppbuiltin.c | 2 | ||||
-rw-r--r-- | gcc/doc/cpp.texi | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/no-math-errno-1.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/no-math-errno-2.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/no-math-errno-3.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/no-math-errno-4.c | 17 |
10 files changed, 65 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9b422f4..8d52622b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-11-12 Joseph Myers <joseph@codesourcery.com> + + * cppbuiltin.c (define_builtin_macros_for_compilation_flags): + Define __NO_MATH_ERRNO__ if -fno-math-errno. + * doc/cpp.texi (__NO_MATH_ERRNO__): Document predefined macro. + 2014-11-12 Richard Biener <rguenther@suse.de> * genmatch.c (::gen_transform): Add capture_info and diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 7feda0f..4eb90fc 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2014-11-12 Joseph Myers <joseph@codesourcery.com> + + * c-cppbuiltin.c (c_cpp_builtins_optimize_pragma): Define and + undefine __NO_MATH_ERRNO__ based on changes to -fmath-errno state. + 2014-11-12 Jakub Jelinek <jakub@redhat.com> PR c/59708 diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index a4ed5c6..c571d1b 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -549,6 +549,11 @@ c_cpp_builtins_optimize_pragma (cpp_reader *pfile, tree prev_tree, else if (prev->x_flag_signaling_nans && !cur->x_flag_signaling_nans) cpp_undef (pfile, "__SUPPORT_SNAN__"); + if (!prev->x_flag_errno_math && cur->x_flag_errno_math) + cpp_undef (pfile, "__NO_MATH_ERRNO__"); + else if (prev->x_flag_errno_math && !cur->x_flag_errno_math) + cpp_define (pfile, "__NO_MATH_ERRNO__"); + if (!prev->x_flag_finite_math_only && cur->x_flag_finite_math_only) { cpp_undef (pfile, "__FINITE_MATH_ONLY__"); diff --git a/gcc/cppbuiltin.c b/gcc/cppbuiltin.c index 3fc2f8a..474f724 100644 --- a/gcc/cppbuiltin.c +++ b/gcc/cppbuiltin.c @@ -102,6 +102,8 @@ define_builtin_macros_for_compilation_flags (cpp_reader *pfile) cpp_define (pfile, "__FAST_MATH__"); if (flag_signaling_nans) cpp_define (pfile, "__SUPPORT_SNAN__"); + if (!flag_errno_math) + cpp_define (pfile, "__NO_MATH_ERRNO__"); cpp_define_formatted (pfile, "__FINITE_MATH_ONLY__=%d", flag_finite_math_only); diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi index f32aac7..df04d0b 100644 --- a/gcc/doc/cpp.texi +++ b/gcc/doc/cpp.texi @@ -2421,6 +2421,10 @@ Annex G requirements (for example, because @option{-fcx-limited-range} was used). If 1 or more, it indicates that it is intended to support those requirements; this does not mean that all relevant language features are supported by GCC. + +@item __NO_MATH_ERRNO__ +This macro is defined if @option{-fno-math-errno} is used, or enabled +by another option such as @option{-ffast-math} or by default. @end table @node System-specific Predefined Macros diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c72e75f..0b5b094 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-11-12 Joseph Myers <joseph@codesourcery.com> + + * gcc.dg/no-math-errno-1.c, gcc.dg/no-math-errno-2.c, + gcc.dg/no-math-errno-3.c, gcc.dg/no-math-errno-4.c: New tests. + 2014-11-12 H.J. Lu <hongjiu.lu@intel.com> PR testsuite/63830 diff --git a/gcc/testsuite/gcc.dg/no-math-errno-1.c b/gcc/testsuite/gcc.dg/no-math-errno-1.c new file mode 100644 index 0000000..2659f59 --- /dev/null +++ b/gcc/testsuite/gcc.dg/no-math-errno-1.c @@ -0,0 +1,7 @@ +/* Test __NO_MATH_ERRNO__ is defined with -fno-math-errno. */ +/* { dg-do compile } */ +/* { dg-options "-fno-math-errno" } */ + +#ifndef __NO_MATH_ERRNO__ +#error "__NO_MATH_ERRNO__ not defined" +#endif diff --git a/gcc/testsuite/gcc.dg/no-math-errno-2.c b/gcc/testsuite/gcc.dg/no-math-errno-2.c new file mode 100644 index 0000000..f44a997 --- /dev/null +++ b/gcc/testsuite/gcc.dg/no-math-errno-2.c @@ -0,0 +1,7 @@ +/* Test __NO_MATH_ERRNO__ is defined with -ffast-math. */ +/* { dg-do compile } */ +/* { dg-options "-ffast-math" } */ + +#ifndef __NO_MATH_ERRNO__ +#error "__NO_MATH_ERRNO__ not defined" +#endif diff --git a/gcc/testsuite/gcc.dg/no-math-errno-3.c b/gcc/testsuite/gcc.dg/no-math-errno-3.c new file mode 100644 index 0000000..e19e94f --- /dev/null +++ b/gcc/testsuite/gcc.dg/no-math-errno-3.c @@ -0,0 +1,7 @@ +/* Test __NO_MATH_ERRNO__ is not defined with -fmath-errno. */ +/* { dg-do compile } */ +/* { dg-options "-fmath-errno" } */ + +#ifdef __NO_MATH_ERRNO__ +#error "__NO_MATH_ERRNO__ defined" +#endif diff --git a/gcc/testsuite/gcc.dg/no-math-errno-4.c b/gcc/testsuite/gcc.dg/no-math-errno-4.c new file mode 100644 index 0000000..c6daa12 --- /dev/null +++ b/gcc/testsuite/gcc.dg/no-math-errno-4.c @@ -0,0 +1,17 @@ +/* Test __NO_MATH_ERRNO__ is defined and undefined by pragmas. */ +/* { dg-do compile } */ +/* { dg-options "-fmath-errno" } */ + +#ifdef __NO_MATH_ERRNO__ +#error "__NO_MATH_ERRNO__ defined" +#endif + +#pragma GCC optimize "-fno-math-errno" +#ifndef __NO_MATH_ERRNO__ +#error "__NO_MATH_ERRNO__ not defined" +#endif + +#pragma GCC optimize "-fmath-errno" +#ifdef __NO_MATH_ERRNO__ +#error "__NO_MATH_ERRNO__ defined" +#endif |