OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [va-arg-22.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 688 jeremybenn
#include <stdarg.h>
2
 
3
extern void abort (void);
4
extern void exit (int);
5
 
6
void bar (int n, int c)
7
{
8
  static int lastn = -1, lastc = -1;
9
 
10
  if (lastn != n)
11
    {
12
      if (lastc != lastn)
13
        abort ();
14
      lastc = 0;
15
      lastn = n;
16
    }
17
 
18
  if (c != (char) (lastc ^ (n << 3)))
19
    abort ();
20
  lastc++;
21
}
22
 
23
#define D(N) typedef struct { char x[N]; } A##N;
24
D(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)
25
D(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)
26
D(16) D(31) D(32) D(35) D(72)
27
#undef D
28
 
29
void foo (int size, ...)
30
{
31
#define D(N) A##N a##N;
32
D(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)
33
D(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)
34
D(16) D(31) D(32) D(35) D(72)
35
#undef D
36
  va_list ap;
37
  int i;
38
 
39
  if (size != 21)
40
    abort ();
41
  va_start (ap, size);
42
#define D(N)                                    \
43
  a##N = va_arg (ap, typeof (a##N));            \
44
  for (i = 0; i < N; i++)                        \
45
    bar (N, a##N.x[i]);
46
D(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)
47
D(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)
48
D(16) D(31) D(32) D(35) D(72)
49
#undef D
50
  va_end (ap);
51
}
52
 
53
int main (void)
54
{
55
#define D(N) A##N a##N;
56
D(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)
57
D(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)
58
D(16) D(31) D(32) D(35) D(72)
59
#undef D
60
  int i;
61
 
62
#define D(N)                                    \
63
  for (i = 0; i < N; i++)                        \
64
    a##N.x[i] = i ^ (N << 3);
65
D(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)
66
D(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)
67
D(16) D(31) D(32) D(35) D(72)
68
#undef D
69
 
70
  foo (21
71
#define D(N) , a##N
72
D(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)
73
D(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)
74
D(16) D(31) D(32) D(35) D(72)
75
#undef D
76
      );
77
  exit (0);
78
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.