Commit | Line | Data |
---|---|---|
a6bac58e TT |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
3 | Copyright 2008, 2009 Free Software Foundation, Inc. | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 3 of the License, or | |
8 | (at your option) any later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
17 | ||
18 | struct s | |
19 | { | |
20 | int a; | |
21 | int *b; | |
22 | }; | |
23 | ||
24 | struct ss | |
25 | { | |
26 | struct s a; | |
27 | struct s b; | |
28 | }; | |
29 | ||
30 | #ifdef __cplusplus | |
31 | struct S : public s { | |
32 | int zs; | |
33 | }; | |
34 | ||
35 | struct SS { | |
36 | int zss; | |
37 | S s; | |
38 | }; | |
39 | ||
40 | struct SSS | |
41 | { | |
42 | SSS (int x, const S& r); | |
43 | int a; | |
44 | const S &b; | |
45 | }; | |
46 | SSS::SSS (int x, const S& r) : a(x), b(r) { } | |
47 | ||
48 | class VirtualTest | |
49 | { | |
50 | private: | |
51 | int value; | |
52 | ||
53 | public: | |
54 | VirtualTest () | |
55 | { | |
56 | value = 1; | |
57 | } | |
58 | }; | |
59 | ||
60 | class Vbase1 : public virtual VirtualTest { }; | |
61 | class Vbase2 : public virtual VirtualTest { }; | |
62 | class Vbase3 : public virtual VirtualTest { }; | |
63 | ||
64 | class Derived : public Vbase1, public Vbase2, public Vbase3 | |
65 | { | |
66 | private: | |
67 | int value; | |
68 | ||
69 | public: | |
70 | Derived () | |
71 | { | |
72 | value = 2; | |
73 | } | |
74 | }; | |
75 | ||
76 | #endif | |
77 | ||
78 | typedef struct string_repr | |
79 | { | |
80 | struct whybother | |
81 | { | |
82 | const char *contents; | |
83 | } whybother; | |
84 | } string; | |
85 | ||
86 | /* This lets us avoid malloc. */ | |
87 | int array[100]; | |
88 | ||
89 | struct container | |
90 | { | |
91 | string name; | |
92 | int len; | |
93 | int *elements; | |
94 | }; | |
95 | ||
96 | typedef struct container zzz_type; | |
97 | ||
98 | string | |
99 | make_string (const char *s) | |
100 | { | |
101 | string result; | |
102 | result.whybother.contents = s; | |
103 | return result; | |
104 | } | |
105 | ||
106 | zzz_type | |
107 | make_container (const char *s) | |
108 | { | |
109 | zzz_type result; | |
110 | ||
111 | result.name = make_string (s); | |
112 | result.len = 0; | |
113 | result.elements = 0; | |
114 | ||
115 | return result; | |
116 | } | |
117 | ||
118 | void | |
119 | add_item (zzz_type *c, int val) | |
120 | { | |
121 | if (c->len == 0) | |
122 | c->elements = array; | |
123 | c->elements[c->len] = val; | |
124 | ++c->len; | |
125 | } | |
126 | ||
127 | void init_s(struct s *s, int a) | |
128 | { | |
129 | s->a = a; | |
130 | s->b = &s->a; | |
131 | } | |
132 | ||
133 | void init_ss(struct ss *s, int a, int b) | |
134 | { | |
135 | init_s(&s->a, a); | |
136 | init_s(&s->b, b); | |
137 | } | |
138 | ||
139 | void do_nothing(void) | |
140 | { | |
141 | int c; | |
142 | ||
143 | c = 23; /* Another MI breakpoint */ | |
144 | } | |
145 | ||
146 | int | |
147 | main () | |
148 | { | |
149 | struct ss ss; | |
150 | struct ss ssa[2]; | |
151 | string x = make_string ("this is x"); | |
152 | zzz_type c = make_container ("container"); | |
153 | const struct string_repr cstring = { { "const string" } }; | |
154 | ||
155 | init_ss(&ss, 1, 2); | |
156 | init_ss(ssa+0, 3, 4); | |
157 | init_ss(ssa+1, 5, 6); | |
158 | ||
159 | #ifdef __cplusplus | |
160 | S cps; | |
161 | ||
162 | cps.zs = 7; | |
163 | init_s(&cps, 8); | |
164 | ||
165 | SS cpss; | |
166 | cpss.zss = 9; | |
167 | init_s(&cpss.s, 10); | |
168 | ||
169 | SS cpssa[2]; | |
170 | cpssa[0].zss = 11; | |
171 | init_s(&cpssa[0].s, 12); | |
172 | cpssa[1].zss = 13; | |
173 | init_s(&cpssa[1].s, 14); | |
174 | ||
175 | SSS sss(15, cps); | |
176 | ||
177 | SSS& ref (sss); | |
178 | ||
179 | Derived derived; | |
180 | ||
181 | #endif | |
182 | ||
183 | add_item (&c, 23); /* MI breakpoint here */ | |
184 | add_item (&c, 72); | |
185 | ||
186 | #ifdef MI | |
187 | do_nothing (); | |
188 | #endif | |
189 | ||
190 | return 0; /* break to inspect struct and union */ | |
191 | } |