Now these tests should succeed and be meaningful on all archs. --- validation/preprocessor/predef-char-bit.c | 16 ---------- validation/preprocessor/predef-llp64.c | 10 ++++++ validation/preprocessor/predef-lp32.c | 9 ++++++ validation/preprocessor/predef-lp64.c | 9 ++++++ validation/preprocessor/predef-max.c | 18 ----------- validation/preprocessor/predef-sizeof.c | 25 --------------- validation/preprocessor/predef.c | 38 +++++++++++++++++++++++ 7 files changed, 66 insertions(+), 59 deletions(-) delete mode 100644 validation/preprocessor/predef-char-bit.c create mode 100644 validation/preprocessor/predef-llp64.c create mode 100644 validation/preprocessor/predef-lp32.c create mode 100644 validation/preprocessor/predef-lp64.c delete mode 100644 validation/preprocessor/predef-max.c delete mode 100644 validation/preprocessor/predef-sizeof.c create mode 100644 validation/preprocessor/predef.c diff --git a/validation/preprocessor/predef-char-bit.c b/validation/preprocessor/predef-char-bit.c deleted file mode 100644 index fed0166e4..000000000 --- a/validation/preprocessor/predef-char-bit.c +++ /dev/null @@ -1,16 +0,0 @@ -#define TEST_BIT(X, T) if (__ ## X ## _BIT__ != 8 * sizeof(T)) return 1 - -int test(void) -{ - TEST_BIT(CHAR, char); - - return 0; -} - -/* - * check-name: predefined __<type>_BIT__ - * check-command: test-linearize -Wno-decl $file - * check-output-ignore - * - * check-output-contains: ret\\..*\\$0 - */ diff --git a/validation/preprocessor/predef-llp64.c b/validation/preprocessor/predef-llp64.c new file mode 100644 index 000000000..a34b51b3a --- /dev/null +++ b/validation/preprocessor/predef-llp64.c @@ -0,0 +1,10 @@ +#include "predef.c" + +/* + * check-name: predefined macros for LLP64 + * check-command: test-linearize -Wno-decl -msize-llp64 $file + * check-known-to-fail + * check-output-ignore + * + * check-output-contains: ret\\..*\\$0 + */ diff --git a/validation/preprocessor/predef-lp32.c b/validation/preprocessor/predef-lp32.c new file mode 100644 index 000000000..8fa2846c2 --- /dev/null +++ b/validation/preprocessor/predef-lp32.c @@ -0,0 +1,9 @@ +#include "predef.c" + +/* + * check-name: predefined macros for LP32 + * check-command: test-linearize -Wno-decl -m32 $file + * check-output-ignore + * + * check-output-contains: ret\\..*\\$0 + */ diff --git a/validation/preprocessor/predef-lp64.c b/validation/preprocessor/predef-lp64.c new file mode 100644 index 000000000..0173ca40d --- /dev/null +++ b/validation/preprocessor/predef-lp64.c @@ -0,0 +1,9 @@ +#include "predef.c" + +/* + * check-name: predefined macros for LP64 + * check-command: test-linearize -Wno-decl -m64 $file + * check-output-ignore + * + * check-output-contains: ret\\..*\\$0 + */ diff --git a/validation/preprocessor/predef-max.c b/validation/preprocessor/predef-max.c deleted file mode 100644 index ad4b7eaf1..000000000 --- a/validation/preprocessor/predef-max.c +++ /dev/null @@ -1,18 +0,0 @@ -#define TEST_MAX(X, Z) if (X != ((~ Z) >> 1)) return 1 - -int test_max(void) -{ - TEST_MAX(__INT_MAX__, 0U); - TEST_MAX(__LONG_MAX__, 0UL); - TEST_MAX(__LONG_LONG_MAX__, 0ULL); - - return 0; -} - -/* - * check-name: predefined __<type>_MAX__ - * check-command: test-linearize -Wno-decl $file - * check-output-ignore - * - * check-output-contains: ret\\..*\\$0 - */ diff --git a/validation/preprocessor/predef-sizeof.c b/validation/preprocessor/predef-sizeof.c deleted file mode 100644 index 12be2dd1d..000000000 --- a/validation/preprocessor/predef-sizeof.c +++ /dev/null @@ -1,25 +0,0 @@ -#define TEST(X, T) if (__SIZEOF_ ## X ## __ != sizeof(T)) return 1 - -int test_sizeof(void) -{ - TEST(SHORT, short); - TEST(INT, int); - TEST(LONG, long); - TEST(LONG_LONG, long long); - TEST(INT128, __int128); - TEST(SIZE_T, __SIZE_TYPE__); - TEST(POINTER, void*); - TEST(FLOAT, float); - TEST(DOUBLE, double); - TEST(LONG_DOUBLE, long double); - - return 0; -} - -/* - * check-name: predefined __SIZEOF_<type>__ - * check-command: test-linearize -Wno-decl $file - * check-output-ignore - * - * check-output-contains: ret\\..*\\$0 - */ diff --git a/validation/preprocessor/predef.c b/validation/preprocessor/predef.c new file mode 100644 index 000000000..0453ce43f --- /dev/null +++ b/validation/preprocessor/predef.c @@ -0,0 +1,38 @@ +#define BITS(T) (sizeof(T) * 8) +#define SIGN_BIT(T) (1ULL << (BITS(T) - 1)) + +int test(void); +int test(void) +{ +#define TEST_BIT(X, T) if (__ ## X ## _BIT__ != BITS(T)) return 1 + TEST_BIT(CHAR, char); + +#define TEST_MAX(X, T) if (__ ## X ## _MAX__ != (SIGN_BIT(T) - 1)) return 1 + TEST_MAX(SCHAR, signed char); + TEST_MAX(SHRT, short); + TEST_MAX(INT, int); + TEST_MAX(LONG, long); + TEST_MAX(LONG_LONG, long long); + +#define TEST_SIZEOF(X, T) if (__SIZEOF_ ## X ## __ != sizeof(T)) return 1 + TEST_SIZEOF(SHORT, short); + TEST_SIZEOF(INT, int); + TEST_SIZEOF(LONG, long); + TEST_SIZEOF(LONG_LONG, long long); + TEST_SIZEOF(INT128, __int128); + TEST_SIZEOF(SIZE_T, __SIZE_TYPE__); + TEST_SIZEOF(POINTER, void*); + TEST_SIZEOF(FLOAT, float); + TEST_SIZEOF(DOUBLE, double); + TEST_SIZEOF(LONG_DOUBLE, long double); + + return 0; +} + +/* + * check-name: predefined macros: __SIZEOF_<type>__, ... + * check-command: test-linearize -Wno-decl $file + * check-output-ignore + * + * check-output-contains: ret\\..*\\$0 + */ -- 2.19.0