struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / assert.c
blobf18b8215bba0c1842f5d4f61a12bcd7b9e077d86
1 /* assert.c
2 */
4 #include <testfwk.h>
6 #define NDEBUG
8 #include <assert.h>
10 volatile int i = 42;
12 void testStaticAssert (void)
14 /* sdcc always supports C11 _Static_assert, even though the earliest standard requiring it is C11. */
15 #if defined (__SDCC) || __STDC_VERSION__ >= 201112L
16 _Static_assert (1, "First assertion");
17 _Static_assert (sizeof(int), "Second assertion");
18 #endif
21 #pragma std_c23
23 void testStaticAssert2X (void)
25 #if defined (__SDCC)
26 _Static_assert (1);
27 _Static_assert (sizeof(int));
28 #endif
31 int a[] = {1, 0};
33 void testAssert (void)
35 assert (i);
36 assert (i - 42);
37 #ifdef __SDCC // SDCC assert is always C23-compliant
38 assert (a[1, 0]); // C23 requires C23 to be implemented as variadic macro, which is meant for the use of compound literals in the argument. But the easiest way to test that is by using a comma operator not surrounded by ().
39 #endif