PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / struct-by-value-1.c
blobaddf253d8e2ccc58b40c41d4ec5124253c9829a9
1 /* Test structure passing by value. */
2 /* { dg-do run } */
3 /* { dg-options "-O2" } */
5 #define T(N) \
6 struct S##N { unsigned char i[N]; }; \
7 struct S##N g1s##N, g2s##N, g3s##N; \
9 void \
10 init##N (struct S##N *p, int i) \
11 { \
12 int j; \
13 for (j = 0; j < N; j++) \
14 p->i[j] = i + j; \
15 } \
17 void \
18 check##N (struct S##N *p, int i) \
19 { \
20 int j; \
21 for (j = 0; j < N; j++) \
22 if (p->i[j] != i + j) abort (); \
23 } \
25 void \
26 test##N (struct S##N s1, struct S##N s2, \
27 struct S##N s3) \
28 { \
29 check##N (&s1, 64); \
30 check##N (&s2, 128); \
31 check##N (&s3, 192); \
32 } \
34 void \
35 test2_##N (struct S##N s1, struct S##N s2) \
36 { \
37 test##N (s1, g2s##N, s2); \
38 } \
40 void \
41 testit##N (void) \
42 { \
43 init##N (&g1s##N, 64); \
44 check##N (&g1s##N, 64); \
45 init##N (&g2s##N, 128); \
46 check##N (&g2s##N, 128); \
47 init##N (&g3s##N, 192); \
48 check##N (&g3s##N, 192); \
49 test##N (g1s##N, g2s##N, g3s##N); \
50 test2_##N (g1s##N, g3s##N); \
53 extern void abort (void);
54 extern void exit (int);
56 T(0) T(1) T(2) T(3) T(4) T(5) T(6) T(7)
57 T(8) T(9) T(10) T(11) T(12) T(13) T(14) T(15)
58 T(16) T(17) T(18) T(19) T(20) T(21) T(22) T(23)
59 T(24) T(25) T(26) T(27) T(28) T(29) T(30) T(31)
60 T(32) T(33) T(34) T(35) T(36) T(37) T(38) T(39)
61 T(40) T(41) T(42) T(43) T(44) T(45) T(46) T(47)
62 T(48) T(49) T(50) T(51) T(52) T(53) T(54) T(55)
63 T(56) T(57) T(58) T(59) T(60) T(61) T(62) T(63)
65 #undef T
67 int
68 main ()
70 #define T(N) testit##N ();
72 T(0) T(1) T(2) T(3) T(4) T(5) T(6) T(7)
73 T(8) T(9) T(10) T(11) T(12) T(13) T(14) T(15)
74 T(16) T(17) T(18) T(19) T(20) T(21) T(22) T(23)
75 T(24) T(25) T(26) T(27) T(28) T(29) T(30) T(31)
76 T(32) T(33) T(34) T(35) T(36) T(37) T(38) T(39)
77 T(40) T(41) T(42) T(43) T(44) T(45) T(46) T(47)
78 T(48) T(49) T(50) T(51) T(52) T(53) T(54) T(55)
79 T(56) T(57) T(58) T(59) T(60) T(61) T(62) T(63)
81 #undef T
82 exit (0);