From 72d8e4439c7ec2193fc1713192da13afbfd1ebdd Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 9 Feb 2025 08:04:30 +0100 Subject: [PATCH] stdckdint-h tests: Fix compilation error (regression 2025-02-07). * tests/test-intprops.c: Exclude INT_PROMOTE checks if TEST_STDCKDINT is defined. --- ChangeLog | 6 ++++++ tests/test-intprops.c | 16 +++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 710db41aa8..73350f9f99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2025-02-09 Bruno Haible + + stdckdint-h tests: Fix compilation error (regression 2025-02-07). + * tests/test-intprops.c: Exclude INT_PROMOTE checks if TEST_STDCKDINT is + defined. + 2025-02-09 Bruno Haible intprops tests: Strengthen INT_PROMOTE tests. diff --git a/tests/test-intprops.c b/tests/test-intprops.c index 6c06e47ab3..d16b67b5ce 100644 --- a/tests/test-intprops.c +++ b/tests/test-intprops.c @@ -62,18 +62,20 @@ #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__)) +# 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 +# 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; @@ -84,9 +86,6 @@ main (void) /* Use VERIFY for tests that must be integer constant expressions, ASSERT otherwise. */ - /* Check that INT_PROMOTE is a no-op on floats. */ - ASSERT (INT_PROMOTE (2.71828) > 2); - #ifndef TEST_STDCKDINT /* TYPE_IS_INTEGER. */ ASSERT (TYPE_IS_INTEGER (bool)); @@ -121,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); -- 2.39.5