1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-18 00:07:21 +00:00
cc65/test/val/opsize.c

34 lines
1.5 KiB
C
Raw Normal View History

/* Test for result types of certain unary operations */
#include <stdio.h>
signed char x;
struct S {
unsigned char a : 3;
unsigned int b : 3;
} s;
int main(void)
{
_Static_assert(sizeof (++x) == sizeof (char), "++x result should not have promoted type");
_Static_assert(sizeof (--x) == sizeof (char), "--x result should not have promoted type");
_Static_assert(sizeof (x++) == sizeof (char), "x++ result should not have promoted type");
_Static_assert(sizeof (x--) == sizeof (char), "x-- result should not have promoted type");
_Static_assert(sizeof (x=0) == sizeof (char), "x=0 result should not have promoted type");
_Static_assert(sizeof (+x) == sizeof (int), "+x result should have promoted type");
_Static_assert(sizeof (-x) == sizeof (int), "-x result should have promoted type");
_Static_assert(sizeof (~x) == sizeof (int), "~x result should have promoted type");
_Static_assert(sizeof (+s.a) == sizeof (int), "+s.a result should have promoted type");
_Static_assert(sizeof (-s.a) == sizeof (int), "-s.a result should have promoted type");
_Static_assert(sizeof (~s.a) == sizeof (int), "~s.a result should have promoted type");
_Static_assert(sizeof (+s.b) == sizeof (int), "+s.b result should have promoted type");
_Static_assert(sizeof (-s.b) == sizeof (int), "-s.b result should have promoted type");
_Static_assert(sizeof (~s.b) == sizeof (int), "~s.b result should have promoted type");
return 0;
}