summaryrefslogtreecommitdiff
path: root/support/regression/tests/gcc-torture-execute-pr64979.c
blob: 949d5fdbc3d826a512a7848f39deae79c135e8ff (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
/*
   pr64979.c from the execute part of the gcc torture tests.
 */

#include <testfwk.h>

#ifdef __SDCC
#pragma std_c99
#pragma disable_warning 93
#endif

/* PR target/64979 */

#include <stdarg.h>

#ifndef __SDCC_pdk14 // Lack of memory
void
bar (int x, va_list *ap)
{
  (void)x;
  if (ap)
    {
      int i;
      for (i = 0; i < 10; i++)
        ASSERT (i == va_arg (*ap, int));
      ASSERT (va_arg (*ap, double) == 0.5);
    }
}

void
foo (int x, ...)
{
  va_list ap;
  int n;

  va_start (ap, x);
  n = va_arg (ap, int);
  bar (x, (va_list *) ((n == 0) ? ((void *) 0) : &ap));
  va_end (ap);
}
#endif

void
testTortureExecute (void)
{
#ifndef __SDCC_pdk14 // Lack of memory
  foo (100, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0.5);
  return;
#endif
}