Fix handling of pre-C2X function declarators without prototype, RFE #776.
[sdcc.git] / sdcc / support / regression / tests / bug-3135.c
blob47782a256a948ac1381f4597ed255edb3535441f
1 /* bug-3135.c
2 A stack access overwrote a value held in hl on gbz80.
3 */
5 #include <testfwk.h>
7 #pragma disable_warning 283
9 typedef unsigned char UBYTE;
11 #define MAX_PROJECTILES 2
12 #define MAX_ACTIVE_ACTORS 3
13 #define MAX_ACTORS 4
15 typedef struct _BankPtr
17 unsigned char bank;
18 unsigned int offset;
19 } BankPtr;
21 typedef struct _PROJECTILE {
22 UBYTE col_group;
23 } Projectile;
25 typedef struct {
26 BankPtr hit_1_ptr;
27 BankPtr hit_2_ptr;
28 } Actor;
30 Projectile projectiles[MAX_PROJECTILES];
31 UBYTE actors_active[MAX_ACTIVE_ACTORS];
32 Actor actors[MAX_ACTORS];
34 void TestFn2(BankPtr* events_ptr) {
35 ASSERT (events_ptr->bank == 5 && events_ptr->offset == 0xFC00);
38 void TestFn() {
39 UBYTE hit;
40 UBYTE i;
42 for (i = 0; i != 1; i++) {
43 hit = actors_active[0];
44 if (hit != 0xFF) {
45 if (projectiles[i].col_group == 2) {
46 TestFn2(&actors[hit].hit_1_ptr);
47 } else if (projectiles[i].col_group == 4) {
48 TestFn2(&actors[hit].hit_2_ptr);
54 void
55 testBug(void)
57 projectiles[0].col_group = 2;
58 actors_active[0] = 0;
59 actors[0].hit_1_ptr.bank = 5;
60 actors[0].hit_1_ptr.offset = 0xFC00;
62 TestFn();