aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-09-25 16:07:50 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2024-09-25 16:26:35 +0200
commit0564d9501ebf11c9f0c541ac79054a38ec791d8c (patch)
tree66ab207a2e62c6d16fb69caf3a76b6b3227f19fb /gcc
parent340ef96560da93891418c39d38b5d90f6bd47053 (diff)
downloadgcc-0564d9501ebf11c9f0c541ac79054a38ec791d8c.zip
gcc-0564d9501ebf11c9f0c541ac79054a38ec791d8c.tar.gz
gcc-0564d9501ebf11c9f0c541ac79054a38ec791d8c.tar.bz2
c++: Add testcase for DR 2836
Seems we already handle it the way the DR clarifies, if double/long double and std::float64_t have the same mode, foo has long double type (while x + y would be _Float64 in C23), so this patch just adds a testcase which verifies that. 2024-09-25 Jakub Jelinek <jakub@redhat.com> * g++.dg/DRs/dr2836.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/g++.dg/DRs/dr2836.C30
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/DRs/dr2836.C b/gcc/testsuite/g++.dg/DRs/dr2836.C
new file mode 100644
index 0000000..88e35a7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/DRs/dr2836.C
@@ -0,0 +1,30 @@
+// DR 2836 - Conversion rank of long double and extended floating-point types
+// { dg-do compile { target c++23 } }
+// { dg-additional-options "-mlong-double-64" { target powerpc*-*-* s390*-*-* } }
+
+#include <stdfloat>
+
+#if defined (__STDCPP_FLOAT64_T__) \
+ && __LDBL_MAX_EXP__ == __FLT64_MAX_EXP__ \
+ && __LDBL_MANT_DIG__ == __FLT64_MANT_DIG__ \
+ && __DBL_MAX_EXP__ == __FLT64_MAX_EXP__ \
+ && __DBL_MANT_DIG__ == __FLT64_MANT_DIG__
+auto
+foo (long double x, std::float64_t y)
+{
+ return x + y;
+}
+
+template<typename T, T v> struct integral_constant {
+ static constexpr T value = v;
+};
+typedef integral_constant<bool, false> false_type;
+typedef integral_constant<bool, true> true_type;
+template<class T, class U>
+struct is_same : false_type {};
+template <class T>
+struct is_same<T, T> : true_type {};
+
+static_assert (is_same <decltype (foo (1.0L, 1.0F64)), long double>::value);
+
+#endif