+2023-03-25 Bruno Haible <bruno@clisp.org>
+
+ Make some header file tests a bit stronger.
+ * tests/test-float.c: Include fpucw.h and macros.h only after checking
+ the macros.
+ * tests/test-glob-h.c: Include macros.h only after checking the types
+ and macros.
+ * tests/test-inttypes.c: Don't include <stddef.h>.
+ * tests/test-math.c: Include <limits.h> and macros.h only after checking
+ the types and macros.
+ * tests/test-stddef.c: Include <limits.h> only after checking the types
+ and macros.
+ * tests/test-sys_select.c: Include signature.h only after checking the
+ types.
+ * tests/test-sys_socket.c: Include <errno.h> only after checking the
+ types and macros.
+ * tests/test-wctype-h.c: Include macros.h only after checking the types.
+
2023-03-25 Bruno Haible <bruno@clisp.org>
is* tests: Ensure needed .m4 files are packaged.
#include <float.h>
-#include "fpucw.h"
-#include "macros.h"
-
/* Check that FLT_RADIX is a constant expression. */
int a[] = { FLT_RADIX };
+/* ----------------------- Check macros for 'float' ----------------------- */
+
+/* Check that the FLT_* macros expand to constant expressions. */
+int fb[] =
+ {
+ FLT_MANT_DIG, FLT_MIN_EXP, FLT_MAX_EXP,
+ FLT_DIG, FLT_MIN_10_EXP, FLT_MAX_10_EXP
+ };
+float fc[] = { FLT_EPSILON, FLT_MIN, FLT_MAX };
+
+/* ----------------------- Check macros for 'double' ----------------------- */
+
+/* Check that the DBL_* macros expand to constant expressions. */
+int db[] =
+ {
+ DBL_MANT_DIG, DBL_MIN_EXP, DBL_MAX_EXP,
+ DBL_DIG, DBL_MIN_10_EXP, DBL_MAX_10_EXP
+ };
+double dc[] = { DBL_EPSILON, DBL_MIN, DBL_MAX };
+
+/* -------------------- Check macros for 'long double' -------------------- */
+
+/* Check that the LDBL_* macros expand to constant expressions. */
+int lb[] =
+ {
+ LDBL_MANT_DIG, LDBL_MIN_EXP, LDBL_MAX_EXP,
+ LDBL_DIG, LDBL_MIN_10_EXP, LDBL_MAX_10_EXP
+ };
+long double lc1 = LDBL_EPSILON;
+long double lc2 = LDBL_MIN;
+#if 0 /* LDBL_MAX is not a constant expression on some platforms. */
+long double lc3 = LDBL_MAX;
+#endif
+
+/* ------------------------------------------------------------------------- */
+
+#include "fpucw.h"
+#include "macros.h"
+
#if FLT_RADIX == 2
/* Return 2^n. */
/* ----------------------- Check macros for 'float' ----------------------- */
-/* Check that the FLT_* macros expand to constant expressions. */
-int fb[] =
- {
- FLT_MANT_DIG, FLT_MIN_EXP, FLT_MAX_EXP,
- FLT_DIG, FLT_MIN_10_EXP, FLT_MAX_10_EXP
- };
-float fc[] = { FLT_EPSILON, FLT_MIN, FLT_MAX };
-
static void
test_float (void)
{
/* ----------------------- Check macros for 'double' ----------------------- */
-/* Check that the DBL_* macros expand to constant expressions. */
-int db[] =
- {
- DBL_MANT_DIG, DBL_MIN_EXP, DBL_MAX_EXP,
- DBL_DIG, DBL_MIN_10_EXP, DBL_MAX_10_EXP
- };
-double dc[] = { DBL_EPSILON, DBL_MIN, DBL_MAX };
-
static void
test_double (void)
{
/* -------------------- Check macros for 'long double' -------------------- */
-/* Check that the LDBL_* macros expand to constant expressions. */
-int lb[] =
- {
- LDBL_MANT_DIG, LDBL_MIN_EXP, LDBL_MAX_EXP,
- LDBL_DIG, LDBL_MIN_10_EXP, LDBL_MAX_10_EXP
- };
-long double lc1 = LDBL_EPSILON;
-long double lc2 = LDBL_MIN;
-#if 0 /* LDBL_MAX is not a constant expression on some platforms. */
-long double lc3 = LDBL_MAX;
-#endif
-
static void
test_long_double (void)
{
#include <config.h>
#include <stddef.h>
-#include <limits.h>
/* Check that appropriate types are defined. */
wchar_t a = 'c';
static_assert (sizeof (offsetof (struct d, e)) == sizeof (size_t));
static_assert (offsetof (struct d, f) == 1);
-/* offsetof promotes to an unsigned integer if and only if sizes do
- not fit in int. */
-static_assert ((offsetof (struct d, e) < -1) == (INT_MAX < (size_t) -1));
-
/* Check max_align_t's alignment. */
static_assert (alignof (double) <= alignof (max_align_t));
static_assert (alignof (int) <= alignof (max_align_t));
unreachable ();
}
+#include <limits.h> /* INT_MAX */
+
+/* offsetof promotes to an unsigned integer if and only if sizes do
+ not fit in int. */
+static_assert ((offsetof (struct d, e) < -1) == (INT_MAX < (size_t) -1));
+
int
main (void)
{
#include <sys/select.h>
+/* Check that the 'struct timeval' type is defined. */
+struct timeval a;
+
+/* Check that a.tv_sec is wide enough to hold a time_t, ignoring
+ signedness issues. */
+typedef int verify_tv_sec_type[sizeof (time_t) <= sizeof (a.tv_sec) ? 1 : -1];
+
+/* Check that sigset_t is defined. */
+sigset_t t2;
+
#include "signature.h"
/* The following may be macros without underlying functions, so only
SIGNATURE_CHECK (FD_ZERO, void, (fd_set *));
#endif
-/* Check that the 'struct timeval' type is defined. */
-struct timeval a;
-
-/* Check that a.tv_sec is wide enough to hold a time_t, ignoring
- signedness issues. */
-typedef int verify_tv_sec_type[sizeof (time_t) <= sizeof (a.tv_sec) ? 1 : -1];
-
-/* Check that sigset_t is defined. */
-sigset_t t2;
-
int
main (void)
{