struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3260.c
blob5e5b9f6f35544b320c6e97259fb8fca84310b5ea
1 #include <testfwk.h>
3 /* Bug #3260 caused typecast function pointers to pass all */
4 /* parameters via the stack and not pass any parameter via */
5 /* register, even when some should have been passed via */
6 /* register. */
8 /* Look for __SDCC_STACK_AUTO to make sure the port is */
9 /* parameters in registers and/or stack and not statically */
10 #if defined(__SDCC_STACK_AUTO) || defined(PORT_HOST)
11 int (*p)(int, int) __reentrant;
13 void (*q)(void) __reentrant;
15 int f(void)
17 return (*p)(23, 42);
20 int g(void)
22 return (*(((int (*)(int, int))q)))(23, 42);
25 int c(int a, int b) __reentrant
27 return a - b;
29 #endif
31 void
32 testBug(void)
34 #if defined(__SDCC_STACK_AUTO) || defined(PORT_HOST)
35 p = &c;
36 q = (void (*)(void))(&c);
37 ASSERT (f() == 23 - 42);
38 ASSERT (g() == 23 - 42);
39 #endif