libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / compat / struct-align-1_x.c
blob939db9d21e045b864f9b5b835a93f14759767228
1 /* { dg-options "-Wno-psabi" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
3 #include "compat-common.h"
4 #include "struct-align-1.h"
6 #define SETUP(NAME,V1,V2,V3) \
7 char v1_##NAME = V1; \
8 double v2_##NAME = V2; \
9 int v3_##NAME = V3; \
11 struct B1_##NAME b1_##NAME = { V1, V2 }; \
12 struct B2_##NAME b2_##NAME = { V1, { V2 } }; \
13 struct B3_##NAME b3_##NAME = { V1, { V2, V3 } }; \
15 struct B1_##NAME ab1_##NAME[2] = \
16 { { V1, V2 }, { V1, V2 } }; \
17 struct B2_##NAME ab2_##NAME[2] = \
18 { { V1, { V2 } }, { V1, { V2 } } }; \
19 struct B3_##NAME ab3_##NAME[2] = \
20 { { V1, { V2, V3 } }, { V1, { V2, V3 } } }; \
22 extern void test_##NAME (void); \
23 extern void checkp1_##NAME (struct B1_##NAME *); \
24 extern void checkp2_##NAME (struct B2_##NAME *); \
25 extern void checkp3_##NAME (struct B3_##NAME *); \
26 extern void checkg1_##NAME (void); \
27 extern void checkg2_##NAME (void); \
28 extern void checkg3_##NAME (void); \
30 void \
31 pass1_##NAME (struct B1_##NAME s) \
32 { \
33 checkp1_##NAME (&s); \
34 } \
36 void \
37 pass2_##NAME (struct B2_##NAME s) \
38 { \
39 checkp2_##NAME (&s); \
40 } \
42 void \
43 pass3_##NAME (struct B3_##NAME s) \
44 { \
45 checkp3_##NAME (&s); \
46 } \
48 struct B1_##NAME \
49 return1_##NAME (void) \
50 { \
51 return ab1_##NAME[0]; \
52 } \
54 struct B2_##NAME \
55 return2_##NAME (void) \
56 { \
57 return ab2_##NAME[0]; \
58 } \
60 struct B3_##NAME \
61 return3_##NAME (void) \
62 { \
63 return ab3_##NAME[0]; \
66 #define CHECK(NAME) test_##NAME()
68 #if __INT_MAX__ > 32767
69 SETUP (orig, 49, 1.0, 111111)
70 #else
71 SETUP (orig, 49, 1.0, 1111)
72 #endif
73 #ifndef SKIP_ATTRIBUTE
74 #if __INT_MAX__ > 32767
75 SETUP (p_all, 50, 2.0, 222222)
76 SETUP (p_inner, 51, 3.0, 333333)
77 SETUP (p_outer, 52, 4.0, 444444)
78 SETUP (a_max, 53, 5.0, 555555)
79 SETUP (m_outer_p_inner, 54, 6.0, 666666)
80 SETUP (m_inner_p_outer, 55, 7.0, 777777)
81 #else
82 SETUP (p_all, 50, 2.0, 2222)
83 SETUP (p_inner, 51, 3.0, 3333)
84 SETUP (p_outer, 52, 4.0, 4444)
85 SETUP (a_max, 53, 5.0, 5555)
86 SETUP (m_outer_p_inner, 54, 6.0, 6666)
87 SETUP (m_inner_p_outer, 55, 7.0, 7777)
88 #endif
89 #endif
91 void
92 struct_align_1_x (void)
94 DEBUG_INIT
96 CHECK (orig);
97 #ifndef SKIP_ATTRIBUTE
98 CHECK (p_all);
99 CHECK (p_inner);
100 CHECK (p_outer);
101 CHECK (a_max);
102 CHECK (m_outer_p_inner);
103 CHECK (m_inner_p_outer);
104 #endif
106 DEBUG_FINI
108 if (fails != 0)
109 abort ();