Commit | Line | Data |
---|---|---|
a8a69e63 | 1 | /* Support for printing C and C++ types for GDB, the GNU debugger. |
81afee37 | 2 | Copyright 1986, 1988, 1989, 1991, 1993, 1994, 1995, 1996 |
84bdfea6 | 3 | Free Software Foundation, Inc. |
a8a69e63 FF |
4 | |
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
6c9638b4 | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
a8a69e63 FF |
20 | |
21 | #include "defs.h" | |
22 | #include "obstack.h" | |
23 | #include "bfd.h" /* Binary File Description */ | |
24 | #include "symtab.h" | |
25 | #include "gdbtypes.h" | |
26 | #include "expression.h" | |
27 | #include "value.h" | |
28 | #include "gdbcore.h" | |
29 | #include "target.h" | |
30 | #include "command.h" | |
31 | #include "gdbcmd.h" | |
32 | #include "language.h" | |
33 | #include "demangle.h" | |
34 | #include "c-lang.h" | |
35 | #include "typeprint.h" | |
36 | ||
2b576293 | 37 | #include "gdb_string.h" |
a8a69e63 | 38 | #include <errno.h> |
4c664b8d | 39 | #include <ctype.h> |
a8a69e63 | 40 | |
65b07ddc DT |
41 | /* Flag indicating target was compiled by HP compiler */ |
42 | extern int hp_som_som_object_present; | |
43 | ||
a8a69e63 | 44 | static void |
199b2450 | 45 | c_type_print_args PARAMS ((struct type *, GDB_FILE *)); |
a8a69e63 FF |
46 | |
47 | static void | |
199b2450 | 48 | c_type_print_varspec_suffix PARAMS ((struct type *, GDB_FILE *, int, int, int)); |
a8a69e63 FF |
49 | |
50 | static void | |
199b2450 | 51 | cp_type_print_derivation_info PARAMS ((GDB_FILE *, struct type *)); |
a8a69e63 FF |
52 | |
53 | void | |
199b2450 | 54 | c_type_print_varspec_prefix PARAMS ((struct type *, GDB_FILE *, int, int)); |
a8a69e63 | 55 | |
65b07ddc DT |
56 | static void |
57 | c_type_print_cv_qualifier PARAMS ((struct type *, GDB_FILE *, int, int)); | |
58 | ||
59 | ||
a8a69e63 FF |
60 | \f |
61 | /* Print a description of a type in the format of a | |
62 | typedef for the current language. | |
63 | NEW is the new name for a type TYPE. */ | |
64 | ||
65 | void | |
66 | c_typedef_print (type, new, stream) | |
67 | struct type *type; | |
68 | struct symbol *new; | |
199b2450 | 69 | GDB_FILE *stream; |
a8a69e63 | 70 | { |
5e548861 | 71 | CHECK_TYPEDEF (type); |
a8a69e63 FF |
72 | switch (current_language->la_language) |
73 | { | |
74 | #ifdef _LANG_c | |
75 | case language_c: | |
76 | case language_cplus: | |
77 | fprintf_filtered(stream, "typedef "); | |
78 | type_print(type,"",stream,0); | |
79 | if(TYPE_NAME ((SYMBOL_TYPE (new))) == 0 | |
2e4964ad FF |
80 | || !STREQ (TYPE_NAME ((SYMBOL_TYPE (new))), SYMBOL_NAME (new))) |
81 | fprintf_filtered(stream, " %s", SYMBOL_SOURCE_NAME(new)); | |
a8a69e63 FF |
82 | break; |
83 | #endif | |
84 | #ifdef _LANG_m2 | |
85 | case language_m2: | |
86 | fprintf_filtered(stream, "TYPE "); | |
87 | if(!TYPE_NAME(SYMBOL_TYPE(new)) || | |
2e4964ad FF |
88 | !STREQ (TYPE_NAME(SYMBOL_TYPE(new)), SYMBOL_NAME(new))) |
89 | fprintf_filtered(stream, "%s = ", SYMBOL_SOURCE_NAME(new)); | |
a8a69e63 FF |
90 | else |
91 | fprintf_filtered(stream, "<builtin> = "); | |
92 | type_print(type,"",stream,0); | |
93 | break; | |
94 | #endif | |
a8a69e63 FF |
95 | #ifdef _LANG_chill |
96 | case language_chill: | |
6a2eecac PB |
97 | fprintf_filtered(stream, "SYNMODE "); |
98 | if(!TYPE_NAME(SYMBOL_TYPE(new)) || | |
99 | !STREQ (TYPE_NAME(SYMBOL_TYPE(new)), SYMBOL_NAME(new))) | |
100 | fprintf_filtered(stream, "%s = ", SYMBOL_SOURCE_NAME(new)); | |
101 | else | |
102 | fprintf_filtered(stream, "<builtin> = "); | |
103 | type_print(type,"",stream,0); | |
104 | break; | |
a8a69e63 | 105 | #endif |
a8a69e63 FF |
106 | default: |
107 | error("Language not supported."); | |
108 | } | |
109 | fprintf_filtered(stream, ";\n"); | |
110 | } | |
111 | ||
112 | ||
113 | /* LEVEL is the depth to indent lines by. */ | |
114 | ||
115 | void | |
116 | c_print_type (type, varstring, stream, show, level) | |
117 | struct type *type; | |
118 | char *varstring; | |
199b2450 | 119 | GDB_FILE *stream; |
a8a69e63 FF |
120 | int show; |
121 | int level; | |
122 | { | |
123 | register enum type_code code; | |
a8a69e63 FF |
124 | int demangled_args; |
125 | ||
5e548861 PB |
126 | if (show > 0) |
127 | CHECK_TYPEDEF (type); | |
128 | ||
a8a69e63 FF |
129 | c_type_print_base (type, stream, show, level); |
130 | code = TYPE_CODE (type); | |
131 | if ((varstring != NULL && *varstring != '\0') | |
132 | || | |
133 | /* Need a space if going to print stars or brackets; | |
134 | but not if we will print just a type name. */ | |
135 | ((show > 0 || TYPE_NAME (type) == 0) | |
136 | && | |
137 | (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC | |
138 | || code == TYPE_CODE_METHOD | |
139 | || code == TYPE_CODE_ARRAY | |
140 | || code == TYPE_CODE_MEMBER | |
141 | || code == TYPE_CODE_REF))) | |
142 | fputs_filtered (" ", stream); | |
143 | c_type_print_varspec_prefix (type, stream, show, 0); | |
144 | ||
433732f2 SG |
145 | if (varstring != NULL) |
146 | { | |
147 | fputs_filtered (varstring, stream); | |
a8a69e63 | 148 | |
433732f2 SG |
149 | /* For demangled function names, we have the arglist as part of the name, |
150 | so don't print an additional pair of ()'s */ | |
a8a69e63 | 151 | |
433732f2 SG |
152 | demangled_args = strchr(varstring, '(') != NULL; |
153 | c_type_print_varspec_suffix (type, stream, show, 0, demangled_args); | |
154 | } | |
a8a69e63 | 155 | } |
a8a69e63 FF |
156 | |
157 | /* If TYPE is a derived type, then print out derivation information. | |
158 | Print only the actual base classes of this type, not the base classes | |
159 | of the base classes. I.E. for the derivation hierarchy: | |
160 | ||
161 | class A { int a; }; | |
162 | class B : public A {int b; }; | |
163 | class C : public B {int c; }; | |
164 | ||
165 | Print the type of class C as: | |
166 | ||
167 | class C : public B { | |
168 | int c; | |
169 | } | |
170 | ||
171 | Not as the following (like gdb used to), which is not legal C++ syntax for | |
172 | derived types and may be confused with the multiple inheritance form: | |
173 | ||
174 | class C : public B : public A { | |
175 | int c; | |
176 | } | |
177 | ||
178 | In general, gdb should try to print the types as closely as possible to | |
65b07ddc DT |
179 | the form that they appear in the source code. |
180 | Note that in case of protected derivation gcc will not say 'protected' | |
181 | but 'private'. The HP's aCC compiler emits specific information for | |
182 | derivation via protected inheritance, so gdb can print it out */ | |
a8a69e63 FF |
183 | |
184 | static void | |
185 | cp_type_print_derivation_info (stream, type) | |
199b2450 | 186 | GDB_FILE *stream; |
a8a69e63 FF |
187 | struct type *type; |
188 | { | |
189 | char *name; | |
190 | int i; | |
191 | ||
192 | for (i = 0; i < TYPE_N_BASECLASSES (type); i++) | |
193 | { | |
194 | fputs_filtered (i == 0 ? ": " : ", ", stream); | |
195 | fprintf_filtered (stream, "%s%s ", | |
65b07ddc DT |
196 | BASETYPE_VIA_PUBLIC (type, i) ? "public" |
197 | : (TYPE_FIELD_PROTECTED (type, i) ? "protected" : "private"), | |
a8a69e63 FF |
198 | BASETYPE_VIA_VIRTUAL(type, i) ? " virtual" : ""); |
199 | name = type_name_no_tag (TYPE_BASECLASS (type, i)); | |
200 | fprintf_filtered (stream, "%s", name ? name : "(null)"); | |
201 | } | |
202 | if (i > 0) | |
203 | { | |
204 | fputs_filtered (" ", stream); | |
205 | } | |
206 | } | |
65b07ddc DT |
207 | /* Print the C++ method arguments ARGS to the file STREAM. */ |
208 | ||
209 | void | |
210 | cp_type_print_method_args (args, prefix, varstring, staticp, stream) | |
211 | struct type **args; | |
212 | char *prefix; | |
213 | char *varstring; | |
214 | int staticp; | |
215 | GDB_FILE *stream; | |
216 | { | |
217 | int i; | |
218 | ||
219 | fprintf_symbol_filtered (stream, prefix, language_cplus, DMGL_ANSI); | |
220 | fprintf_symbol_filtered (stream, varstring, language_cplus, DMGL_ANSI); | |
221 | fputs_filtered ("(", stream); | |
222 | if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID) | |
223 | { | |
224 | i = !staticp; /* skip the class variable */ | |
225 | while (1) | |
226 | { | |
227 | type_print (args[i++], "", stream, 0); | |
228 | if (!args[i]) | |
229 | { | |
230 | fprintf_filtered (stream, " ..."); | |
231 | break; | |
232 | } | |
233 | else if (args[i]->code != TYPE_CODE_VOID) | |
234 | { | |
235 | fprintf_filtered (stream, ", "); | |
236 | } | |
237 | else break; | |
238 | } | |
239 | } | |
240 | else if (current_language->la_language == language_cplus) | |
241 | { | |
242 | fprintf_filtered (stream, "void"); | |
243 | } | |
244 | ||
245 | fprintf_filtered (stream, ")"); | |
246 | } | |
247 | ||
a8a69e63 FF |
248 | |
249 | /* Print any asterisks or open-parentheses needed before the | |
250 | variable name (to describe its type). | |
251 | ||
252 | On outermost call, pass 0 for PASSED_A_PTR. | |
253 | On outermost call, SHOW > 0 means should ignore | |
254 | any typename for TYPE and show its details. | |
255 | SHOW is always zero on recursive calls. */ | |
256 | ||
257 | void | |
258 | c_type_print_varspec_prefix (type, stream, show, passed_a_ptr) | |
259 | struct type *type; | |
199b2450 | 260 | GDB_FILE *stream; |
a8a69e63 FF |
261 | int show; |
262 | int passed_a_ptr; | |
263 | { | |
264 | char *name; | |
265 | if (type == 0) | |
266 | return; | |
267 | ||
268 | if (TYPE_NAME (type) && show <= 0) | |
269 | return; | |
270 | ||
271 | QUIT; | |
272 | ||
273 | switch (TYPE_CODE (type)) | |
274 | { | |
275 | case TYPE_CODE_PTR: | |
276 | c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1); | |
277 | fprintf_filtered (stream, "*"); | |
65b07ddc | 278 | c_type_print_cv_qualifier (type, stream, 1, 0); |
a8a69e63 FF |
279 | break; |
280 | ||
281 | case TYPE_CODE_MEMBER: | |
282 | if (passed_a_ptr) | |
283 | fprintf_filtered (stream, "("); | |
284 | c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0); | |
285 | fprintf_filtered (stream, " "); | |
286 | name = type_name_no_tag (TYPE_DOMAIN_TYPE (type)); | |
287 | if (name) | |
288 | fputs_filtered (name, stream); | |
289 | else | |
290 | c_type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, passed_a_ptr); | |
291 | fprintf_filtered (stream, "::"); | |
292 | break; | |
293 | ||
294 | case TYPE_CODE_METHOD: | |
295 | if (passed_a_ptr) | |
a46d92a7 | 296 | fprintf_filtered (stream, "("); |
a8a69e63 FF |
297 | c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0); |
298 | if (passed_a_ptr) | |
299 | { | |
300 | fprintf_filtered (stream, " "); | |
301 | c_type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, passed_a_ptr); | |
302 | fprintf_filtered (stream, "::"); | |
303 | } | |
304 | break; | |
305 | ||
306 | case TYPE_CODE_REF: | |
307 | c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1); | |
308 | fprintf_filtered (stream, "&"); | |
65b07ddc | 309 | c_type_print_cv_qualifier (type, stream, 1, 0); |
a8a69e63 FF |
310 | break; |
311 | ||
312 | case TYPE_CODE_FUNC: | |
313 | c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0); | |
314 | if (passed_a_ptr) | |
315 | fprintf_filtered (stream, "("); | |
316 | break; | |
317 | ||
318 | case TYPE_CODE_ARRAY: | |
319 | c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0); | |
320 | if (passed_a_ptr) | |
321 | fprintf_filtered (stream, "("); | |
322 | break; | |
323 | ||
324 | case TYPE_CODE_UNDEF: | |
325 | case TYPE_CODE_STRUCT: | |
326 | case TYPE_CODE_UNION: | |
327 | case TYPE_CODE_ENUM: | |
328 | case TYPE_CODE_INT: | |
329 | case TYPE_CODE_FLT: | |
330 | case TYPE_CODE_VOID: | |
331 | case TYPE_CODE_ERROR: | |
332 | case TYPE_CODE_CHAR: | |
333 | case TYPE_CODE_BOOL: | |
334 | case TYPE_CODE_SET: | |
335 | case TYPE_CODE_RANGE: | |
c4413e2c | 336 | case TYPE_CODE_STRING: |
72cd0384 | 337 | case TYPE_CODE_BITSTRING: |
22d7f91e | 338 | case TYPE_CODE_COMPLEX: |
5e548861 | 339 | case TYPE_CODE_TYPEDEF: |
a8a69e63 FF |
340 | /* These types need no prefix. They are listed here so that |
341 | gcc -Wall will reveal any types that haven't been handled. */ | |
342 | break; | |
343 | } | |
344 | } | |
345 | ||
65b07ddc DT |
346 | /* Print out "const" and "volatile" attributes. |
347 | TYPE is a pointer to the type being printed out. | |
348 | STREAM is the output destination. | |
349 | NEED_SPACE = 1 indicates an initial white space is needed */ | |
350 | ||
351 | static void | |
352 | c_type_print_cv_qualifier (type, stream, need_pre_space, need_post_space) | |
353 | struct type *type; | |
354 | GDB_FILE *stream; | |
355 | int need_pre_space; | |
356 | int need_post_space; | |
357 | { | |
358 | int flag = 0; | |
359 | ||
360 | if (TYPE_CONST (type)) | |
361 | { | |
362 | if (need_pre_space) | |
363 | fprintf_filtered (stream, " "); | |
364 | fprintf_filtered (stream, "const"); | |
365 | flag = 1; | |
366 | } | |
367 | ||
368 | if (TYPE_VOLATILE (type)) | |
369 | { | |
370 | if (flag || need_pre_space) | |
371 | fprintf_filtered (stream, " "); | |
372 | fprintf_filtered (stream, "volatile"); | |
373 | flag = 1; | |
374 | } | |
375 | ||
376 | if (flag && need_post_space) | |
377 | fprintf_filtered (stream, " "); | |
378 | } | |
379 | ||
380 | ||
381 | ||
382 | ||
a8a69e63 FF |
383 | static void |
384 | c_type_print_args (type, stream) | |
385 | struct type *type; | |
199b2450 | 386 | GDB_FILE *stream; |
a8a69e63 FF |
387 | { |
388 | int i; | |
389 | struct type **args; | |
390 | ||
391 | fprintf_filtered (stream, "("); | |
392 | args = TYPE_ARG_TYPES (type); | |
393 | if (args != NULL) | |
394 | { | |
395 | if (args[1] == NULL) | |
396 | { | |
397 | fprintf_filtered (stream, "..."); | |
398 | } | |
65b07ddc DT |
399 | else if ((args[1]->code == TYPE_CODE_VOID) && |
400 | (current_language->la_language == language_cplus)) | |
401 | { | |
402 | fprintf_filtered (stream, "void"); | |
403 | } | |
a8a69e63 FF |
404 | else |
405 | { | |
406 | for (i = 1; | |
407 | args[i] != NULL && args[i]->code != TYPE_CODE_VOID; | |
408 | i++) | |
409 | { | |
410 | c_print_type (args[i], "", stream, -1, 0); | |
411 | if (args[i+1] == NULL) | |
412 | { | |
413 | fprintf_filtered (stream, "..."); | |
414 | } | |
415 | else if (args[i+1]->code != TYPE_CODE_VOID) | |
416 | { | |
417 | fprintf_filtered (stream, ","); | |
418 | wrap_here (" "); | |
419 | } | |
420 | } | |
421 | } | |
422 | } | |
65b07ddc DT |
423 | else if (current_language->la_language == language_cplus) |
424 | { | |
425 | fprintf_filtered (stream, "void"); | |
426 | } | |
427 | ||
a8a69e63 FF |
428 | fprintf_filtered (stream, ")"); |
429 | } | |
430 | ||
431 | /* Print any array sizes, function arguments or close parentheses | |
432 | needed after the variable name (to describe its type). | |
433 | Args work like c_type_print_varspec_prefix. */ | |
434 | ||
435 | static void | |
436 | c_type_print_varspec_suffix (type, stream, show, passed_a_ptr, demangled_args) | |
437 | struct type *type; | |
199b2450 | 438 | GDB_FILE *stream; |
a8a69e63 FF |
439 | int show; |
440 | int passed_a_ptr; | |
441 | int demangled_args; | |
442 | { | |
443 | if (type == 0) | |
444 | return; | |
445 | ||
446 | if (TYPE_NAME (type) && show <= 0) | |
447 | return; | |
448 | ||
449 | QUIT; | |
450 | ||
451 | switch (TYPE_CODE (type)) | |
452 | { | |
453 | case TYPE_CODE_ARRAY: | |
454 | if (passed_a_ptr) | |
455 | fprintf_filtered (stream, ")"); | |
456 | ||
457 | fprintf_filtered (stream, "["); | |
fda36387 PB |
458 | if (TYPE_LENGTH (type) >= 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0 |
459 | && TYPE_ARRAY_UPPER_BOUND_TYPE(type) != BOUND_CANNOT_BE_DETERMINED) | |
a8a69e63 FF |
460 | fprintf_filtered (stream, "%d", |
461 | (TYPE_LENGTH (type) | |
462 | / TYPE_LENGTH (TYPE_TARGET_TYPE (type)))); | |
463 | fprintf_filtered (stream, "]"); | |
464 | ||
465 | c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0); | |
466 | break; | |
467 | ||
468 | case TYPE_CODE_MEMBER: | |
469 | if (passed_a_ptr) | |
470 | fprintf_filtered (stream, ")"); | |
471 | c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0); | |
472 | break; | |
473 | ||
474 | case TYPE_CODE_METHOD: | |
475 | if (passed_a_ptr) | |
476 | fprintf_filtered (stream, ")"); | |
477 | c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0); | |
478 | if (passed_a_ptr) | |
479 | { | |
480 | c_type_print_args (type, stream); | |
481 | } | |
482 | break; | |
483 | ||
484 | case TYPE_CODE_PTR: | |
485 | case TYPE_CODE_REF: | |
486 | c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0); | |
487 | break; | |
488 | ||
489 | case TYPE_CODE_FUNC: | |
a8a69e63 FF |
490 | if (passed_a_ptr) |
491 | fprintf_filtered (stream, ")"); | |
492 | if (!demangled_args) | |
27202b6a PB |
493 | { int i, len = TYPE_NFIELDS (type); |
494 | fprintf_filtered (stream, "("); | |
65b07ddc DT |
495 | if ((len == 0) && (current_language->la_language == language_cplus)) |
496 | { | |
497 | fprintf_filtered (stream, "void"); | |
498 | } | |
499 | else | |
500 | for (i = 0; i < len; i++) | |
501 | { | |
502 | if (i > 0) | |
503 | { | |
504 | fputs_filtered (", ", stream); | |
505 | wrap_here (" "); | |
506 | } | |
507 | c_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0); | |
508 | } | |
27202b6a PB |
509 | fprintf_filtered (stream, ")"); |
510 | } | |
dac317dc JK |
511 | c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, |
512 | passed_a_ptr, 0); | |
a8a69e63 FF |
513 | break; |
514 | ||
515 | case TYPE_CODE_UNDEF: | |
516 | case TYPE_CODE_STRUCT: | |
517 | case TYPE_CODE_UNION: | |
518 | case TYPE_CODE_ENUM: | |
519 | case TYPE_CODE_INT: | |
520 | case TYPE_CODE_FLT: | |
521 | case TYPE_CODE_VOID: | |
522 | case TYPE_CODE_ERROR: | |
523 | case TYPE_CODE_CHAR: | |
524 | case TYPE_CODE_BOOL: | |
525 | case TYPE_CODE_SET: | |
526 | case TYPE_CODE_RANGE: | |
c4413e2c | 527 | case TYPE_CODE_STRING: |
72cd0384 | 528 | case TYPE_CODE_BITSTRING: |
22d7f91e | 529 | case TYPE_CODE_COMPLEX: |
5e548861 | 530 | case TYPE_CODE_TYPEDEF: |
a8a69e63 FF |
531 | /* These types do not need a suffix. They are listed so that |
532 | gcc -Wall will report types that may not have been considered. */ | |
533 | break; | |
534 | } | |
535 | } | |
536 | ||
537 | /* Print the name of the type (or the ultimate pointer target, | |
538 | function value or array element), or the description of a | |
539 | structure or union. | |
540 | ||
875fc229 JK |
541 | SHOW positive means print details about the type (e.g. enum values), |
542 | and print structure elements passing SHOW - 1 for show. | |
0e4ad984 | 543 | SHOW negative means just print the type name or struct tag if there is one. |
875fc229 JK |
544 | If there is no name, print something sensible but concise like |
545 | "struct {...}". | |
0e4ad984 JK |
546 | SHOW zero means just print the type name or struct tag if there is one. |
547 | If there is no name, print something sensible but not as concise like | |
548 | "struct {int x; int y;}". | |
875fc229 JK |
549 | |
550 | LEVEL is the number of spaces to indent by. | |
a8a69e63 FF |
551 | We increase it for some recursive calls. */ |
552 | ||
553 | void | |
554 | c_type_print_base (type, stream, show, level) | |
555 | struct type *type; | |
199b2450 | 556 | GDB_FILE *stream; |
a8a69e63 FF |
557 | int show; |
558 | int level; | |
559 | { | |
a8a69e63 FF |
560 | register int i; |
561 | register int len; | |
562 | register int lastval; | |
563 | char *mangled_name; | |
564 | char *demangled_name; | |
65b07ddc | 565 | char *demangled_no_static; |
a8a69e63 | 566 | enum {s_none, s_public, s_private, s_protected} section_type; |
65b07ddc DT |
567 | int need_access_label = 0; |
568 | int j, len2; | |
569 | ||
a8a69e63 FF |
570 | QUIT; |
571 | ||
572 | wrap_here (" "); | |
573 | if (type == NULL) | |
574 | { | |
575 | fputs_filtered ("<type unknown>", stream); | |
576 | return; | |
577 | } | |
578 | ||
579 | /* When SHOW is zero or less, and there is a valid type name, then always | |
b2bebdb0 JK |
580 | just print the type name directly from the type. */ |
581 | /* If we have "typedef struct foo {. . .} bar;" do we want to print it | |
582 | as "struct foo" or as "bar"? Pick the latter, because C++ folk tend | |
583 | to expect things like "class5 *foo" rather than "struct class5 *foo". */ | |
a8a69e63 | 584 | |
b2bebdb0 JK |
585 | if (show <= 0 |
586 | && TYPE_NAME (type) != NULL) | |
a8a69e63 | 587 | { |
65b07ddc | 588 | c_type_print_cv_qualifier (type, stream, 0, 1); |
a8a69e63 FF |
589 | fputs_filtered (TYPE_NAME (type), stream); |
590 | return; | |
591 | } | |
592 | ||
5e548861 | 593 | CHECK_TYPEDEF (type); |
dda398c3 | 594 | |
a8a69e63 FF |
595 | switch (TYPE_CODE (type)) |
596 | { | |
5e548861 | 597 | case TYPE_CODE_TYPEDEF: |
a8a69e63 FF |
598 | case TYPE_CODE_ARRAY: |
599 | case TYPE_CODE_PTR: | |
600 | case TYPE_CODE_MEMBER: | |
601 | case TYPE_CODE_REF: | |
602 | case TYPE_CODE_FUNC: | |
603 | case TYPE_CODE_METHOD: | |
604 | c_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level); | |
605 | break; | |
606 | ||
607 | case TYPE_CODE_STRUCT: | |
65b07ddc DT |
608 | c_type_print_cv_qualifier (type, stream, 0, 1); |
609 | /* Note TYPE_CODE_STRUCT and TYPE_CODE_CLASS have the same value, | |
610 | * so we use another means for distinguishing them. | |
611 | */ | |
612 | if (HAVE_CPLUS_STRUCT (type)) { | |
613 | switch (TYPE_DECLARED_TYPE(type)) { | |
614 | case DECLARED_TYPE_CLASS: | |
615 | fprintf_filtered (stream, "class "); | |
616 | break; | |
617 | case DECLARED_TYPE_UNION: | |
618 | fprintf_filtered (stream, "union "); | |
619 | break; | |
620 | case DECLARED_TYPE_STRUCT: | |
621 | fprintf_filtered (stream, "struct "); | |
622 | break; | |
623 | default: | |
624 | /* If there is a CPLUS_STRUCT, assume class if not | |
625 | * otherwise specified in the declared_type field. | |
626 | */ | |
627 | fprintf_filtered (stream, "class "); | |
628 | break; | |
629 | } /* switch */ | |
630 | } else { | |
631 | /* If not CPLUS_STRUCT, then assume it's a C struct */ | |
632 | fprintf_filtered (stream, "struct "); | |
633 | } | |
a8a69e63 FF |
634 | goto struct_union; |
635 | ||
636 | case TYPE_CODE_UNION: | |
65b07ddc | 637 | c_type_print_cv_qualifier (type, stream, 0, 1); |
a8a69e63 | 638 | fprintf_filtered (stream, "union "); |
b2bebdb0 JK |
639 | |
640 | struct_union: | |
65b07ddc DT |
641 | |
642 | /* Print the tag if it exists. | |
643 | * The HP aCC compiler emits | |
644 | * a spurious "{unnamed struct}"/"{unnamed union}"/"{unnamed enum}" | |
645 | * tag for unnamed struct/union/enum's, which we don't | |
646 | * want to print. | |
647 | */ | |
648 | if (TYPE_TAG_NAME (type) != NULL && | |
649 | strncmp(TYPE_TAG_NAME(type), "{unnamed", 8)) | |
8789d972 | 650 | { |
b2bebdb0 JK |
651 | fputs_filtered (TYPE_TAG_NAME (type), stream); |
652 | if (show > 0) | |
653 | fputs_filtered (" ", stream); | |
8789d972 | 654 | } |
8789d972 | 655 | wrap_here (" "); |
0e4ad984 | 656 | if (show < 0) |
b2bebdb0 JK |
657 | { |
658 | /* If we just printed a tag name, no need to print anything else. */ | |
659 | if (TYPE_TAG_NAME (type) == NULL) | |
660 | fprintf_filtered (stream, "{...}"); | |
661 | } | |
0e4ad984 | 662 | else if (show > 0 || TYPE_TAG_NAME (type) == NULL) |
a8a69e63 | 663 | { |
a8a69e63 FF |
664 | cp_type_print_derivation_info (stream, type); |
665 | ||
666 | fprintf_filtered (stream, "{\n"); | |
667 | if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0)) | |
668 | { | |
669 | if (TYPE_FLAGS (type) & TYPE_FLAG_STUB) | |
670 | fprintfi_filtered (level + 4, stream, "<incomplete type>\n"); | |
671 | else | |
672 | fprintfi_filtered (level + 4, stream, "<no data fields>\n"); | |
673 | } | |
674 | ||
675 | /* Start off with no specific section type, so we can print | |
676 | one for the first field we find, and use that section type | |
677 | thereafter until we find another type. */ | |
678 | ||
679 | section_type = s_none; | |
680 | ||
65b07ddc DT |
681 | /* For a class, if all members are private, there's no need |
682 | for a "private:" label; similarly, for a struct or union | |
683 | masquerading as a class, if all members are public, there's | |
684 | no need for a "public:" label. */ | |
685 | ||
686 | if ((TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_CLASS) || | |
687 | (TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_TEMPLATE)) | |
688 | { | |
689 | QUIT; | |
690 | len = TYPE_NFIELDS (type); | |
691 | for (i = TYPE_N_BASECLASSES (type); i < len; i++) | |
692 | if (!TYPE_FIELD_PRIVATE (type, i)) | |
693 | { | |
694 | need_access_label = 1; | |
695 | break; | |
696 | } | |
697 | QUIT; | |
698 | if (!need_access_label) | |
699 | { | |
700 | len2 = TYPE_NFN_FIELDS (type); | |
701 | for (j = 0; j < len2; j++) | |
702 | { | |
703 | len = TYPE_FN_FIELDLIST_LENGTH (type, j); | |
704 | for (i = 0; i < len; i++) | |
705 | if (!TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type, j), i)) | |
706 | { | |
707 | need_access_label = 1; | |
708 | break; | |
709 | } | |
710 | if (need_access_label) | |
711 | break; | |
712 | } | |
713 | } | |
714 | } | |
715 | else if ((TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_STRUCT) || | |
716 | (TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_UNION)) | |
717 | { | |
718 | QUIT; | |
719 | len = TYPE_NFIELDS (type); | |
720 | for (i = TYPE_N_BASECLASSES (type); i < len; i++) | |
721 | if (TYPE_FIELD_PRIVATE (type, i) || TYPE_FIELD_PROTECTED (type, i)) | |
722 | { | |
723 | need_access_label = 1; | |
724 | break; | |
725 | } | |
726 | QUIT; | |
727 | if (!need_access_label) | |
728 | { | |
729 | len2 = TYPE_NFN_FIELDS (type); | |
730 | for (j = 0; j < len2; j++) | |
731 | { | |
732 | QUIT; | |
733 | len = TYPE_FN_FIELDLIST_LENGTH (type, j); | |
734 | for (i = 0; i < len; i++) | |
735 | if (TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type, j), i) || | |
736 | TYPE_FN_FIELD_PROTECTED (TYPE_FN_FIELDLIST1 (type, j), i)) | |
737 | { | |
738 | need_access_label = 1; | |
739 | break; | |
740 | } | |
741 | if (need_access_label) | |
742 | break; | |
743 | } | |
744 | } | |
745 | } | |
746 | ||
a8a69e63 FF |
747 | /* If there is a base class for this type, |
748 | do not print the field that it occupies. */ | |
749 | ||
750 | len = TYPE_NFIELDS (type); | |
751 | for (i = TYPE_N_BASECLASSES (type); i < len; i++) | |
752 | { | |
753 | QUIT; | |
754 | /* Don't print out virtual function table. */ | |
65b07ddc DT |
755 | /* HP ANSI C++ case */ |
756 | if (TYPE_HAS_VTABLE(type) && (STREQN (TYPE_FIELD_NAME (type, i), "__vfp", 5))) | |
757 | continue; | |
758 | /* Other compilers */ | |
759 | /* pai:: FIXME : check for has_vtable < 0 */ | |
81afee37 FF |
760 | if (STREQN (TYPE_FIELD_NAME (type, i), "_vptr", 5) |
761 | && is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5])) | |
a8a69e63 FF |
762 | continue; |
763 | ||
764 | /* If this is a C++ class we can print the various C++ section | |
765 | labels. */ | |
766 | ||
65b07ddc | 767 | if (HAVE_CPLUS_STRUCT (type) && need_access_label) |
a8a69e63 FF |
768 | { |
769 | if (TYPE_FIELD_PROTECTED (type, i)) | |
770 | { | |
771 | if (section_type != s_protected) | |
772 | { | |
773 | section_type = s_protected; | |
774 | fprintfi_filtered (level + 2, stream, | |
775 | "protected:\n"); | |
776 | } | |
777 | } | |
778 | else if (TYPE_FIELD_PRIVATE (type, i)) | |
779 | { | |
780 | if (section_type != s_private) | |
781 | { | |
782 | section_type = s_private; | |
783 | fprintfi_filtered (level + 2, stream, "private:\n"); | |
784 | } | |
785 | } | |
786 | else | |
787 | { | |
788 | if (section_type != s_public) | |
789 | { | |
790 | section_type = s_public; | |
791 | fprintfi_filtered (level + 2, stream, "public:\n"); | |
792 | } | |
793 | } | |
794 | } | |
795 | ||
796 | print_spaces_filtered (level + 4, stream); | |
797 | if (TYPE_FIELD_STATIC (type, i)) | |
798 | { | |
799 | fprintf_filtered (stream, "static "); | |
800 | } | |
801 | c_print_type (TYPE_FIELD_TYPE (type, i), | |
802 | TYPE_FIELD_NAME (type, i), | |
803 | stream, show - 1, level + 4); | |
804 | if (!TYPE_FIELD_STATIC (type, i) | |
805 | && TYPE_FIELD_PACKED (type, i)) | |
806 | { | |
807 | /* It is a bitfield. This code does not attempt | |
808 | to look at the bitpos and reconstruct filler, | |
809 | unnamed fields. This would lead to misleading | |
810 | results if the compiler does not put out fields | |
811 | for such things (I don't know what it does). */ | |
812 | fprintf_filtered (stream, " : %d", | |
813 | TYPE_FIELD_BITSIZE (type, i)); | |
814 | } | |
815 | fprintf_filtered (stream, ";\n"); | |
816 | } | |
817 | ||
818 | /* If there are both fields and methods, put a space between. */ | |
819 | len = TYPE_NFN_FIELDS (type); | |
820 | if (len && section_type != s_none) | |
821 | fprintf_filtered (stream, "\n"); | |
822 | ||
823 | /* C++: print out the methods */ | |
a8a69e63 FF |
824 | for (i = 0; i < len; i++) |
825 | { | |
826 | struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); | |
827 | int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i); | |
828 | char *method_name = TYPE_FN_FIELDLIST_NAME (type, i); | |
b2bebdb0 | 829 | char *name = type_name_no_tag (type); |
2e4964ad | 830 | int is_constructor = name && STREQ(method_name, name); |
a8a69e63 FF |
831 | for (j = 0; j < len2; j++) |
832 | { | |
4c664b8d PS |
833 | char *physname = TYPE_FN_FIELD_PHYSNAME (f, j); |
834 | int is_full_physname_constructor = | |
a46d92a7 PS |
835 | ((physname[0] == '_' && physname[1] == '_' |
836 | && strchr ("0123456789Qt", physname[2])) | |
837 | || STREQN (physname, "__ct__", 6) | |
838 | || DESTRUCTOR_PREFIX_P (physname) | |
839 | || STREQN (physname, "__dt__", 6)); | |
4c664b8d | 840 | |
a8a69e63 FF |
841 | QUIT; |
842 | if (TYPE_FN_FIELD_PROTECTED (f, j)) | |
843 | { | |
844 | if (section_type != s_protected) | |
845 | { | |
846 | section_type = s_protected; | |
847 | fprintfi_filtered (level + 2, stream, | |
848 | "protected:\n"); | |
849 | } | |
850 | } | |
851 | else if (TYPE_FN_FIELD_PRIVATE (f, j)) | |
852 | { | |
853 | if (section_type != s_private) | |
854 | { | |
855 | section_type = s_private; | |
856 | fprintfi_filtered (level + 2, stream, "private:\n"); | |
857 | } | |
858 | } | |
859 | else | |
860 | { | |
861 | if (section_type != s_public) | |
862 | { | |
863 | section_type = s_public; | |
864 | fprintfi_filtered (level + 2, stream, "public:\n"); | |
865 | } | |
866 | } | |
867 | ||
868 | print_spaces_filtered (level + 4, stream); | |
869 | if (TYPE_FN_FIELD_VIRTUAL_P (f, j)) | |
870 | fprintf_filtered (stream, "virtual "); | |
871 | else if (TYPE_FN_FIELD_STATIC_P (f, j)) | |
872 | fprintf_filtered (stream, "static "); | |
873 | if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0) | |
874 | { | |
875 | /* Keep GDB from crashing here. */ | |
a46d92a7 | 876 | fprintf_filtered (stream, "<undefined type> %s;\n", |
a8a69e63 FF |
877 | TYPE_FN_FIELD_PHYSNAME (f, j)); |
878 | break; | |
879 | } | |
65b07ddc DT |
880 | else if (!is_constructor && /* constructors don't have declared types */ |
881 | !is_full_physname_constructor && /* " " */ | |
882 | !strstr (method_name, "operator ")) /* Not a type conversion operator */ | |
883 | /* (note space -- other operators don't have it) */ | |
a8a69e63 FF |
884 | { |
885 | type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)), | |
84bdfea6 | 886 | "", stream, -1); |
a8a69e63 FF |
887 | fputs_filtered (" ", stream); |
888 | } | |
889 | if (TYPE_FN_FIELD_STUB (f, j)) | |
a46d92a7 PS |
890 | /* Build something we can demangle. */ |
891 | mangled_name = gdb_mangle_name (type, i, j); | |
892 | else | |
893 | mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j); | |
894 | ||
895 | demangled_name = | |
896 | cplus_demangle (mangled_name, | |
897 | DMGL_ANSI | DMGL_PARAMS); | |
898 | if (demangled_name == NULL) | |
a8a69e63 | 899 | { |
65b07ddc DT |
900 | /* in some cases (for instance with the HP demangling), |
901 | if a function has more than 10 arguments, | |
902 | the demangling will fail. | |
903 | Let's try to reconstruct the function signature from | |
904 | the symbol information */ | |
905 | if (!TYPE_FN_FIELD_STUB (f, j)) | |
906 | cp_type_print_method_args (TYPE_FN_FIELD_ARGS (f, j), "", | |
907 | method_name, | |
908 | TYPE_FN_FIELD_STATIC_P (f, j), | |
909 | stream); | |
4f9bddb4 | 910 | else |
65b07ddc DT |
911 | fprintf_filtered (stream, "<badly mangled name '%s'>", |
912 | mangled_name); | |
913 | } | |
914 | else | |
915 | { | |
916 | char *p; | |
917 | char *demangled_no_class = demangled_name; | |
918 | ||
919 | while (p = strchr (demangled_no_class, ':')) | |
a8a69e63 | 920 | { |
65b07ddc | 921 | demangled_no_class = p; |
a46d92a7 PS |
922 | if (*++demangled_no_class == ':') |
923 | ++demangled_no_class; | |
a8a69e63 | 924 | } |
65b07ddc DT |
925 | /* get rid of the static word appended by the demangler */ |
926 | p = strstr (demangled_no_class, " static"); | |
927 | if (p != NULL) | |
928 | { | |
929 | int length = p - demangled_no_class; | |
930 | demangled_no_static = (char *) xmalloc (length + 1); | |
931 | strncpy (demangled_no_static, demangled_no_class, length); | |
932 | *(demangled_no_static + length) = '\0'; | |
933 | fputs_filtered (demangled_no_static, stream); | |
934 | free (demangled_no_static); | |
935 | } | |
936 | else | |
937 | fputs_filtered (demangled_no_class, stream); | |
a46d92a7 | 938 | free (demangled_name); |
a8a69e63 | 939 | } |
a46d92a7 PS |
940 | |
941 | if (TYPE_FN_FIELD_STUB (f, j)) | |
942 | free (mangled_name); | |
a8a69e63 FF |
943 | |
944 | fprintf_filtered (stream, ";\n"); | |
945 | } | |
946 | } | |
947 | ||
65b07ddc DT |
948 | if (TYPE_LOCALTYPE_PTR (type) && show >= 0) |
949 | fprintfi_filtered (level, stream, " (Local at %s:%d)\n", | |
950 | TYPE_LOCALTYPE_FILE (type), | |
951 | TYPE_LOCALTYPE_LINE (type)); | |
952 | ||
a8a69e63 FF |
953 | fprintfi_filtered (level, stream, "}"); |
954 | } | |
65b07ddc DT |
955 | if (TYPE_CODE(type) == TYPE_CODE_TEMPLATE) |
956 | goto go_back; | |
a8a69e63 FF |
957 | break; |
958 | ||
959 | case TYPE_CODE_ENUM: | |
65b07ddc DT |
960 | c_type_print_cv_qualifier (type, stream, 0, 1); |
961 | /* HP C supports sized enums */ | |
962 | if (hp_som_som_object_present) | |
963 | switch (TYPE_LENGTH (type)) | |
964 | { | |
965 | case 1: | |
966 | fputs_filtered ("char ", stream); | |
967 | break; | |
968 | case 2: | |
969 | fputs_filtered ("short ", stream); | |
970 | break; | |
971 | default: | |
972 | break; | |
973 | } | |
974 | fprintf_filtered (stream, "enum "); | |
975 | /* Print the tag name if it exists. | |
976 | * Fix for CHFts22718 (RT): The aCC compiler emits | |
977 | * a spurious "{unnamed struct}"/"{unnamed union}"/"{unnamed enum}" | |
978 | * tag for unnamed struct/union/enum's, which we don't | |
979 | * want to print. | |
980 | */ | |
981 | if (TYPE_TAG_NAME (type) != NULL && | |
982 | strncmp(TYPE_TAG_NAME(type), "{unnamed", 8)) | |
a8a69e63 | 983 | { |
b2bebdb0 JK |
984 | fputs_filtered (TYPE_TAG_NAME (type), stream); |
985 | if (show > 0) | |
986 | fputs_filtered (" ", stream); | |
a8a69e63 | 987 | } |
8789d972 | 988 | |
a8a69e63 | 989 | wrap_here (" "); |
0e4ad984 | 990 | if (show < 0) |
b2bebdb0 JK |
991 | { |
992 | /* If we just printed a tag name, no need to print anything else. */ | |
993 | if (TYPE_TAG_NAME (type) == NULL) | |
994 | fprintf_filtered (stream, "{...}"); | |
995 | } | |
0e4ad984 | 996 | else if (show > 0 || TYPE_TAG_NAME (type) == NULL) |
a8a69e63 FF |
997 | { |
998 | fprintf_filtered (stream, "{"); | |
999 | len = TYPE_NFIELDS (type); | |
1000 | lastval = 0; | |
1001 | for (i = 0; i < len; i++) | |
1002 | { | |
1003 | QUIT; | |
1004 | if (i) fprintf_filtered (stream, ", "); | |
1005 | wrap_here (" "); | |
1006 | fputs_filtered (TYPE_FIELD_NAME (type, i), stream); | |
1007 | if (lastval != TYPE_FIELD_BITPOS (type, i)) | |
1008 | { | |
1009 | fprintf_filtered (stream, " = %d", TYPE_FIELD_BITPOS (type, i)); | |
1010 | lastval = TYPE_FIELD_BITPOS (type, i); | |
1011 | } | |
1012 | lastval++; | |
1013 | } | |
1014 | fprintf_filtered (stream, "}"); | |
1015 | } | |
1016 | break; | |
1017 | ||
1018 | case TYPE_CODE_VOID: | |
1019 | fprintf_filtered (stream, "void"); | |
1020 | break; | |
1021 | ||
1022 | case TYPE_CODE_UNDEF: | |
1023 | fprintf_filtered (stream, "struct <unknown>"); | |
1024 | break; | |
1025 | ||
1026 | case TYPE_CODE_ERROR: | |
1027 | fprintf_filtered (stream, "<unknown type>"); | |
1028 | break; | |
1029 | ||
1030 | case TYPE_CODE_RANGE: | |
1031 | /* This should not occur */ | |
1032 | fprintf_filtered (stream, "<range type>"); | |
1033 | break; | |
1034 | ||
65b07ddc DT |
1035 | case TYPE_CODE_TEMPLATE: |
1036 | /* Called on "ptype t" where "t" is a template. | |
1037 | * Prints the template header (with args), e.g.: | |
1038 | * template <class T1, class T2> class " | |
1039 | * and then merges with the struct/union/class code to | |
1040 | * print the rest of the definition. | |
1041 | */ | |
1042 | c_type_print_cv_qualifier (type, stream, 0, 1); | |
1043 | fprintf_filtered (stream, "template <"); | |
1044 | for (i = 0; i < TYPE_NTEMPLATE_ARGS(type); i++) { | |
1045 | struct template_arg templ_arg; | |
1046 | templ_arg = TYPE_TEMPLATE_ARG(type, i); | |
1047 | fprintf_filtered (stream, "class %s", templ_arg.name); | |
1048 | if (i < TYPE_NTEMPLATE_ARGS(type)-1) | |
1049 | fprintf_filtered (stream, ", "); | |
1050 | } | |
1051 | fprintf_filtered (stream, "> class "); | |
1052 | /* Yuck, factor this out to a subroutine so we can call | |
1053 | * it and return to the point marked with the "goback:" label... - RT | |
1054 | */ | |
1055 | goto struct_union; | |
1056 | go_back: | |
1057 | if (TYPE_NINSTANTIATIONS(type) > 0) { | |
1058 | fprintf_filtered (stream, "\ntemplate instantiations:\n"); | |
1059 | for (i = 0; i < TYPE_NINSTANTIATIONS(type); i++) { | |
1060 | fprintf_filtered(stream, " "); | |
1061 | c_type_print_base (TYPE_INSTANTIATION(type, i), stream, 0, level); | |
1062 | if (i < TYPE_NINSTANTIATIONS(type)-1) fprintf_filtered(stream, "\n"); | |
1063 | } | |
1064 | } | |
1065 | break; | |
1066 | ||
a8a69e63 FF |
1067 | default: |
1068 | /* Handle types not explicitly handled by the other cases, | |
1069 | such as fundamental types. For these, just print whatever | |
1070 | the type name is, as recorded in the type itself. If there | |
1071 | is no type name, then complain. */ | |
1072 | if (TYPE_NAME (type) != NULL) | |
1073 | { | |
65b07ddc | 1074 | c_type_print_cv_qualifier (type, stream, 0, 1); |
a8a69e63 FF |
1075 | fputs_filtered (TYPE_NAME (type), stream); |
1076 | } | |
1077 | else | |
1078 | { | |
fd09c963 JK |
1079 | /* At least for dump_symtab, it is important that this not be |
1080 | an error (). */ | |
1081 | fprintf_filtered (stream, "<invalid type code %d>", | |
1082 | TYPE_CODE (type)); | |
a8a69e63 FF |
1083 | } |
1084 | break; | |
1085 | } | |
1086 | } | |
1087 | ||
65b07ddc DT |
1088 | |
1089 | ||
1090 |