aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2019-05-03 20:25:05 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2019-05-03 20:25:05 +0100
commite339291fc13d074bade3fd9ab3cbfacce5a21cbd (patch)
tree2c50a2cca767aa1e4aa1d00ebdeff95742a12e7b
parent56e5b093de436686effacab1f3211f8695be39a6 (diff)
downloadgcc-e339291fc13d074bade3fd9ab3cbfacce5a21cbd.zip
gcc-e339291fc13d074bade3fd9ab3cbfacce5a21cbd.tar.gz
gcc-e339291fc13d074bade3fd9ab3cbfacce5a21cbd.tar.bz2
Fix new testcase to not require std::copysign
Use __builtin_copysign{,f,l} when std::copysign isn't available. PR libstdc++/61761 * testsuite/26_numerics/complex/proj.cc: Don't assume <cmath> defines std::copysign. From-SVN: r270859
-rw-r--r--libstdc++-v3/ChangeLog4
-rw-r--r--libstdc++-v3/testsuite/26_numerics/complex/proj.cc20
2 files changed, 22 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index b139014..4039631 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,9 @@
2019-05-03 Jonathan Wakely <jwakely@redhat.com>
+ PR libstdc++/61761
+ * testsuite/26_numerics/complex/proj.cc: Don't assume <cmath> defines
+ std::copysign.
+
PR libstdc++/52119
* include/ext/numeric_traits.h (__glibcxx_min): Avoid integer
overflow warning with -Wpedantic -Wsystem-headers.
diff --git a/libstdc++-v3/testsuite/26_numerics/complex/proj.cc b/libstdc++-v3/testsuite/26_numerics/complex/proj.cc
index b70ca4c..caf12d2 100644
--- a/libstdc++-v3/testsuite/26_numerics/complex/proj.cc
+++ b/libstdc++-v3/testsuite/26_numerics/complex/proj.cc
@@ -21,6 +21,22 @@
#include <limits>
#include <testsuite_hooks.h>
+namespace test
+{
+#ifdef _GLIBCXX_USE_C99_MATH_TR1
+ using std::copysign;
+#else
+ bool copysign(float x, float y)
+ { return __builtin_copysignf(x, y); }
+
+ bool copysign(double x, double y)
+ { return __builtin_copysign(x, y); }
+
+ bool copysign(long double x, long double y)
+ { return __builtin_copysignl(x, y); }
+#endif
+}
+
template<typename T>
bool eq(const std::complex<T>& x, const std::complex<T>& y)
{
@@ -28,9 +44,9 @@ bool eq(const std::complex<T>& x, const std::complex<T>& y)
bool nan_imags = std::isnan(x.imag()) && std::isnan(y.imag());
bool sign_reals
- = std::copysign(T(1), x.real()) == std::copysign(T(1), y.real());
+ = test::copysign(T(1), x.real()) == test::copysign(T(1), y.real());
bool sign_imags
- = std::copysign(T(1), x.imag()) == std::copysign(T(1), y.imag());
+ = test::copysign(T(1), x.imag()) == test::copysign(T(1), y.imag());
return ((x.real() == y.real() && sign_reals) || nan_reals)
&& ((x.imag() == y.imag() && sign_imags) || nan_imags);