Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / gcc.dg / fixed-point / struct-layout-1.c
blobb9a02f0c7a820f9815ab6e5cff0d609586636d7c
1 /* { dg-do run } */
2 /* { dg-options "-std=gnu99" } */
4 /* This test is based on the test from ../dfp/. */
6 #include <stdarg.h>
8 extern void abort (void);
10 struct S1
12 long _Fract a[0];
15 struct S2
17 struct
19 long _Fract e;
20 } b[0];
23 struct S3
25 union
27 long _Fract c;
28 } a[0];
31 struct S4
33 int a[0];
34 long _Fract b[0];
37 struct S5
39 union
41 long _Fract c[0];
42 } a;
45 int check_var (int z, ...)
47 long long result;
48 va_list ap;
49 va_start (ap, z);
50 va_arg (ap, struct S1);
51 result = va_arg (ap, long long);
52 va_end (ap);
54 return (result == 2LL);
57 int main ()
59 struct S1 s1;
60 struct S2 s2;
61 struct S3 s3;
62 struct S4 s4;
63 struct S5 s5;
65 if (check_var (2, s1, 2LL) == 0)
66 abort ();
67 if (check_var (2, s2, 2LL) == 0)
68 abort ();
69 if (check_var (2, s3, 2LL) == 0)
70 abort ();
71 if (check_var (2, s4, 2LL) == 0)
72 abort ();
73 if (check_var (2, s5, 2LL) == 0)
74 abort ();
76 return 0;