aboutsummaryrefslogtreecommitdiff
path: root/gdb/teststruct.c
blob: 75f16422f0ab16e65841a9b009c489e4a9de144b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
struct small
{
  int i;
};

struct med
{
  struct small s1, s2;
};

struct large
{
  struct med m1, m2;
};

struct xlarge
{
  struct large l1, l2;
};

struct small ret_small ();
struct med ret_med ();
struct large ret_large ();
struct xlarge ret_xlarge ();

void print_small ();
void print_med ();
void print_large ();
void print_xlarge ();

main ()
{
  struct small s;
  struct med m;
  struct large l;
  struct xlarge x;

  s = ret_small (1);
  m = ret_med (s,s);
  l = ret_large (m, m);
  x = ret_xlarge (l, l);

  print_small (s);
  print_med (m);
  print_large (l);
  print_xlarge (x);
}

struct small ret_small (i)
     int i;
{
  struct small s;
  s.i = i;
  return s;
}

struct med ret_med (s1, s2)
     struct small s1, s2;
{
  struct med m;
  m.s1 = s1;
  m.s2 = s2;
  return m;
}

struct large ret_large (m1, m2)
     struct med m1, m2;
{
  struct large l;
  l.m1 = m1;
  l.m2 = m2;
  return l;
}

struct xlarge ret_xlarge (l1, l2)
     struct large l1, l2;
{
  struct xlarge x;
  x.l1 = l1;
  x.l2 = l2;
  return x;
}

void print_small (s)
     struct small s;
{
  printf ("small: s.i = %d\n", s.i);
}

void print_med (m)
     struct med m;
{
  printf ("med: m.s1.i = %d; m.s2.i = %d\n", m.s1.i, m.s2.i);
}

void print_large (l)
     struct large l;
{
  printf ("large: l.m1.s1.i = %d; l.m1.s2.i = %d; l.m2.s1.i = %d; l.m2.s2.i = %d\n",
	  l.m1.s1.i, l.m1.s2.i, l.m2.s1.i, l.m2.s2.i);
}

void print_xlarge (x)
     struct xlarge x;
{
  printf ("xlarge: x.l1: ");
  print_large (x.l1);
  printf ("xlarge: x.l2: ");
  print_large (x.l2);
}