summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-2376.c
blob: da6160c08dd18ec8c4bb3d34cbe883e765d98663 (plain) (blame)
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
/*
   bug-2195.c

   A peephole optimizer bug in calls to __z88dk_fastcall.
*/

#if !defined(__SDCC_z80) && !defined(__SDCC_z180) && !defined(__SDCC_r2k) && !defined(__SDCC_r3ka) && !defined(__SDCC_tlcs90)
#define __z88dk_fastcall
#endif

#include <string.h>
#include <testfwk.h>

char v[5];

void kputchar(unsigned char c) __z88dk_fastcall
{
  static int i;
  v[i++] = c;
}

void kputs(const char *p) __z88dk_fastcall
{
  while(*p)
    kputchar(*p++); /* The bug resulted in the peephole optimizer optimizing out the parameter to this call */
}

void testBug(void)
{
  const char *s = "test";
  kputs(s);
  ASSERT(!strcmp(s, v));
}