Debian Codegraph @

gcc/testsuite/gcc.c-torture/compile/structret.c

raw
1 /* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */
2 /* { dg-additional-options "-std=gnu89" } */
3
4 struct foo
5 {
6 int a, b, c, d;
7 double doubl;
8 } s1, s2;
9
10 #ifndef ONLY2
11
12 struct foo
13 structret (s1, i1, i2, s2)
14 struct foo s1, s2;
15 int i1, i2;
16 {
17 if (i1 != i2)
18 {
19 if (i1 < i2)
20 return s1;
21 else
22 return s2;
23 }
24 s2.a = 11;
25 s2.b = 22;
26 s2.c = s1.c;
27 s2.d = s1.d;
28 return s2;
29 }
30
31 #endif
32
33 #ifndef ONLY1
34
35 struct foo
36 mani (a, b)
37 {
38 return structret (s1, a, b, s2);
39 }
40
41 init ()
42 {
43 s1.a = 1;
44 s1.b = 2;
45 s1.c = 3;
46 s1.d = 4;
47 s1.doubl = 3.1415;
48 s2.a = -1;
49 s2.b = -2;
50 s2.c = -3;
51 s2.d = -4;
52 s2.doubl = 2.71818;
53 }
54
55 main ()
56 {
57 struct foo s;
58
59 init ();
60 s = mani (1, 1);
61 printf ("%d, %d, %d, %d : %f\n", s.a, s.b, s.c, s.d, s.doubl);
62
63 init ();
64 s = mani (2, 1);
65 printf ("%d, %d, %d, %d : %f\n", s.a, s.b, s.c, s.d, s.doubl);
66
67 init ();
68 s = mani (1, 2);
69 printf ("%d, %d, %d, %d : %f\n", s.a, s.b, s.c, s.d, s.doubl);
70 }
71
72 #endif