summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug2783061.c
blob: fe87c950ec370c4cfec581a754d3df8b66b3f23c (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
35
36
37
38
39
40
41
42
43
44
/*
    bug 2783061
*/

#include <stdarg.h>
#include <testfwk.h>

#define CP	(void __code*)0x1234
#define XP	(void __xdata*)0x5678

void
varargs_fn (char k, ...)
{
  va_list arg;
  void __code * cp;
  void __xdata * xp;
  void * gp;

  va_start (arg, k);

  cp = va_arg (arg, void __code *);
  ASSERT (cp == CP);
  xp = va_arg (arg, void __xdata *);
  ASSERT (xp == XP);
  gp = va_arg (arg, void *);
  ASSERT (gp == (void *)CP);
#if defined(__SDCC_hc08) || defined(__SDCC_s08)
  /* bug 2713 - casting literal pointer to generic pointer modified upper bits */
  ASSERT ((int)gp == 0x1234);
#endif
  gp = va_arg (arg, void *);
  ASSERT (gp == (void *)XP);

  va_end (arg);
}

void
testBug (void)
{
  void __code * cp = CP;
  void __xdata * xp = XP;

  varargs_fn('k', (void __code *)cp, (void __xdata *)xp, cp, xp);
}