summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-3675.c
blob: 8cc14c482a18d88333d0b049cd51ded842ebeac0 (plain)
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
/* bug-3642.c
   A bug in handling of parameters to nested function calls (outer one explicit, inner one via helper function)
   that resulted in a register parameter being sent to the wrong function.
*/

#include <testfwk.h>

struct s
{
	unsigned int i;
};

// Need a function where the first paremeter is an integer parameter small enough to be passed in registers, followed by a struct parameter.
void f(unsigned int i, struct s s)
{
	ASSERT (i == 0x5a5a);
	ASSERT (s.i == 0xa5a5);
}

void
testBug (void)
{
#ifndef __SDCC_ds390 // Fails to link
	struct s s = {0xa5a5};

	f(0x5a5a, s); // When passing s, a memcpy call will be used as helper function. The 0x5a5a will be passed as if it was an additional parameter to that memcpy instead of being passed to f.
#endif
}