summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2020-12-21 15:15:36 -0500
committerPatrick Palka <ppalka@redhat.com>2020-12-21 15:15:36 -0500
commit6a31d47e271d066ea85b3716f7b77f18e6b55242 (patch)
tree02684ce11cb6b5026d2c1cd62b7b753dd5d960f2 /libstdc++-v3/testsuite
parente798f081925b5085de3c9d0f330eb6e255a377bf (diff)
downloadgcc-6a31d47e271d066ea85b3716f7b77f18e6b55242.tar.gz
libstdc++: Disable floating-point std::to_chars on unsupported targets
This patch conditionally disables the floating-point std::to_chars implementation on targets whose float and double aren't IEEE binary32 and binary64, until a proper fallback can be added for such targets. This fixes a bootstrap failure on non-IEEE-754 FP targets such as vax-netbsdelf. The new preprocessor tests in c++config that detect the binary32 and binary64 formats were copied from gcc/testsuite/gcc.dg/float-exact-1.c. libstdc++-v3/ChangeLog: * include/bits/c++config (_GLIBCXX_FLOAT_IS_IEEE_BINARY_32): Define this macro. (_GLIBCXX_DOUBLE_IS_IEEE_BINARY_64): Likewise. * include/std/charconv (to_chars): Use these macros to conditionally hide the overloads for floating-point types. * src/c++17/floating_to_chars.cc: Use the macros to conditionally disable this file. (floating_type_traits<float>): Remove redundant static assert. (floating_type_traits<double>): Likewise. * testsuite/20_util/to_chars/double.cc: Run this test only on ieee-floats effective targets. * testsuite/20_util/to_chars/float.cc: Likewise. * testsuite/20_util/to_chars/long_double.cc: Likewise. * testsuite/lib/libstdc++.exp (check_effective_target_ieee-floats): Define new proc for detecting whether float and double have the IEEE binary32 and binary64 formats.
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/20_util/to_chars/double.cc1
-rw-r--r--libstdc++-v3/testsuite/20_util/to_chars/float.cc1
-rw-r--r--libstdc++-v3/testsuite/20_util/to_chars/long_double.cc1
-rw-r--r--libstdc++-v3/testsuite/lib/libstdc++.exp8
4 files changed, 11 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/20_util/to_chars/double.cc b/libstdc++-v3/testsuite/20_util/to_chars/double.cc
index 9d1f37d3026..bb6f74424ed 100644
--- a/libstdc++-v3/testsuite/20_util/to_chars/double.cc
+++ b/libstdc++-v3/testsuite/20_util/to_chars/double.cc
@@ -32,6 +32,7 @@
// DEALINGS IN THE SOFTWARE.
// { dg-do run { target c++17 } }
+// { dg-require-effective-target ieee-floats }
#include <charconv>
diff --git a/libstdc++-v3/testsuite/20_util/to_chars/float.cc b/libstdc++-v3/testsuite/20_util/to_chars/float.cc
index b8901063ea0..0c8dd4f66df 100644
--- a/libstdc++-v3/testsuite/20_util/to_chars/float.cc
+++ b/libstdc++-v3/testsuite/20_util/to_chars/float.cc
@@ -32,6 +32,7 @@
// DEALINGS IN THE SOFTWARE.
// { dg-do run { target c++17 } }
+// { dg-require-effective-target ieee-floats }
#include <charconv>
diff --git a/libstdc++-v3/testsuite/20_util/to_chars/long_double.cc b/libstdc++-v3/testsuite/20_util/to_chars/long_double.cc
index 12ac8ae7822..f89daa2c665 100644
--- a/libstdc++-v3/testsuite/20_util/to_chars/long_double.cc
+++ b/libstdc++-v3/testsuite/20_util/to_chars/long_double.cc
@@ -19,6 +19,7 @@
// hexadecimal floating-point literals.
// { dg-do run { target c++17 } }
// { dg-xfail-run-if "Ryu needs __int128" { large_long_double && { ! int128 } } }
+// { dg-require-effective-target ieee-floats }
#include <charconv>
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index b7d7b906de4..6e5634ef1d2 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1323,6 +1323,14 @@ proc check_effective_target_futex { } {
}]
}
+# Return 1 if float and double have the IEEE binary32 and binary64 formats.
+proc check_effective_target_ieee-floats { } {
+ return [check_v3_target_prop_cached et_ieee_floats {
+ set cond "_GLIBCXX_FLOAT_IS_IEEE_BINARY32 && _GLIBCXX_DOUBLE_IS_IEEE_BINARY64"
+ return [v3_check_preprocessor_condition ieee_floats $cond]
+ }]
+}
+
set additional_prunes ""
if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \