[gdb] Fix more typos in comments (2)
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / ctf-ptype.c
1 /* This test program is part of GDB, the GNU debugger.
2
3 Copyright 2019 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 /*
19 * Test file with lots of different types, for testing the
20 * "ptype" command on CTF data. It's derived from ptype.c.
21 */
22
23 /*
24 * First the basic C types.
25 */
26
27 #if !defined (__STDC__) && !defined (_AIX)
28 #define signed /**/
29 #endif
30
31 char v_char;
32 signed char v_signed_char;
33 unsigned char v_unsigned_char;
34
35 short v_short;
36 signed short v_signed_short;
37 unsigned short v_unsigned_short;
38
39 int v_int;
40 signed int v_signed_int;
41 unsigned int v_unsigned_int;
42
43 long v_long;
44 signed long v_signed_long;
45 unsigned long v_unsigned_long;
46
47 float v_float;
48 double v_double;
49
50 /**** arrays *******/
51
52 char v_char_array[2];
53 signed char v_signed_char_array[2];
54 unsigned char v_unsigned_char_array[2];
55
56 short v_short_array[2];
57 signed short v_signed_short_array[2];
58 unsigned short v_unsigned_short_array[2];
59
60 int v_int_array[2];
61 signed int v_signed_int_array[2];
62 unsigned int v_unsigned_int_array[2];
63
64 long v_long_array[2];
65 signed long v_signed_long_array[2];
66 unsigned long v_unsigned_long_array[2];
67
68 float v_float_array[2];
69 double v_double_array[2];
70
71 /* PR 3742 */
72 typedef char t_char_array[];
73 t_char_array *pv_char_array;
74
75 /**** pointers *******/
76
77 char *v_char_pointer;
78 signed char *v_signed_char_pointer;
79 unsigned char *v_unsigned_char_pointer;
80
81 short *v_short_pointer;
82 signed short *v_signed_short_pointer;
83 unsigned short *v_unsigned_short_pointer;
84
85 int *v_int_pointer;
86 signed int *v_signed_int_pointer;
87 unsigned int *v_unsigned_int_pointer;
88
89 long *v_long_pointer;
90 signed long *v_signed_long_pointer;
91 unsigned long *v_unsigned_long_pointer;
92
93 float *v_float_pointer;
94 double *v_double_pointer;
95
96 /**** structs *******/
97
98 struct t_struct {
99 char v_char_member;
100 short v_short_member;
101 int v_int_member;
102 long v_long_member;
103 float v_float_member;
104 double v_double_member;
105 } v_struct1;
106
107 struct t_struct *v_t_struct_p;
108
109 struct {
110 char v_char_member;
111 short v_short_member;
112 int v_int_member;
113 long v_long_member;
114 float v_float_member;
115 double v_double_member;
116 } v_struct2;
117
118 /* typedef'd struct without a tag. */
119 typedef struct {
120 double v_double_member;
121 int v_int_member;
122 } t_struct3;
123 /* GCC seems to want a variable of this type, or else it won't put out
124 a symbol. */
125 t_struct3 v_struct3;
126
127 /**** unions *******/
128
129 union t_union {
130 char v_char_member;
131 short v_short_member;
132 int v_int_member;
133 long v_long_member;
134 float v_float_member;
135 double v_double_member;
136 } v_union;
137
138 union {
139 char v_char_member;
140 short v_short_member;
141 int v_int_member;
142 long v_long_member;
143 float v_float_member;
144 double v_double_member;
145 } v_union2;
146
147 /* typedef'd union without a tag. */
148 typedef union {
149 double v_double_member;
150 int v_int_member;
151 } t_union3;
152 /* GCC seems to want a variable of this type, or else it won't put out
153 a symbol. */
154 t_union3 v_union3;
155
156 /**** Some misc more complicated things *******/
157
158 struct outer_struct {
159 int outer_int;
160 struct inner_struct {
161 int inner_int;
162 long inner_long;
163 }inner_struct_instance;
164 union inner_union {
165 int inner_union_int;
166 long inner_union_long;
167 }inner_union_instance;
168 long outer_long;
169 } nested_su;
170
171 struct highest
172 {
173 int a;
174 struct
175 {
176 int b;
177 struct { int c; } anonymous_level_2;
178 } anonymous_level_1;
179 } the_highest;
180
181 /**** Enumerations *******/
182
183 enum
184 /* Work around the bug for compilers which don't put out the right stabs. */
185 #if __GNUC__ < 2 && !defined (_AIX)
186 primary1_tag
187 #endif
188 {red1, green1, blue1} primary1;
189
190 enum {red, green, blue} primary;
191 enum colors {yellow, purple, pink} nonprimary;
192
193 enum {chevy, ford} clunker;
194 enum cars {bmw, porsche} sportscar;
195
196 #undef FALSE
197 #undef TRUE
198 typedef enum {FALSE, TRUE} boolean;
199 boolean v_boolean;
200 /*note: aCC has bool type predefined with 'false' and 'true'*/
201 typedef enum bvals {my_false, my_true} boolean2;
202 boolean2 v_boolean2;
203
204 enum misordered {two = 2, one = 1, zero = 0, three = 3};
205
206 /* Seems like we need a variable of this type to get the type to be put
207 in the executable, at least for AIX xlc. */
208 enum misordered v_misordered = three;
209
210 /**** Pointers to functions *******/
211
212 typedef int (*func_type) (int (*) (int, float), float);
213 double (*old_fptr) ();
214 double (*new_fptr) (void);
215 int (*fptr) (int, float);
216 int *(*fptr2) (int (*) (int, float), float);
217 int (*xptr) (int (*) (), int (*) (void), int);
218 int (*(*ffptr) (char)) (short);
219 int (*(*(*fffptr) (char)) (short)) (long);
220
221 func_type v_func_type;
222
223 int main ()
224 {
225 /* Ensure that malloc is a pointer type; avoid use of "void" and any include files. */
226 /* extern char *malloc();*/
227
228 /* Some of the tests in ptype.exp require invoking malloc, so make
229 sure it is linked in to this program. */
230 v_char_pointer = (char *) malloc (1);
231
232 /* Some linkers (e.g. on AIX) remove unreferenced variables,
233 so make sure to reference them. */
234 primary = blue;
235 primary1 = blue1;
236 nonprimary = pink;
237 sportscar = porsche;
238 clunker = ford;
239 v_struct1.v_int_member = 5;
240 v_struct2.v_int_member = 6;
241 v_struct3.v_int_member = 7;
242
243 v_char = 0;
244 v_signed_char = 0;
245 v_unsigned_char = 0;
246
247 v_short = 0;
248 v_signed_short = 0;
249 v_unsigned_short = 0;
250
251 v_int = 0;
252 v_signed_int = 0;
253 v_unsigned_int = 0;
254
255 v_long = 0;
256 v_signed_long = 0;
257 v_unsigned_long = 0;
258
259 v_float = 0;
260 v_double = 0;
261
262 v_char_array[0] = 0;
263 v_signed_char_array[0] = 0;
264 v_unsigned_char_array[0] = 0;
265
266 v_short_array[0] = 0;
267 v_signed_short_array[0] = 0;
268 v_unsigned_short_array[0] = 0;
269
270 v_int_array[0] = 0;
271 v_signed_int_array[0] = 0;
272 v_unsigned_int_array[0] = 0;
273
274 v_long_array[0] = 0;
275 v_signed_long_array[0] = 0;
276 v_unsigned_long_array[0] = 0;
277
278 v_float_array[0] = 0;
279 v_double_array[0] = 0;
280
281 v_char_pointer = 0;
282 v_signed_char_pointer = 0;
283 v_unsigned_char_pointer = 0;
284
285 v_short_pointer = 0;
286 v_signed_short_pointer = 0;
287 v_unsigned_short_pointer = 0;
288
289 v_int_pointer = 0;
290 v_signed_int_pointer = 0;
291 v_unsigned_int_pointer = 0;
292
293 v_long_pointer = 0;
294 v_signed_long_pointer = 0;
295 v_unsigned_long_pointer = 0;
296
297 v_float_pointer = 0;
298 v_double_pointer = 0;
299
300 nested_su.outer_int = 0;
301 v_t_struct_p = 0;
302
303 the_highest.a = 0;
304 return 0;
305 }
This page took 0.03773 seconds and 4 git commands to generate.