mirror of git://gcc.gnu.org/git/gcc.git
Use ::isinf and ::isnan if libc defines them
PR libstdc++/48891 * acinclude.m4 (GLIBCXX_CHECK_MATH11_PROTO): Check for obsolete isinf and isnan functions. * config.h.in: Regenerate. * configure: Regenerate. * include/c_global/cmath (isinf(double), isnan(double)) [_GLIBCXX_HAVE_OBSOLETE_ISINF_ISNAN]: Import via using-directive. * testsuite/26_numerics/headers/cmath/48891.cc: New. From-SVN: r232327
This commit is contained in:
parent
0b4b6ef227
commit
39a1d8c894
|
|
@ -1,3 +1,14 @@
|
||||||
|
2016-01-13 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
|
PR libstdc++/48891
|
||||||
|
* acinclude.m4 (GLIBCXX_CHECK_MATH11_PROTO): Check for obsolete isinf
|
||||||
|
and isnan functions.
|
||||||
|
* config.h.in: Regenerate.
|
||||||
|
* configure: Regenerate.
|
||||||
|
* include/c_global/cmath (isinf(double), isnan(double))
|
||||||
|
[_GLIBCXX_HAVE_OBSOLETE_ISINF_ISNAN]: Import via using-directive.
|
||||||
|
* testsuite/26_numerics/headers/cmath/48891.cc: New.
|
||||||
|
|
||||||
2016-01-13 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
|
2016-01-13 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
|
||||||
|
|
||||||
PR libstdc++/66006
|
PR libstdc++/66006
|
||||||
|
|
|
||||||
|
|
@ -2186,6 +2186,40 @@ AC_DEFUN([GLIBCXX_CHECK_MATH11_PROTO], [
|
||||||
fi
|
fi
|
||||||
AC_MSG_RESULT([$glibcxx_cv_math11_overload])
|
AC_MSG_RESULT([$glibcxx_cv_math11_overload])
|
||||||
;;
|
;;
|
||||||
|
*-*-*gnu*)
|
||||||
|
# If <math.h> defines the obsolete isinf(double) and isnan(double)
|
||||||
|
# functions (instead of or as well as the C99 generic macros) then we
|
||||||
|
# can't define std::isinf(double) and std::isnan(double) in <cmath>
|
||||||
|
# and must use the ones from <math.h> instead.
|
||||||
|
AC_MSG_CHECKING([for obsolete isinf and isnan functions in <math.h>])
|
||||||
|
AC_CACHE_VAL(glibcxx_cv_obsolete_isinf_isnan, [
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
|
||||||
|
[#include <math.h>
|
||||||
|
#undef isinf
|
||||||
|
#undef isnan
|
||||||
|
namespace std {
|
||||||
|
using ::isinf;
|
||||||
|
bool isinf(float);
|
||||||
|
bool isinf(long double);
|
||||||
|
using ::isnan;
|
||||||
|
bool isnan(float);
|
||||||
|
bool isnan(long double);
|
||||||
|
}
|
||||||
|
using std::isinf;
|
||||||
|
using std::isnan;
|
||||||
|
bool b = isinf(0.0) || isnan(0.0);
|
||||||
|
])],
|
||||||
|
[glibcxx_cv_obsolete_isinf_isnan=yes],
|
||||||
|
[glibcxx_cv_obsolete_isinf_isnan=no]
|
||||||
|
)])
|
||||||
|
|
||||||
|
|
||||||
|
if test $glibcxx_cv_obsolete_isinf_isnan = yes; then
|
||||||
|
AC_DEFINE(HAVE_OBSOLETE_ISINF_ISNAN, 1,
|
||||||
|
[Define if <math.h> defines obsolete isinf and isnan functions.])
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT([$glibcxx_cv_obsolete_isinf_isnan])
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CXXFLAGS="$ac_save_CXXFLAGS"
|
CXXFLAGS="$ac_save_CXXFLAGS"
|
||||||
|
|
|
||||||
|
|
@ -300,6 +300,9 @@
|
||||||
/* Define to 1 if you have the <nan.h> header file. */
|
/* Define to 1 if you have the <nan.h> header file. */
|
||||||
#undef HAVE_NAN_H
|
#undef HAVE_NAN_H
|
||||||
|
|
||||||
|
/* Define if <math.h> defines obsolete isinf and isnan functions. */
|
||||||
|
#undef HAVE_OBSOLETE_ISINF_ISNAN
|
||||||
|
|
||||||
/* Define if poll is available in <poll.h>. */
|
/* Define if poll is available in <poll.h>. */
|
||||||
#undef HAVE_POLL
|
#undef HAVE_POLL
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18174,6 +18174,54 @@ fi
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_math11_overload" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_math11_overload" >&5
|
||||||
$as_echo "$glibcxx_cv_math11_overload" >&6; }
|
$as_echo "$glibcxx_cv_math11_overload" >&6; }
|
||||||
;;
|
;;
|
||||||
|
*-*-*gnu*)
|
||||||
|
# If <math.h> defines the obsolete isinf(double) and isnan(double)
|
||||||
|
# functions (instead of or as well as the C99 generic macros) then we
|
||||||
|
# can't define std::isinf(double) and std::isnan(double) in <cmath>
|
||||||
|
# and must use the ones from <math.h> instead.
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for obsolete isinf and isnan functions in <math.h>" >&5
|
||||||
|
$as_echo_n "checking for obsolete isinf and isnan functions in <math.h>... " >&6; }
|
||||||
|
if test "${glibcxx_cv_obsolete_isinf_isnan+set}" = set; then :
|
||||||
|
$as_echo_n "(cached) " >&6
|
||||||
|
else
|
||||||
|
|
||||||
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
/* end confdefs.h. */
|
||||||
|
#include <math.h>
|
||||||
|
#undef isinf
|
||||||
|
#undef isnan
|
||||||
|
namespace std {
|
||||||
|
using ::isinf;
|
||||||
|
bool isinf(float);
|
||||||
|
bool isinf(long double);
|
||||||
|
using ::isnan;
|
||||||
|
bool isnan(float);
|
||||||
|
bool isnan(long double);
|
||||||
|
}
|
||||||
|
using std::isinf;
|
||||||
|
using std::isnan;
|
||||||
|
bool b = isinf(0.0) || isnan(0.0);
|
||||||
|
|
||||||
|
_ACEOF
|
||||||
|
if ac_fn_cxx_try_compile "$LINENO"; then :
|
||||||
|
glibcxx_cv_obsolete_isinf_isnan=yes
|
||||||
|
else
|
||||||
|
glibcxx_cv_obsolete_isinf_isnan=no
|
||||||
|
|
||||||
|
fi
|
||||||
|
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if test $glibcxx_cv_obsolete_isinf_isnan = yes; then
|
||||||
|
|
||||||
|
$as_echo "#define HAVE_OBSOLETE_ISINF_ISNAN 1" >>confdefs.h
|
||||||
|
|
||||||
|
fi
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_obsolete_isinf_isnan" >&5
|
||||||
|
$as_echo "$glibcxx_cv_obsolete_isinf_isnan" >&6; }
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CXXFLAGS="$ac_save_CXXFLAGS"
|
CXXFLAGS="$ac_save_CXXFLAGS"
|
||||||
|
|
|
||||||
|
|
@ -606,9 +606,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
isinf(float __x)
|
isinf(float __x)
|
||||||
{ return __builtin_isinf(__x); }
|
{ return __builtin_isinf(__x); }
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_OBSOLETE_ISINF_ISNAN
|
||||||
|
using ::isinf;
|
||||||
|
#else
|
||||||
constexpr bool
|
constexpr bool
|
||||||
isinf(double __x)
|
isinf(double __x)
|
||||||
{ return __builtin_isinf(__x); }
|
{ return __builtin_isinf(__x); }
|
||||||
|
#endif
|
||||||
|
|
||||||
constexpr bool
|
constexpr bool
|
||||||
isinf(long double __x)
|
isinf(long double __x)
|
||||||
|
|
@ -626,9 +630,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
isnan(float __x)
|
isnan(float __x)
|
||||||
{ return __builtin_isnan(__x); }
|
{ return __builtin_isnan(__x); }
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_OBSOLETE_ISINF_ISNAN
|
||||||
|
using ::isnan;
|
||||||
|
#else
|
||||||
constexpr bool
|
constexpr bool
|
||||||
isnan(double __x)
|
isnan(double __x)
|
||||||
{ return __builtin_isnan(__x); }
|
{ return __builtin_isnan(__x); }
|
||||||
|
#endif
|
||||||
|
|
||||||
constexpr bool
|
constexpr bool
|
||||||
isnan(long double __x)
|
isnan(long double __x)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Copyright (C) 2016 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this library; see the file COPYING3. If not see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// { dg-options "-std=gnu++11" }
|
||||||
|
// { dg-do compile }
|
||||||
|
|
||||||
|
// PR libstdc++/48891
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
using std::isinf;
|
||||||
|
using std::isnan;
|
||||||
|
|
||||||
|
bool d1 = isinf(1.0);
|
||||||
|
bool d2 = isnan(1.0);
|
||||||
Loading…
Reference in New Issue