struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-2349.c
blobf4907b6325ee6f75854cff11d28b4f9ad88ab658
1 /*
2 bug-2349.c
3 */
5 #include <testfwk.h>
7 #pragma disable_warning 85
9 long subchar(void *pa, void *pb)
11 return *((char *) pa) - *((char *) pb);
14 long subint(void *pa, void *pb)
16 return *((int *) pa) - *((int *) pb);
19 long sublong(void *pa, void *pb)
21 return *((long *) pa) - *((long *) pb);
24 long addlong(void *pa, void *pb)
26 return *((long *) pa) + *((long *) pb);
29 #define NULL ((void *) 0)
31 #if defined (__SDCC_MODEL_MEDIUM)
32 typedef long (*subfunc_t)(void *pa, void * __pdata pb);
33 #elif defined (__SDCC_MODEL_LARGE)
34 typedef long (*subfunc_t)(void *pa, void * __xdata pb);
35 #elif defined (__SDCC_MODEL_HUGE)
36 typedef long (*subfunc_t)(void *pa, void * __xdata pb);
37 #else
38 typedef long (*subfunc_t)(void *pa, void *pb);
39 #endif
41 subfunc_t dosub(subfunc_t f)
43 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15)
44 if (f == subchar)
45 return subint;
46 else if (f == subint)
47 return sublong;
48 else if (f == sublong)
49 return subchar;
50 else if (f == NULL)
51 return addlong;
52 else
53 return NULL;
54 #endif
57 void testBug(void)
59 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15)
60 ASSERT (dosub(subchar) == subint);
61 ASSERT (dosub(subint) == sublong);
62 ASSERT (dosub(sublong) == subchar);
63 ASSERT (dosub(addlong) == NULL);
64 ASSERT (dosub(NULL) == addlong);
65 #endif