summaryrefslogtreecommitdiff
path: root/tests/test-intprops.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2025-10-18 19:06:52 +0200
committerJörg Frings-Fürst <debian@jff.email>2025-10-18 19:06:52 +0200
commit27dae84ed92f1ef0300263091972338d12e78348 (patch)
tree7c52931f474fafb8a4bd4fd15ca3461c77cdecc2 /tests/test-intprops.c
parent4682deeb62247d34de87f8e777f99e2d337fd377 (diff)
New upstream version 1.4.1upstream/1.4.1upstream
Diffstat (limited to 'tests/test-intprops.c')
-rw-r--r--tests/test-intprops.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/test-intprops.c b/tests/test-intprops.c
index 3bffc3f5..cce1386e 100644
--- a/tests/test-intprops.c
+++ b/tests/test-intprops.c
@@ -1,5 +1,5 @@
/* Test intprops.h.
- Copyright (C) 2011-2024 Free Software Foundation, Inc.
+ Copyright (C) 2011-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
# pragma GCC diagnostic ignored "-Wtype-limits"
/* Work around a bug in GCC 6.1 and earlier; see:
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68971 */
+ https://gcc.gnu.org/PR68971 */
# pragma GCC diagnostic ignored "-Woverflow"
#endif
@@ -62,6 +62,21 @@
#define DONTCARE __LINE__
+#ifndef TEST_STDCKDINT
+/* Check that INT_PROMOTE promotes to int.
+ GCC < 4.9 lacks _Generic even though it may claim C11 conformance. */
+# if (201112 <= __STDC_VERSION__ \
+ && (!defined __GNUC__ || 4 < __GNUC__ + (9 <= __GNUC_MINOR__) \
+ || defined __clang__))
+int check_INT_PROMOTE = _Generic (INT_PROMOTE ((short int) 0), int: 0);
+# endif
+/* For other compilers, check the size and sign of INT_PROMOTE (x). */
+int check_INT_PROMOTE_size
+ [2 * (sizeof (INT_PROMOTE ((short int) 0)) == sizeof (int)) - 1];
+int check_INT_PROMOTE_sign
+ [2 * (INT_PROMOTE ((short int) -1) < 0) - 1];
+#endif
+
int int_minus_2 = -2;
int int_1 = 1;
@@ -105,6 +120,9 @@ main (void)
ASSERT (TYPE_SIGNED (double));
ASSERT (TYPE_SIGNED (long double));
+ /* Check that INT_PROMOTE is a no-op on floats. */
+ ASSERT (INT_PROMOTE (2.71828) > 2);
+
/* Integer representation. Check that it is two's complement. */
VERIFY (INT_MIN + INT_MAX < 0);