diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-03-27 14:35:46 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-03-27 16:12:27 +0200 |
| commit | c1a53a868ebafd1d134e4a77c86074b9d07e4281 (patch) | |
| tree | c906be28b94be226f32528d6b2a8263bc75bd208 /validation | |
| parent | 369cbea4b37692bfd93ca23c1991d002354d2219 (diff) | |
| download | sparse-dev-c1a53a868ebafd1d134e4a77c86074b9d07e4281.tar.gz | |
do not depends on limits.h to test __CHAR_BIT__
This test depends on the header <limits.h> which itself depends
on some macros being defined by the compiler.
Now these macros are predefined (at least the obvious ones)
but it's annoying for the tests to depends on external things
like this header.
Remove this dependence by rewriting the test to use the predefined
macros directly.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/builtin_char_bit.c | 7 | ||||
| -rw-r--r-- | validation/preprocessor/predef-char-bit.c | 16 |
2 files changed, 16 insertions, 7 deletions
diff --git a/validation/builtin_char_bit.c b/validation/builtin_char_bit.c deleted file mode 100644 index 30e6bed4..00000000 --- a/validation/builtin_char_bit.c +++ /dev/null @@ -1,7 +0,0 @@ -#include <limits.h> - -static unsigned int word_bits = sizeof(unsigned int) * CHAR_BIT; - -/* - * check-name: __CHAR_BIT__ - */ diff --git a/validation/preprocessor/predef-char-bit.c b/validation/preprocessor/predef-char-bit.c new file mode 100644 index 00000000..fed0166e --- /dev/null +++ b/validation/preprocessor/predef-char-bit.c @@ -0,0 +1,16 @@ +#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 + */ |
