Mercurial > gnulib
changeset 39819:535331977e47
intprops tests: Fix compilation error with pre-C99 compiler.
* tests/test-intprops.c (verify_stmt): New macro.
(VERIFY, main): Use it.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Thu, 06 Sep 2018 14:35:29 +0200 |
parents | 6e823034f518 |
children | 1f42ad97158b |
files | ChangeLog tests/test-intprops.c |
diffstat | 2 files changed, 26 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Sep 06 14:28:38 2018 +0200 +++ b/ChangeLog Thu Sep 06 14:35:29 2018 +0200 @@ -1,3 +1,9 @@ +2018-09-06 Bruno Haible <bruno@clisp.org> + + intprops tests: Fix compilation error with pre-C99 compiler. + * tests/test-intprops.c (verify_stmt): New macro. + (VERIFY, main): Use it. + 2018-09-06 Bruno Haible <bruno@clisp.org> limits-h: Provide numerical limits macros.
--- a/tests/test-intprops.c Thu Sep 06 14:28:38 2018 +0200 +++ b/tests/test-intprops.c Thu Sep 06 14:35:29 2018 +0200 @@ -39,13 +39,17 @@ #include "macros.h" +/* Compile-time verification of expression X. + In this file, we need it as a statement, rather than as a declaration. */ +#define verify_stmt(x) do { verify (x); } while (0) + /* VERIFY (X) uses a static assertion for compilers that are known to work, and falls back on a dynamic assertion for other compilers. 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__ || __SUNPRO_C -# define VERIFY(x) do { verify (x); } while (0) +# define VERIFY(x) verify_stmt (x) #else # define VERIFY(x) ASSERT (x) #endif @@ -114,8 +118,10 @@ VERIFY (TYPE_MINIMUM (unsigned long int) == 0); VERIFY (TYPE_MAXIMUM (unsigned long int) == ULONG_MAX); #ifdef LLONG_MAX - verify (TYPE_MINIMUM (long long int) == LLONG_MIN); - verify (TYPE_MAXIMUM (long long int) == LLONG_MAX); + verify_stmt (TYPE_MINIMUM (long long int) == LLONG_MIN); + verify_stmt (TYPE_MAXIMUM (long long int) == LLONG_MAX); + verify_stmt (TYPE_MINIMUM (unsigned long long int) == 0); + verify_stmt (TYPE_MAXIMUM (unsigned long long int) == ULLONG_MAX); #endif VERIFY (TYPE_MINIMUM (intmax_t) == INTMAX_MIN); VERIFY (TYPE_MAXIMUM (intmax_t) == INTMAX_MAX); @@ -124,18 +130,18 @@ /* TYPE_WIDTH. */ #ifdef CHAR_WIDTH - verify (TYPE_WIDTH (char) == CHAR_WIDTH); - verify (TYPE_WIDTH (signed char) == SCHAR_WIDTH); - verify (TYPE_WIDTH (unsigned char) == UCHAR_WIDTH); - verify (TYPE_WIDTH (short int) == SHRT_WIDTH); - verify (TYPE_WIDTH (unsigned short int) == USHRT_WIDTH); - verify (TYPE_WIDTH (int) == INT_WIDTH); - verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH); - verify (TYPE_WIDTH (long int) == LONG_WIDTH); - verify (TYPE_WIDTH (unsigned long int) == ULONG_WIDTH); + verify_stmt (TYPE_WIDTH (char) == CHAR_WIDTH); + verify_stmt (TYPE_WIDTH (signed char) == SCHAR_WIDTH); + verify_stmt (TYPE_WIDTH (unsigned char) == UCHAR_WIDTH); + verify_stmt (TYPE_WIDTH (short int) == SHRT_WIDTH); + verify_stmt (TYPE_WIDTH (unsigned short int) == USHRT_WIDTH); + verify_stmt (TYPE_WIDTH (int) == INT_WIDTH); + verify_stmt (TYPE_WIDTH (unsigned int) == UINT_WIDTH); + verify_stmt (TYPE_WIDTH (long int) == LONG_WIDTH); + verify_stmt (TYPE_WIDTH (unsigned long int) == ULONG_WIDTH); #ifdef LLONG_WIDTH - verify (TYPE_WIDTH (long long int) == LLONG_WIDTH); - verify (TYPE_WIDTH (unsigned long long int) == ULLONG_WIDTH); + verify_stmt (TYPE_WIDTH (long long int) == LLONG_WIDTH); + verify_stmt (TYPE_WIDTH (unsigned long long int) == ULLONG_WIDTH); #endif #endif