struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-2663.c
blob5e3932dba6bee7fd795c02fd77291cc4c5680bff
1 /*
2 bug-2548.c
3 */
5 #include <testfwk.h>
7 static int cmp_eq (long arg1, long arg2)
9 return arg1 != arg2;
11 struct op {
12 const char *op_name;
13 void (*op_func)(void);
16 /* In initializations, SDCC did not allow some function pointer casts allowed by the standard. */
17 #ifdef __SDCC
18 const struct op string_binop1[] = {
19 {"=", (void (*)(void*))cmp_eq},
22 const struct op string_binop2[] = {
23 {"=", (void (*)(void*))&cmp_eq},
25 #endif
27 void testBug(void)
29 #ifdef _SDCC
30 #if !defined(__SDCC_mcs51) && !defined(__SDCC_ds390) && !defined(__SDCC_hc08) && !defined(__SDCC_s08) && !defined(__SDCC_mos6502) && !defined(__SDCC_mos65c02) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) /* mcs51, hc08, s08 and pdk14 have restrictions on function pointers wrt. reentrancy */
31 ASSERT(((int (*)(long, long))(string_binop1[0].op_func))(1, 1) == 0);
32 ASSERT(((int (*)(long, long))(string_binop1[0].op_func))(1, 2) == 1);
33 ASSERT(((int (*)(long, long))(string_binop2[0].op_func))(1, 1) == 0);
34 ASSERT(((int (*)(long, long))(string_binop2[0].op_func))(1, 2) == 1);
35 #endif
36 #endif