X-Git-Url: https://pd.if.org/git/?p=lice;a=blobdiff_plain;f=tests%2Falignof.c;fp=tests%2Falignof.c;h=f3a58a9f47ecd89fb076e99d1fd2823e00537b9d;hp=0000000000000000000000000000000000000000;hb=bb650f4a52a456c1aa0a34508d6f3dcce58291b6;hpb=686688990cde8ecd8d9423fde7f88b6ac6ac8a40 diff --git a/tests/alignof.c b/tests/alignof.c new file mode 100644 index 0000000..f3a58a9 --- /dev/null +++ b/tests/alignof.c @@ -0,0 +1,43 @@ +// alignof + +#include + +int main(void) { + expecti(__alignof_is_defined, 1); + + expecti(alignof(char), 1); + expecti(alignof(int), 4); + expecti(alignof(long), 8); + + struct test { + char a; + int b; + }; + + expecti(alignof(struct test), 8); + + expecti(_Alignof(char), 1); + expecti(__alignof__(char), 1); + expecti(_Alignof(struct test), 8); + expecti(__alignof__(struct test), 8); + + struct complex { + struct { + char a; + short b; + int c; + } d; + char e; + union { + int f; + struct { + int g; + int h; + } i; + } j; + }; + + expecti(alignof(struct complex), 16); + + return 0; +}