1/*
2 * Copyright 2014, NICTA
3 *
4 * This software may be distributed and modified according to the terms of
5 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
6 * See "LICENSE_BSD2.txt" for details.
7 *
8 * @TAG(NICTA_BSD)
9 */
10
11struct struct1 {
12  char c;
13  int fld1;
14  char fld2;
15};
16
17struct charpair {
18  char c1;
19  char c2;
20};
21
22struct allinclusive {
23  char c;
24  struct charpair p1;
25  struct struct1 s;
26  int foo;
27  };
28
29int firstinc_ptr(struct struct1 *sptr)
30{
31  if (sptr) { return sptr->fld1 + 1; }
32  else return 1;
33}
34
35int firstinc(struct struct1 m)
36{
37  return m.fld1 + 1;
38}
39
40struct struct1 *firstptr_ptr(struct struct1 *sptr)
41{
42  return sptr + 1;
43}
44
45int *fldaddr(struct struct1 *sptr)
46{
47  return &(sptr->fld1);
48}
49
50struct allinclusive mkall(int i)
51{
52  struct allinclusive s;
53  s.c = i;
54  s.s.c = i + 1;
55  s.p1.c1 = i + 2;
56  s.p1.c2 = i + 3;
57  s.s.fld1 = i + 4;
58  s.s.fld2 = i + 5;
59  s.foo = i + 6;
60  return s;
61}
62
63
64struct voidstar {
65  void *vptr;
66  int i;
67};
68
69struct recursive1;
70struct recursive2 {
71  struct recursive1 *ptr;
72  int fld;
73};
74
75struct recursive1 {
76  struct recursive2 subfld;
77  char c;
78};
79
80struct {
81  int anonfld1;
82  char anonfld2[10];
83} anon_global1, anon_global2;
84
85int f(int i)
86{
87  if (i == 0) return anon_global1.anonfld1;
88  else return anon_global2.anonfld1;
89}
90
91struct tree20 {
92  struct tree20 *array[20];
93  void *data;
94};
95
96struct tree20 create20(void *init)
97{
98  struct tree20 s;
99  for (int i = 0; i < 20; i++) s.array[i] = 0;
100  s.data = init;
101  return s;
102}
103
104typedef struct monstrous {
105  int i,j;
106} __attribute__((packed)) monstrous_t;
107
108monstrous_t yikes(void)
109{
110  return (monstrous_t){.j = 6, .i = 3};
111}
112