diff options
Diffstat (limited to 'tests/test-stdalign.c')
-rw-r--r-- | tests/test-stdalign.c | 37 |
1 files changed, 5 insertions, 32 deletions
diff --git a/tests/test-stdalign.c b/tests/test-stdalign.c index a18f8bc4..a9355545 100644 --- a/tests/test-stdalign.c +++ b/tests/test-stdalign.c @@ -3,7 +3,7 @@ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -18,13 +18,9 @@ #include <config.h> -#include <stdalign.h> - #include <stddef.h> #include <stdint.h> -#include "verify.h" - #include "macros.h" typedef long double longdouble; @@ -33,32 +29,21 @@ typedef struct { char a[2]; } struct2; typedef struct { char a[3]; } struct3; typedef struct { char a[4]; } struct4; -verify (__alignof_is_defined == 1); -#ifndef alignof -# error "alignof is not a macro" -#endif - -#if __alignas_is_defined -verify (__alignas_is_defined == 1); -# ifndef alignas -# error "alignas is not a macro" -# endif +#if (202311 <= __STDC_VERSION__ || __alignas_is_defined \ + || 201103 <= __cplusplus) /* mingw can go up only to 8. 8 is all that GNU Emacs needs, so let's limit the test to 8 for now. */ # define TEST_ALIGNMENT 8 #else -# define _Alignas(alignment) # define alignas(alignment) # define TEST_ALIGNMENT 1 #endif #define CHECK_STATIC(type) \ typedef struct { char slot1; type slot2; } type##_helper; \ - verify (alignof (type) == offsetof (type##_helper, slot2)); \ - verify (_Alignof (type) == alignof (type)); \ + static_assert (alignof (type) == offsetof (type##_helper, slot2)); \ const int type##_alignment = alignof (type); \ - type alignas (TEST_ALIGNMENT) static_##type##_alignas; \ - type _Alignas (TEST_ALIGNMENT) static_##type##_Alignas + type alignas (TEST_ALIGNMENT) static_##type##_alignas #define CHECK_ALIGNED(var) ASSERT ((uintptr_t) &(var) % TEST_ALIGNMENT == 0) @@ -96,31 +81,19 @@ main () return 77; #else CHECK_ALIGNED (static_char_alignas); - CHECK_ALIGNED (static_char_Alignas); CHECK_ALIGNED (static_short_alignas); - CHECK_ALIGNED (static_short_Alignas); CHECK_ALIGNED (static_int_alignas); - CHECK_ALIGNED (static_int_Alignas); CHECK_ALIGNED (static_long_alignas); - CHECK_ALIGNED (static_long_Alignas); # ifdef INT64_MAX CHECK_ALIGNED (static_int64_t_alignas); - CHECK_ALIGNED (static_int64_t_Alignas); # endif CHECK_ALIGNED (static_float_alignas); - CHECK_ALIGNED (static_float_Alignas); CHECK_ALIGNED (static_double_alignas); - CHECK_ALIGNED (static_double_Alignas); /* CHECK_ALIGNED (static_longdouble_alignas); */ - /* CHECK_ALIGNED (static_longdouble_Alignas); */ CHECK_ALIGNED (static_struct1_alignas); - CHECK_ALIGNED (static_struct1_Alignas); CHECK_ALIGNED (static_struct2_alignas); - CHECK_ALIGNED (static_struct2_Alignas); CHECK_ALIGNED (static_struct3_alignas); - CHECK_ALIGNED (static_struct3_Alignas); CHECK_ALIGNED (static_struct4_alignas); - CHECK_ALIGNED (static_struct4_Alignas); return 0; #endif } |