diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-12-09 15:53:55 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-12-14 00:40:52 +0100 |
commit | b6f0362baae2c8fdd5ef42eaae3bb05f8bcd8fea (patch) | |
tree | a243e01aac15e40ce945bcfdb02c4a166c4e1d9b | |
parent | 21308e0ad0ded24f4c0bb5e6b4becfb4fc84a918 (diff) | |
download | sparse-b6f0362baae2c8fdd5ef42eaae3bb05f8bcd8fea.tar.gz |
testsuite: test predef macros on LP32/LP64/LLP64
Now these tests should succeed and be meaningful on
all archs.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | validation/preprocessor/predef-char-bit.c | 16 | ||||
-rw-r--r-- | validation/preprocessor/predef-llp64.c | 10 | ||||
-rw-r--r-- | validation/preprocessor/predef-lp32.c | 9 | ||||
-rw-r--r-- | validation/preprocessor/predef-lp64.c | 9 | ||||
-rw-r--r-- | validation/preprocessor/predef-max.c | 18 | ||||
-rw-r--r-- | validation/preprocessor/predef-sizeof.c | 25 | ||||
-rw-r--r-- | validation/preprocessor/predef.c | 42 |
7 files changed, 70 insertions, 59 deletions
diff --git a/validation/preprocessor/predef-char-bit.c b/validation/preprocessor/predef-char-bit.c deleted file mode 100644 index fed0166e..00000000 --- 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 00000000..a34b51b3 --- /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 00000000..8fa2846c --- /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 00000000..0173ca40 --- /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 ad4b7eaf..00000000 --- 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 12be2dd1..00000000 --- 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 00000000..ccb5d361 --- /dev/null +++ b/validation/preprocessor/predef.c @@ -0,0 +1,42 @@ +#define BITS(T) (sizeof(T) * 8) +#define SIGN_BIT(T) (1ULL << (BITS(T) - 1)) +#define SMASK(T) (SIGN_BIT(T) - 1) +#define UMASK(T) (SIGN_BIT(T) | SMASK(T)) + +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, M) if (__ ## X ## _MAX__ != M) return 1 +#define TEST_SMAX(X, T) TEST_MAX(X, SMASK(T)) +#define TEST_UMAX(X, T) TEST_MAX(X, UMASK(T)) + TEST_SMAX(SCHAR, signed char); + TEST_SMAX(SHRT, short); + TEST_SMAX(INT, int); + TEST_SMAX(LONG, long); + TEST_SMAX(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 + */ |