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