OSDN Git Service

* gcc.dg/compat/compat-common.h: New file.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / compat / scalar-by-value-1_y.c
1 #include <stdarg.h>
2
3 #include "compat-common.h"
4
5 /* Turn off checking for variable arguments with -DSKIPVA.  */
6 #ifdef SKIPVA
7 const int test_va = 0;
8 #else
9 const int test_va = 1;
10 #endif
11
12 #define T(NAME, TYPE, INITVAL)                                  \
13 extern TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME;         \
14 extern TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME;         \
15 extern TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME;         \
16 extern TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME;         \
17                                                                 \
18 extern void check##NAME (TYPE x, TYPE v);                       \
19                                                                 \
20 void                                                            \
21 init##NAME (TYPE *p, TYPE v)                                    \
22 {                                                               \
23   *p = v + INITVAL;                                             \
24 }                                                               \
25                                                                 \
26 void                                                            \
27 checkg##NAME (void)                                             \
28 {                                                               \
29   check##NAME (g01##NAME,  1);                                  \
30   check##NAME (g02##NAME,  2);                                  \
31   check##NAME (g03##NAME,  3);                                  \
32   check##NAME (g04##NAME,  4);                                  \
33   check##NAME (g05##NAME,  5);                                  \
34   check##NAME (g06##NAME,  6);                                  \
35   check##NAME (g07##NAME,  7);                                  \
36   check##NAME (g08##NAME,  8);                                  \
37   check##NAME (g09##NAME,  9);                                  \
38   check##NAME (g10##NAME, 10);                                  \
39   check##NAME (g11##NAME, 11);                                  \
40   check##NAME (g12##NAME, 12);                                  \
41   check##NAME (g13##NAME, 13);                                  \
42   check##NAME (g14##NAME, 14);                                  \
43   check##NAME (g15##NAME, 15);                                  \
44   check##NAME (g16##NAME, 16);                                  \
45 }                                                               \
46                                                                 \
47 void                                                            \
48 test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04,             \
49             TYPE x05, TYPE x06, TYPE x07, TYPE x08,             \
50             TYPE x09, TYPE x10, TYPE x11, TYPE x12,             \
51             TYPE x13, TYPE x14, TYPE x15, TYPE x16)             \
52 {                                                               \
53   check##NAME (x01,  1);                                        \
54   check##NAME (x02,  2);                                        \
55   check##NAME (x03,  3);                                        \
56   check##NAME (x04,  4);                                        \
57   check##NAME (x05,  5);                                        \
58   check##NAME (x06,  6);                                        \
59   check##NAME (x07,  7);                                        \
60   check##NAME (x08,  8);                                        \
61   check##NAME (x09,  9);                                        \
62   check##NAME (x10, 10);                                        \
63   check##NAME (x11, 11);                                        \
64   check##NAME (x12, 12);                                        \
65   check##NAME (x13, 13);                                        \
66   check##NAME (x14, 14);                                        \
67   check##NAME (x15, 15);                                        \
68   check##NAME (x16, 16);                                        \
69 }                                                               \
70                                                                 \
71 void                                                            \
72 testva##NAME (int n, ...)                                       \
73 {                                                               \
74   int i;                                                        \
75   va_list ap;                                                   \
76   if (test_va)                                                  \
77     {                                                           \
78       va_start (ap, n);                                         \
79       for (i = 0; i < n; i++)                                   \
80         {                                                       \
81           TYPE t = va_arg (ap, TYPE);                           \
82           check##NAME (t, i+1);                                 \
83         }                                                       \
84       va_end (ap);                                              \
85     }                                                           \
86 }
87
88 T(ui, unsigned int, 51)
89 T(si, int, (-55))
90 T(ul, unsigned long, 61)
91 T(sl, long, (-66))
92 T(ull, unsigned long long, 71)
93 T(sll, long long, (-77))
94 T(d, double, 91.0)
95 T(ld, long double, 92.0)