summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-2663.c
blob: c7aaa921f61848a2cb06a6195afc759d00365ee2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
  bug-2548.c
*/

#include <testfwk.h>

static int cmp_eq (long arg1, long arg2)
{
    return arg1 != arg2;
}
struct op {
    const char *op_name;
    void (*op_func)(void);
};

/* In initializations, SDCC did not allow some function pointer casts allowed by the standard. */

const struct op string_binop1[] = {
    {"=", (void (*)(void*))cmp_eq},
};

const struct op string_binop2[] = {
    {"=", (void (*)(void*))&cmp_eq},
};

void testBug(void)
{
#if !defined(__SDCC_mcs51) && !defined(__SDCC_ds390) && !defined(__SDCC_hc08) && !defined(__SDCC_s08) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) /* mcs51, hc08, s08 and pdk14 have restrictions on function pointers wrt. reentrancy */
	ASSERT(((int (*)(long, long))(string_binop1[0].op_func))(1, 1) == 0);
	ASSERT(((int (*)(long, long))(string_binop1[0].op_func))(1, 2) == 1);
	ASSERT(((int (*)(long, long))(string_binop2[0].op_func))(1, 1) == 0);
	ASSERT(((int (*)(long, long))(string_binop2[0].op_func))(1, 2) == 1);
#endif
}