* lib/intprops.h (INT_PROMOTE): Refine comment.
* tests/test-intprops.c: Check the size and sign of INT_PROMOTE (x) on
all compilers.
(main): Check that INT_PROMOTE is a no-op on floats.
+2025-02-09 Bruno Haible <bruno@clisp.org>
+
+ intprops tests: Strengthen INT_PROMOTE tests.
+ * lib/intprops.h (INT_PROMOTE): Refine comment.
+ * tests/test-intprops.c: Check the size and sign of INT_PROMOTE (x) on
+ all compilers.
+ (main): Check that INT_PROMOTE is a no-op on floats.
+
2025-02-08 Collin Funk <collin.funk1@gmail.com>
doc: Document free_aligned_sized and free_sized added in C23.
then 'switch (INT_PROMOTE (E))' pacifies gcc -Wswitch-enum if some
enum values are deliberately omitted from the switch's cases.
Here, unary + is safer than a cast or inline function, as unary +
- does only integer promotions. */
+ does only integer promotions and is disallowed on pointers. */
#define INT_PROMOTE(e) (+ (e))
|| 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];
int int_minus_2 = -2;
int int_1 = 1;
/* 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));