Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug-2687.c
blobf22e9f51c9f372e95d0f81bdb622c25fb52c36ab
1 /* bug-2687.c
2 the type of hexadecimal integer constants was in some cases decided by the rules for decimal ones.
3 */
5 #include <testfwk.h>
7 #include <limits.h>
9 enum type {TYPE_OTHER, TYPE_INT, TYPE_LONG, TYPE_LONGLONG, TYPE_UINT, TYPE_ULONG, TYPE_ULONGLONG};
11 #define TYPEOF(x) _Generic(x, default: TYPE_OTHER, int: TYPE_INT, long: TYPE_LONG, long long: TYPE_LONGLONG, unsigned int: TYPE_UINT, unsigned long: TYPE_ULONG, unsigned long long: TYPE_ULONGLONG)
13 void testBug(void)
15 ASSERT(0x7fffu == (unsigned int)(0x7fff));
16 ASSERT(TYPEOF(0x7fffu) == TYPE_UINT);
17 ASSERT(0xffffu == (unsigned int)(0xffff));
18 ASSERT(TYPEOF(0xffffu) == TYPE_UINT);
20 ASSERT(0x7fffffffu == (unsigned long)(0x7fffffff));
21 ASSERT(TYPEOF(0x7fffffffu) == TYPE_ULONG || TYPEOF(0x7fffffffu) == TYPE_UINT);
22 ASSERT(0xffffffffu == (unsigned long)(0xffffffff));
23 ASSERT(TYPEOF(0xffffffffu) == TYPE_ULONG || TYPEOF(0xffffffffu) == TYPE_UINT);
25 ASSERT(0x7fffffffffffffffu == (unsigned long long)(0x7fffffffffffffff));
26 ASSERT(TYPEOF(0x7fffffffffffffffu) == TYPE_ULONGLONG || TYPEOF(0x7fffffffffffffffu) == TYPE_ULONG || TYPEOF(0x7fffffffffffffffu) == TYPE_UINT);
27 ASSERT(0xffffffffffffffffu == (unsigned long long)(0xffffffffffffffff));
28 ASSERT(TYPEOF(0xffffffffffffffffu) == TYPE_ULONGLONG || TYPEOF(0xffffffffffffffffu) == TYPE_ULONG || TYPEOF(0xffffffffffffffffu) == TYPE_UINT);