summaryrefslogtreecommitdiff
path: root/tests/test-intprops.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-08-09 23:20:49 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2022-08-10 00:22:09 -0700
commit2eb92c362ecfb2dae9c9cb37cb9246df6989181c (patch)
tree298053737c12bfc1144936111b7763b53ae51be7 /tests/test-intprops.c
parent9331caeffae1b7b5f49b65c98c2ff9cc8f3691fd (diff)
downloadgnulib-2eb92c362ecfb2dae9c9cb37cb9246df6989181c.tar.gz
stdckdint-h: new module
This supports draft C23 <stdckdint.h>. * doc/posix-headers/stdckdint.texi: * lib/stdckdint.in.h, modules/stdckdint: * modules/stdckdint-tests, tests/test-stdckdint.c: New files. * MODULES.html.sh, doc/gnulib.texi: Update for new module. * lib/intprops-internal.h: Include <stdckdint.h> if C23 and its macros would help and our substitute has not already started to be included. (_GL_INT_ADD_WRAPV, _GL_INT_SUBTRACT_WRAPV) (_GL_INT_MULTIPLY_WRAPV): Use ckd_add, ckd_sub, ckd_mul if they are defined and would help. * lib/intprops-internal.h, lib/intprops.h: Improve comments. The C23 restrictions on stdckdint macros already mostly applied to intprops.h, so these are clarifications, not further restrictions. * tests/test-intprops.c: If TEST_STDCKDINT is defined, include <stdckdint.h> instead of "intprops.h", and test it instead. (VERIFY) [TEST_STDCKDINT]: Ignore the arg in this case. (main) [TEST_STDCKDINT]: Skip tests irrelevant to stdckdint.h.
Diffstat (limited to 'tests/test-intprops.c')
-rw-r--r--tests/test-intprops.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/test-intprops.c b/tests/test-intprops.c
index 277746a001..a46e9c5e4a 100644
--- a/tests/test-intprops.c
+++ b/tests/test-intprops.c
@@ -30,7 +30,11 @@
#include <config.h>
-#include "intprops.h"
+#ifdef TEST_STDCKDINT
+# include <stdckdint.h>
+#else
+# include "intprops.h"
+#endif
#include "verify.h"
#include <stdbool.h>
@@ -45,10 +49,13 @@
/* VERIFY (X) uses a static assertion for compilers that are known to work,
and falls back on a dynamic assertion for other compilers.
+ But it ignores X if testing stdckdint.h.
These tests should be checkable via 'verify' rather than 'ASSERT', but
using 'verify' would run into a bug with HP-UX 11.23 cc; see
<https://lists.gnu.org/r/bug-gnulib/2011-05/msg00401.html>. */
-#if __GNUC__ || __clang__ || __SUNPRO_C
+#ifdef TEST_STDCKDINT
+# define VERIFY(x) ((void) 0)
+#elif __GNUC__ || __clang__ || __SUNPRO_C
# define VERIFY(x) verify_stmt (x)
#else
# define VERIFY(x) ASSERT (x)
@@ -65,6 +72,7 @@ main (void)
/* Use VERIFY for tests that must be integer constant expressions,
ASSERT otherwise. */
+#ifndef TEST_STDCKDINT
/* TYPE_IS_INTEGER. */
ASSERT (TYPE_IS_INTEGER (bool));
ASSERT (TYPE_IS_INTEGER (char));
@@ -161,6 +169,7 @@ main (void)
VERIFY (INT_STRLEN_BOUND (int64_t) == sizeof ("-9223372036854775808") - 1);
VERIFY (INT_BUFSIZE_BOUND (int64_t) == sizeof ("-9223372036854775808"));
#endif
+#endif
/* All the INT_<op>_RANGE_OVERFLOW tests are equally valid as
INT_<op>_OVERFLOW tests, so define macros to do both. OP is the