mirror of
https://github.com/cc65/cc65.git
synced 2024-09-26 12:55:17 +00:00
Added test cases for result types of certain operations.
This commit is contained in:
parent
25a35d6b59
commit
31128d4809
33
test/val/opsize.c
Normal file
33
test/val/opsize.c
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
/* 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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user