summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-3169.c
blob: 5e1da592837720974b41707da5d65121817f04d0 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
   bug-3169.c
   A bug in z80 pointer write code generation handling of non-dead register pair de when using --reserve-regs-iy.
 */

#include <testfwk.h>

#pragma disable_warning 283

typedef unsigned char uint8_t;
typedef unsigned int uint16_t;
typedef unsigned char bool;

typedef struct _Struct {
  uint8_t abyte1;
  uint8_t abyte2;
  uint16_t aint;
} Struct;

Struct storage;

uint16_t srcInt;
bool flag;

extern void fn1(const Struct*) __z88dk_fastcall;

void f() {

  storage.abyte1 = 1;
  storage.abyte2 = 10;

  if (flag) {
    storage.aint = srcInt;
    fn1(&storage);

    return;
  }

  storage.aint = 1;
  fn1(&storage);
}

void fn1(const Struct *sp) __z88dk_fastcall
{
  ASSERT(sp == &storage);
}

void
testBug(void)
{
  flag = 1;
  f();
}