summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2023-05-17 20:59:54 +0200
committerJakub Jelinek <jakub@redhat.com>2023-05-17 20:59:54 +0200
commitc8da62cfc6475c4b7213b2164c2c0ec8ea6d96b6 (patch)
tree27c8903daac043c050b1020a9588732f879c4353
parentf289749578d114b6fe71f62eaef05d63138d05e0 (diff)
downloadgcc-c8da62cfc6475c4b7213b2164c2c0ec8ea6d96b6.tar.gz
i386: Fix up types in __builtin_{inf,huge_val,nan{,s},fabs,copysign}q builtins [PR109884]
When _Float128 support has been added to C++ for 13.1, float128t_type_node tree has been added - in C float128_type_node and float128t_type_node is the same and represents both _Float128 and __float128, but in C++ they are distinct types which have different handling in the FEs. When doing that change, I mistakenly forgot to change FLOAT128 primitive type, which is used for the __builtin_{inf,huge_val,nan{,s},fabs,copysign}q builtins results and some of their arguments (and nothing else). The following patch fixes that. On ia64 we already use float128t_type_node for those builtins, pa while it has __float128 that type is the same as long double and so those builtins have long double types and on powerpc seems we don't have these builtins but instead define macros which map them to __builtin_*f128. That will not work properly in C++, perhaps we should change those macros to be function-like and cast to __float128. 2023-05-17 Jakub Jelinek <jakub@redhat.com> PR c++/109884 * config/i386/i386-builtin-types.def (FLOAT128): Use float128t_type_node rather than float128_type_node. * c-c++-common/pr109884.c: New test.
-rw-r--r--gcc/config/i386/i386-builtin-types.def2
-rw-r--r--gcc/testsuite/c-c++-common/pr109884.c32
2 files changed, 33 insertions, 1 deletions
diff --git a/gcc/config/i386/i386-builtin-types.def b/gcc/config/i386/i386-builtin-types.def
index 65fe070e37f..cb2d0cd56ed 100644
--- a/gcc/config/i386/i386-builtin-types.def
+++ b/gcc/config/i386/i386-builtin-types.def
@@ -73,7 +73,7 @@ DEF_PRIMITIVE_TYPE (BFLOAT16, ix86_bf16_type_node)
DEF_PRIMITIVE_TYPE (FLOAT, float_type_node)
DEF_PRIMITIVE_TYPE (DOUBLE, double_type_node)
DEF_PRIMITIVE_TYPE (FLOAT80, float80_type_node)
-DEF_PRIMITIVE_TYPE (FLOAT128, float128_type_node)
+DEF_PRIMITIVE_TYPE (FLOAT128, float128t_type_node)
DEF_PRIMITIVE_TYPE (CONST_STRING, const_string_type_node)
# MMX vectors
diff --git a/gcc/testsuite/c-c++-common/pr109884.c b/gcc/testsuite/c-c++-common/pr109884.c
new file mode 100644
index 00000000000..2625c8765b8
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr109884.c
@@ -0,0 +1,32 @@
+/* PR c++/109884 */
+/* PowerPC doesn't define these as builtins, but macros expanding to
+ *f128 builtins. */
+/* { dg-do compile { target { __float128 && { { c || c++11 } && { ! powerpc*-*-* } } } } } */
+/* { dg-add-options __float128 } */
+
+#ifdef __cplusplus
+template <typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template <typename T>
+struct is_same <T, T> {
+ static const bool value = true;
+};
+#define HAS_TYPE(E, U) static_assert (is_same <decltype (E), U>::value, "")
+#else
+#define HAS_TYPE(E, U) _Static_assert (_Generic (E, default : 0, U : 1), "")
+#endif
+
+void
+foo ()
+{
+ __float128 a = 0;
+ HAS_TYPE (__builtin_infq (), __float128);
+ HAS_TYPE (__builtin_huge_valq (), __float128);
+ HAS_TYPE (__builtin_nanq (""), __float128);
+ HAS_TYPE (__builtin_nansq (""), __float128);
+ HAS_TYPE (__builtin_fabsq (a), __float128);
+ HAS_TYPE (__builtin_copysignq (a, a), __float128);
+}