oops accidentally omitted from previous delta
[deliverable/binutils-gdb.git] / gdb / c-typeprint.c
CommitLineData
c906108c 1/* Support for printing C and C++ types for GDB, the GNU debugger.
0b302171
JB
2 Copyright (C) 1986, 1988-1989, 1991-1996, 1998-2003, 2006-2012 Free
3 Software Foundation, Inc.
c906108c 4
c5aa993b 5 This file is part of GDB.
c906108c 6
c5aa993b
JM
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
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
c5aa993b 10 (at your option) any later version.
c906108c 11
c5aa993b
JM
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.
c906108c 16
c5aa993b 17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
19
20#include "defs.h"
04ea0df1 21#include "gdb_obstack.h"
aff410f1 22#include "bfd.h" /* Binary File Description. */
c906108c
SS
23#include "symtab.h"
24#include "gdbtypes.h"
25#include "expression.h"
26#include "value.h"
27#include "gdbcore.h"
28#include "target.h"
c906108c
SS
29#include "language.h"
30#include "demangle.h"
31#include "c-lang.h"
32#include "typeprint.h"
015a42b4 33#include "cp-abi.h"
94af9270 34#include "jv-lang.h"
c906108c
SS
35#include "gdb_string.h"
36#include <errno.h>
c906108c 37
aff410f1
MS
38static void c_type_print_varspec_prefix (struct type *,
39 struct ui_file *,
40 int, int, int);
c906108c 41
aff410f1
MS
42/* Print "const", "volatile", or address space modifiers. */
43static void c_type_print_modifier (struct type *,
44 struct ui_file *,
47663de5 45 int, int);
c5aa993b 46\f
c906108c
SS
47/* LEVEL is the depth to indent lines by. */
48
49void
aff410f1
MS
50c_print_type (struct type *type,
51 const char *varstring,
52 struct ui_file *stream,
fba45db2 53 int show, int level)
c906108c 54{
52f0bd74 55 enum type_code code;
c906108c 56 int demangled_args;
9750e763 57 int need_post_space;
c906108c
SS
58
59 if (show > 0)
60 CHECK_TYPEDEF (type);
61
62 c_type_print_base (type, stream, show, level);
63 code = TYPE_CODE (type);
64 if ((varstring != NULL && *varstring != '\0')
c5aa993b
JM
65 /* Need a space if going to print stars or brackets;
66 but not if we will print just a type name. */
5aafa1cc
PM
67 || ((show > 0 || TYPE_NAME (type) == 0)
68 && (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC
69 || code == TYPE_CODE_METHOD
70 || code == TYPE_CODE_ARRAY
71 || code == TYPE_CODE_MEMBERPTR
72 || code == TYPE_CODE_METHODPTR
73 || code == TYPE_CODE_REF)))
c906108c 74 fputs_filtered (" ", stream);
9750e763
KB
75 need_post_space = (varstring != NULL && strcmp (varstring, "") != 0);
76 c_type_print_varspec_prefix (type, stream, show, 0, need_post_space);
c906108c
SS
77
78 if (varstring != NULL)
79 {
80 fputs_filtered (varstring, stream);
81
aff410f1 82 /* For demangled function names, we have the arglist as part of
0963b4bd 83 the name, so don't print an additional pair of ()'s. */
c906108c 84
c5aa993b 85 demangled_args = strchr (varstring, '(') != NULL;
aff410f1
MS
86 c_type_print_varspec_suffix (type, stream, show,
87 0, demangled_args);
c906108c
SS
88 }
89}
c5aa993b 90
5c6ce71d
TT
91/* Print a typedef using C syntax. TYPE is the underlying type.
92 NEW_SYMBOL is the symbol naming the type. STREAM is the stream on
93 which to print. */
94
95void
aff410f1
MS
96c_print_typedef (struct type *type,
97 struct symbol *new_symbol,
5c6ce71d
TT
98 struct ui_file *stream)
99{
100 CHECK_TYPEDEF (type);
101 fprintf_filtered (stream, "typedef ");
102 type_print (type, "", stream, 0);
103 if (TYPE_NAME ((SYMBOL_TYPE (new_symbol))) == 0
104 || strcmp (TYPE_NAME ((SYMBOL_TYPE (new_symbol))),
b1d61bc9
PM
105 SYMBOL_LINKAGE_NAME (new_symbol)) != 0
106 || TYPE_CODE (SYMBOL_TYPE (new_symbol)) == TYPE_CODE_TYPEDEF)
5c6ce71d
TT
107 fprintf_filtered (stream, " %s", SYMBOL_PRINT_NAME (new_symbol));
108 fprintf_filtered (stream, ";\n");
109}
110
c906108c 111/* If TYPE is a derived type, then print out derivation information.
aff410f1
MS
112 Print only the actual base classes of this type, not the base
113 classes of the base classes. I.e. for the derivation hierarchy:
c906108c 114
c5aa993b
JM
115 class A { int a; };
116 class B : public A {int b; };
117 class C : public B {int c; };
c906108c
SS
118
119 Print the type of class C as:
120
c5aa993b
JM
121 class C : public B {
122 int c;
123 }
c906108c 124
aff410f1
MS
125 Not as the following (like gdb used to), which is not legal C++
126 syntax for derived types and may be confused with the multiple
127 inheritance form:
c906108c 128
c5aa993b
JM
129 class C : public B : public A {
130 int c;
131 }
c906108c 132
aff410f1 133 In general, gdb should try to print the types as closely as
62a49610 134 possible to the form that they appear in the source code. */
c906108c
SS
135
136static void
aff410f1
MS
137cp_type_print_derivation_info (struct ui_file *stream,
138 struct type *type)
c906108c 139{
0d5cff50 140 const char *name;
c906108c
SS
141 int i;
142
143 for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
144 {
145 fputs_filtered (i == 0 ? ": " : ", ", stream);
146 fprintf_filtered (stream, "%s%s ",
aff410f1
MS
147 BASETYPE_VIA_PUBLIC (type, i)
148 ? "public" : (TYPE_FIELD_PROTECTED (type, i)
149 ? "protected" : "private"),
c5aa993b 150 BASETYPE_VIA_VIRTUAL (type, i) ? " virtual" : "");
c906108c
SS
151 name = type_name_no_tag (TYPE_BASECLASS (type, i));
152 fprintf_filtered (stream, "%s", name ? name : "(null)");
153 }
154 if (i > 0)
155 {
156 fputs_filtered (" ", stream);
157 }
158}
ad2f7632 159
c906108c 160/* Print the C++ method arguments ARGS to the file STREAM. */
c5aa993b 161
392a587b 162static void
0d5cff50
DE
163cp_type_print_method_args (struct type *mtype, const char *prefix,
164 const char *varstring, int staticp,
aff410f1 165 struct ui_file *stream)
c906108c 166{
ad2f7632
DJ
167 struct field *args = TYPE_FIELDS (mtype);
168 int nargs = TYPE_NFIELDS (mtype);
169 int varargs = TYPE_VARARGS (mtype);
c906108c 170 int i;
c5aa993b 171
aff410f1
MS
172 fprintf_symbol_filtered (stream, prefix,
173 language_cplus, DMGL_ANSI);
174 fprintf_symbol_filtered (stream, varstring,
175 language_cplus, DMGL_ANSI);
c906108c 176 fputs_filtered ("(", stream);
ad2f7632
DJ
177
178 /* Skip the class variable. */
179 i = staticp ? 0 : 1;
180 if (nargs > i)
c906108c 181 {
ad2f7632 182 while (i < nargs)
c5aa993b 183 {
ad2f7632
DJ
184 type_print (args[i++].type, "", stream, 0);
185
186 if (i == nargs && varargs)
187 fprintf_filtered (stream, ", ...");
188 else if (i < nargs)
189 fprintf_filtered (stream, ", ");
c5aa993b 190 }
c906108c 191 }
ad2f7632
DJ
192 else if (varargs)
193 fprintf_filtered (stream, "...");
c906108c 194 else if (current_language->la_language == language_cplus)
ad2f7632 195 fprintf_filtered (stream, "void");
c5aa993b 196
c906108c 197 fprintf_filtered (stream, ")");
94af9270
KS
198
199 /* For non-static methods, read qualifiers from the type of
200 THIS. */
201 if (!staticp)
202 {
203 struct type *domain;
204
205 gdb_assert (nargs > 0);
206 gdb_assert (TYPE_CODE (args[0].type) == TYPE_CODE_PTR);
207 domain = TYPE_TARGET_TYPE (args[0].type);
208
209 if (TYPE_CONST (domain))
210 fprintf_filtered (stream, " const");
211
212 if (TYPE_VOLATILE (domain))
213 fprintf_filtered (stream, " volatile");
214 }
c906108c
SS
215}
216
217
218/* Print any asterisks or open-parentheses needed before the
219 variable name (to describe its type).
220
221 On outermost call, pass 0 for PASSED_A_PTR.
222 On outermost call, SHOW > 0 means should ignore
223 any typename for TYPE and show its details.
9750e763
KB
224 SHOW is always zero on recursive calls.
225
226 NEED_POST_SPACE is non-zero when a space will be be needed
227 between a trailing qualifier and a field, variable, or function
228 name. */
c906108c 229
a737a51b 230static void
aff410f1
MS
231c_type_print_varspec_prefix (struct type *type,
232 struct ui_file *stream,
233 int show, int passed_a_ptr,
234 int need_post_space)
c906108c 235{
0d5cff50 236 const char *name;
c5504eaf 237
c906108c
SS
238 if (type == 0)
239 return;
240
241 if (TYPE_NAME (type) && show <= 0)
242 return;
243
244 QUIT;
245
246 switch (TYPE_CODE (type))
247 {
248 case TYPE_CODE_PTR:
aff410f1
MS
249 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
250 stream, show, 1, 1);
c906108c 251 fprintf_filtered (stream, "*");
9750e763 252 c_type_print_modifier (type, stream, 1, need_post_space);
c906108c
SS
253 break;
254
0d5de010 255 case TYPE_CODE_MEMBERPTR:
aff410f1
MS
256 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
257 stream, show, 0, 0);
c906108c
SS
258 name = type_name_no_tag (TYPE_DOMAIN_TYPE (type));
259 if (name)
260 fputs_filtered (name, stream);
261 else
aff410f1 262 c_type_print_base (TYPE_DOMAIN_TYPE (type),
e5afdbd7 263 stream, -1, passed_a_ptr);
0d5de010 264 fprintf_filtered (stream, "::*");
c906108c
SS
265 break;
266
0d5de010 267 case TYPE_CODE_METHODPTR:
aff410f1
MS
268 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
269 stream, show, 0, 0);
0d5de010
DJ
270 fprintf_filtered (stream, "(");
271 name = type_name_no_tag (TYPE_DOMAIN_TYPE (type));
272 if (name)
273 fputs_filtered (name, stream);
274 else
aff410f1 275 c_type_print_base (TYPE_DOMAIN_TYPE (type),
e5afdbd7 276 stream, -1, passed_a_ptr);
0d5de010 277 fprintf_filtered (stream, "::*");
c906108c
SS
278 break;
279
280 case TYPE_CODE_REF:
aff410f1
MS
281 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
282 stream, show, 1, 0);
c906108c 283 fprintf_filtered (stream, "&");
9750e763 284 c_type_print_modifier (type, stream, 1, need_post_space);
c906108c
SS
285 break;
286
0d5de010 287 case TYPE_CODE_METHOD:
c906108c 288 case TYPE_CODE_FUNC:
aff410f1
MS
289 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
290 stream, show, 0, 0);
c906108c
SS
291 if (passed_a_ptr)
292 fprintf_filtered (stream, "(");
293 break;
294
295 case TYPE_CODE_ARRAY:
aff410f1
MS
296 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
297 stream, show, 0, 0);
c906108c
SS
298 if (passed_a_ptr)
299 fprintf_filtered (stream, "(");
300 break;
301
248f8055 302 case TYPE_CODE_TYPEDEF:
aff410f1 303 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
350b1b26 304 stream, show, passed_a_ptr, 0);
248f8055
DJ
305 break;
306
c906108c
SS
307 case TYPE_CODE_UNDEF:
308 case TYPE_CODE_STRUCT:
309 case TYPE_CODE_UNION:
310 case TYPE_CODE_ENUM:
311 case TYPE_CODE_INT:
312 case TYPE_CODE_FLT:
313 case TYPE_CODE_VOID:
314 case TYPE_CODE_ERROR:
315 case TYPE_CODE_CHAR:
316 case TYPE_CODE_BOOL:
317 case TYPE_CODE_SET:
318 case TYPE_CODE_RANGE:
319 case TYPE_CODE_STRING:
c906108c 320 case TYPE_CODE_COMPLEX:
5c4e30ca 321 case TYPE_CODE_NAMESPACE:
7678ef8f 322 case TYPE_CODE_DECFLOAT:
c906108c 323 /* These types need no prefix. They are listed here so that
c5aa993b 324 gcc -Wall will reveal any types that haven't been handled. */
c906108c 325 break;
c4093a6a 326 default:
3d263c1d 327 error (_("type not handled in c_type_print_varspec_prefix()"));
c4093a6a 328 break;
c906108c
SS
329 }
330}
331
64b00020
DE
332/* Print out "const" and "volatile" attributes,
333 and address space id if present.
c906108c
SS
334 TYPE is a pointer to the type being printed out.
335 STREAM is the output destination.
a737a51b
DE
336 NEED_PRE_SPACE = 1 indicates an initial white space is needed.
337 NEED_POST_SPACE = 1 indicates a final white space is needed. */
c906108c
SS
338
339static void
47663de5
MS
340c_type_print_modifier (struct type *type, struct ui_file *stream,
341 int need_pre_space, int need_post_space)
c906108c 342{
47663de5 343 int did_print_modifier = 0;
321432c0 344 const char *address_space_id;
c5aa993b 345
7f0b5c30
JB
346 /* We don't print `const' qualifiers for references --- since all
347 operators affect the thing referenced, not the reference itself,
348 every reference is `const'. */
349 if (TYPE_CONST (type)
350 && TYPE_CODE (type) != TYPE_CODE_REF)
c906108c
SS
351 {
352 if (need_pre_space)
c5aa993b 353 fprintf_filtered (stream, " ");
c906108c 354 fprintf_filtered (stream, "const");
47663de5 355 did_print_modifier = 1;
c906108c 356 }
c5aa993b 357
c906108c
SS
358 if (TYPE_VOLATILE (type))
359 {
47663de5 360 if (did_print_modifier || need_pre_space)
c5aa993b 361 fprintf_filtered (stream, " ");
c906108c 362 fprintf_filtered (stream, "volatile");
47663de5 363 did_print_modifier = 1;
c906108c
SS
364 }
365
50810684
UW
366 address_space_id = address_space_int_to_name (get_type_arch (type),
367 TYPE_INSTANCE_FLAGS (type));
47663de5
MS
368 if (address_space_id)
369 {
370 if (did_print_modifier || need_pre_space)
371 fprintf_filtered (stream, " ");
372 fprintf_filtered (stream, "@%s", address_space_id);
373 did_print_modifier = 1;
374 }
375
376 if (did_print_modifier && need_post_space)
c906108c
SS
377 fprintf_filtered (stream, " ");
378}
379
380
0d5de010
DJ
381/* Print out the arguments of TYPE, which should have TYPE_CODE_METHOD
382 or TYPE_CODE_FUNC, to STREAM. Artificial arguments, such as "this"
3167638f
JK
383 in non-static methods, are displayed if LINKAGE_NAME is zero. If
384 LINKAGE_NAME is non-zero and LANGUAGE is language_cplus the topmost
385 parameter types get removed their possible const and volatile qualifiers to
386 match demangled linkage name parameters part of such function type.
387 LANGUAGE is the language in which TYPE was defined. This is a necessary
388 evil since this code is used by the C, C++, and Java backends. */
c906108c 389
94af9270
KS
390void
391c_type_print_args (struct type *type, struct ui_file *stream,
3167638f 392 int linkage_name, enum language language)
c906108c 393{
0d5de010 394 int i, len;
ad2f7632 395 struct field *args;
0d5de010 396 int printed_any = 0;
c906108c
SS
397
398 fprintf_filtered (stream, "(");
ad2f7632 399 args = TYPE_FIELDS (type);
0d5de010 400 len = TYPE_NFIELDS (type);
ad2f7632 401
0d5de010
DJ
402 for (i = 0; i < TYPE_NFIELDS (type); i++)
403 {
bc9a5551
JK
404 struct type *param_type;
405
3167638f 406 if (TYPE_FIELD_ARTIFICIAL (type, i) && linkage_name)
94af9270
KS
407 continue;
408
0d5de010 409 if (printed_any)
c906108c 410 {
0d5de010
DJ
411 fprintf_filtered (stream, ", ");
412 wrap_here (" ");
c906108c 413 }
0d5de010 414
bc9a5551
JK
415 param_type = TYPE_FIELD_TYPE (type, i);
416
3167638f 417 if (language == language_cplus && linkage_name)
bc9a5551
JK
418 {
419 /* C++ standard, 13.1 Overloadable declarations, point 3, item:
420 - Parameter declarations that differ only in the presence or
421 absence of const and/or volatile are equivalent.
422
423 And the const/volatile qualifiers are not present in the mangled
424 names as produced by GCC. */
425
426 param_type = make_cv_type (0, 0, param_type, NULL);
427 }
428
94af9270 429 if (language == language_java)
bc9a5551 430 java_print_type (param_type, "", stream, -1, 0);
94af9270 431 else
bc9a5551 432 c_print_type (param_type, "", stream, -1, 0);
0d5de010 433 printed_any = 1;
c906108c 434 }
0d5de010
DJ
435
436 if (printed_any && TYPE_VARARGS (type))
c906108c 437 {
0d5de010
DJ
438 /* Print out a trailing ellipsis for varargs functions. Ignore
439 TYPE_VARARGS if the function has no named arguments; that
440 represents unprototyped (K&R style) C functions. */
441 if (printed_any && TYPE_VARARGS (type))
442 {
443 fprintf_filtered (stream, ", ");
444 wrap_here (" ");
445 fprintf_filtered (stream, "...");
446 }
c906108c 447 }
0d5de010 448 else if (!printed_any
86ffb506
KS
449 && ((TYPE_PROTOTYPED (type) && language != language_java)
450 || language == language_cplus))
0d5de010 451 fprintf_filtered (stream, "void");
c5aa993b 452
c906108c
SS
453 fprintf_filtered (stream, ")");
454}
455
dfcd3bfb
JM
456/* Return true iff the j'th overloading of the i'th method of TYPE
457 is a type conversion operator, like `operator int () { ... }'.
458 When listing a class's methods, we don't print the return type of
459 such operators. */
a737a51b 460
dfcd3bfb
JM
461static int
462is_type_conversion_operator (struct type *type, int i, int j)
463{
464 /* I think the whole idea of recognizing type conversion operators
465 by their name is pretty terrible. But I don't think our present
466 data structure gives us any other way to tell. If you know of
467 some other way, feel free to rewrite this function. */
0d5cff50 468 const char *name = TYPE_FN_FIELDLIST_NAME (type, i);
dfcd3bfb
JM
469
470 if (strncmp (name, "operator", 8) != 0)
471 return 0;
472
473 name += 8;
474 if (! strchr (" \t\f\n\r", *name))
475 return 0;
476
477 while (strchr (" \t\f\n\r", *name))
478 name++;
479
b0129042
DJ
480 if (!('a' <= *name && *name <= 'z')
481 && !('A' <= *name && *name <= 'Z')
482 && *name != '_')
483 /* If this doesn't look like the start of an identifier, then it
484 isn't a type conversion operator. */
485 return 0;
486 else if (strncmp (name, "new", 3) == 0)
dfcd3bfb
JM
487 name += 3;
488 else if (strncmp (name, "delete", 6) == 0)
489 name += 6;
490 else
39c22d1a
JM
491 /* If it doesn't look like new or delete, it's a type conversion
492 operator. */
493 return 1;
dfcd3bfb
JM
494
495 /* Is that really the end of the name? */
496 if (('a' <= *name && *name <= 'z')
497 || ('A' <= *name && *name <= 'Z')
498 || ('0' <= *name && *name <= '9')
499 || *name == '_')
500 /* No, so the identifier following "operator" must be a type name,
501 and this is a type conversion operator. */
502 return 1;
503
504 /* That was indeed the end of the name, so it was `operator new' or
aff410f1
MS
505 `operator delete', neither of which are type conversion
506 operators. */
dfcd3bfb
JM
507 return 0;
508}
509
dfcd3bfb
JM
510/* Given a C++ qualified identifier QID, strip off the qualifiers,
511 yielding the unqualified name. The return value is a pointer into
512 the original string.
513
514 It's a pity we don't have this information in some more structured
515 form. Even the author of this function feels that writing little
516 parsers like this everywhere is stupid. */
a737a51b 517
dfcd3bfb
JM
518static char *
519remove_qualifiers (char *qid)
520{
0963b4bd 521 int quoted = 0; /* Zero if we're not in quotes;
aff410f1
MS
522 '"' if we're in a double-quoted string;
523 '\'' if we're in a single-quoted string. */
0963b4bd 524 int depth = 0; /* Number of unclosed parens we've seen. */
dfcd3bfb
JM
525 char *parenstack = (char *) alloca (strlen (qid));
526 char *scan;
aff410f1
MS
527 char *last = 0; /* The character after the rightmost
528 `::' token we've seen so far. */
dfcd3bfb
JM
529
530 for (scan = qid; *scan; scan++)
531 {
532 if (quoted)
533 {
534 if (*scan == quoted)
535 quoted = 0;
536 else if (*scan == '\\' && *(scan + 1))
537 scan++;
538 }
539 else if (scan[0] == ':' && scan[1] == ':')
540 {
541 /* If we're inside parenthesis (i.e., an argument list) or
542 angle brackets (i.e., a list of template arguments), then
543 we don't record the position of this :: token, since it's
aff410f1
MS
544 not relevant to the top-level structure we're trying to
545 operate on. */
dfcd3bfb
JM
546 if (depth == 0)
547 {
548 last = scan + 2;
549 scan++;
550 }
551 }
552 else if (*scan == '"' || *scan == '\'')
553 quoted = *scan;
554 else if (*scan == '(')
555 parenstack[depth++] = ')';
556 else if (*scan == '[')
557 parenstack[depth++] = ']';
558 /* We're going to treat <> as a pair of matching characters,
559 since we're more likely to see those in template id's than
560 real less-than characters. What a crock. */
561 else if (*scan == '<')
562 parenstack[depth++] = '>';
563 else if (*scan == ')' || *scan == ']' || *scan == '>')
564 {
565 if (depth > 0 && parenstack[depth - 1] == *scan)
566 depth--;
567 else
568 {
aff410f1
MS
569 /* We're going to do a little error recovery here. If
570 we don't find a match for *scan on the paren stack,
571 but there is something lower on the stack that does
572 match, we pop the stack to that point. */
dfcd3bfb
JM
573 int i;
574
575 for (i = depth - 1; i >= 0; i--)
576 if (parenstack[i] == *scan)
577 {
578 depth = i;
579 break;
580 }
581 }
582 }
583 }
584
585 if (last)
586 return last;
587 else
588 /* We didn't find any :: tokens at the top level, so declare the
589 whole thing an unqualified identifier. */
590 return qid;
591}
592
c906108c
SS
593/* Print any array sizes, function arguments or close parentheses
594 needed after the variable name (to describe its type).
595 Args work like c_type_print_varspec_prefix. */
596
597void
aff410f1
MS
598c_type_print_varspec_suffix (struct type *type,
599 struct ui_file *stream,
600 int show, int passed_a_ptr,
601 int demangled_args)
c906108c
SS
602{
603 if (type == 0)
604 return;
605
606 if (TYPE_NAME (type) && show <= 0)
607 return;
608
609 QUIT;
610
611 switch (TYPE_CODE (type))
612 {
613 case TYPE_CODE_ARRAY:
dbc98a8b
KW
614 {
615 LONGEST low_bound, high_bound;
42056501 616 int is_vector = TYPE_VECTOR (type);
c5aa993b 617
dbc98a8b
KW
618 if (passed_a_ptr)
619 fprintf_filtered (stream, ")");
c5aa993b 620
42056501
AB
621 fprintf_filtered (stream, (is_vector ?
622 "__attribute__ ((vector_size(" : "["));
dbc98a8b 623 if (get_array_bounds (type, &low_bound, &high_bound))
318102b9
SP
624 fprintf_filtered (stream, "%s",
625 plongest (high_bound - low_bound + 1));
42056501 626 fprintf_filtered (stream, (is_vector ? ")))" : "]"));
dbc98a8b 627
aff410f1
MS
628 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
629 show, 0, 0);
dbc98a8b 630 }
c906108c
SS
631 break;
632
0d5de010 633 case TYPE_CODE_MEMBERPTR:
aff410f1
MS
634 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
635 show, 0, 0);
c906108c
SS
636 break;
637
0d5de010
DJ
638 case TYPE_CODE_METHODPTR:
639 fprintf_filtered (stream, ")");
aff410f1
MS
640 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
641 show, 0, 0);
c906108c
SS
642 break;
643
644 case TYPE_CODE_PTR:
645 case TYPE_CODE_REF:
aff410f1
MS
646 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
647 show, 1, 0);
c906108c
SS
648 break;
649
0d5de010 650 case TYPE_CODE_METHOD:
c906108c
SS
651 case TYPE_CODE_FUNC:
652 if (passed_a_ptr)
653 fprintf_filtered (stream, ")");
654 if (!demangled_args)
3167638f 655 c_type_print_args (type, stream, 0, current_language->la_language);
aff410f1
MS
656 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
657 show, passed_a_ptr, 0);
248f8055
DJ
658 break;
659
660 case TYPE_CODE_TYPEDEF:
aff410f1
MS
661 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
662 show, passed_a_ptr, 0);
c906108c
SS
663 break;
664
665 case TYPE_CODE_UNDEF:
666 case TYPE_CODE_STRUCT:
667 case TYPE_CODE_UNION:
668 case TYPE_CODE_ENUM:
669 case TYPE_CODE_INT:
670 case TYPE_CODE_FLT:
671 case TYPE_CODE_VOID:
672 case TYPE_CODE_ERROR:
673 case TYPE_CODE_CHAR:
674 case TYPE_CODE_BOOL:
675 case TYPE_CODE_SET:
676 case TYPE_CODE_RANGE:
677 case TYPE_CODE_STRING:
c906108c 678 case TYPE_CODE_COMPLEX:
5c4e30ca 679 case TYPE_CODE_NAMESPACE:
7678ef8f 680 case TYPE_CODE_DECFLOAT:
c906108c 681 /* These types do not need a suffix. They are listed so that
aff410f1
MS
682 gcc -Wall will report types that may not have been
683 considered. */
c906108c 684 break;
c4093a6a 685 default:
3d263c1d 686 error (_("type not handled in c_type_print_varspec_suffix()"));
c4093a6a 687 break;
c906108c
SS
688 }
689}
690
691/* Print the name of the type (or the ultimate pointer target,
aff410f1
MS
692 function value or array element), or the description of a structure
693 or union.
694
695 SHOW positive means print details about the type (e.g. enum
696 values), and print structure elements passing SHOW - 1 for show.
697
698 SHOW negative means just print the type name or struct tag if there
699 is one. If there is no name, print something sensible but concise
700 like "struct {...}".
701
702 SHOW zero means just print the type name or struct tag if there is
703 one. If there is no name, print something sensible but not as
704 concise like "struct {int x; int y;}".
c906108c
SS
705
706 LEVEL is the number of spaces to indent by.
707 We increase it for some recursive calls. */
708
709void
aff410f1
MS
710c_type_print_base (struct type *type, struct ui_file *stream,
711 int show, int level)
c906108c 712{
b02dede2
DJ
713 int i;
714 int len, real_len;
c5aa993b
JM
715 enum
716 {
717 s_none, s_public, s_private, s_protected
718 }
719 section_type;
c906108c
SS
720 int need_access_label = 0;
721 int j, len2;
722
723 QUIT;
724
725 wrap_here (" ");
726 if (type == NULL)
727 {
3d263c1d 728 fputs_filtered (_("<type unknown>"), stream);
c906108c
SS
729 return;
730 }
731
aff410f1
MS
732 /* When SHOW is zero or less, and there is a valid type name, then
733 always just print the type name directly from the type. */
734 /* If we have "typedef struct foo {. . .} bar;" do we want to print
735 it as "struct foo" or as "bar"? Pick the latter, because C++
736 folk tend to expect things like "class5 *foo" rather than "struct
737 class5 *foo". */
c906108c
SS
738
739 if (show <= 0
740 && TYPE_NAME (type) != NULL)
741 {
47663de5 742 c_type_print_modifier (type, stream, 0, 1);
c906108c
SS
743 fputs_filtered (TYPE_NAME (type), stream);
744 return;
745 }
746
747 CHECK_TYPEDEF (type);
c5aa993b 748
c906108c
SS
749 switch (TYPE_CODE (type))
750 {
751 case TYPE_CODE_TYPEDEF:
aff410f1
MS
752 /* If we get here, the typedef doesn't have a name, and we
753 couldn't resolve TYPE_TARGET_TYPE. Not much we can do. */
8c540a24
DE
754 gdb_assert (TYPE_NAME (type) == NULL);
755 gdb_assert (TYPE_TARGET_TYPE (type) == NULL);
756 fprintf_filtered (stream, _("<unnamed typedef>"));
757 break;
758
c906108c
SS
759 case TYPE_CODE_ARRAY:
760 case TYPE_CODE_PTR:
0d5de010 761 case TYPE_CODE_MEMBERPTR:
c906108c
SS
762 case TYPE_CODE_REF:
763 case TYPE_CODE_FUNC:
764 case TYPE_CODE_METHOD:
0d5de010 765 case TYPE_CODE_METHODPTR:
aff410f1
MS
766 c_type_print_base (TYPE_TARGET_TYPE (type),
767 stream, show, level);
c906108c
SS
768 break;
769
770 case TYPE_CODE_STRUCT:
1c5b7826 771 case TYPE_CODE_UNION:
47663de5 772 c_type_print_modifier (type, stream, 0, 1);
1c5b7826
TT
773 if (TYPE_CODE (type) == TYPE_CODE_UNION)
774 fprintf_filtered (stream, "union ");
775 else if (TYPE_DECLARED_CLASS (type))
0cc2414c 776 fprintf_filtered (stream, "class ");
c5aa993b 777 else
0cc2414c 778 fprintf_filtered (stream, "struct ");
c906108c 779
aff410f1
MS
780 /* Print the tag if it exists. The HP aCC compiler emits a
781 spurious "{unnamed struct}"/"{unnamed union}"/"{unnamed
782 enum}" tag for unnamed struct/union/enum's, which we don't
783 want to print. */
5aafa1cc
PM
784 if (TYPE_TAG_NAME (type) != NULL
785 && strncmp (TYPE_TAG_NAME (type), "{unnamed", 8))
c906108c
SS
786 {
787 fputs_filtered (TYPE_TAG_NAME (type), stream);
788 if (show > 0)
789 fputs_filtered (" ", stream);
790 }
791 wrap_here (" ");
792 if (show < 0)
793 {
aff410f1
MS
794 /* If we just printed a tag name, no need to print anything
795 else. */
c906108c
SS
796 if (TYPE_TAG_NAME (type) == NULL)
797 fprintf_filtered (stream, "{...}");
798 }
799 else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
800 {
d48cc9dd
DJ
801 struct type *basetype;
802 int vptr_fieldno;
803
c906108c 804 cp_type_print_derivation_info (stream, type);
c5aa993b 805
c906108c 806 fprintf_filtered (stream, "{\n");
98751a41
JK
807 if (TYPE_NFIELDS (type) == 0 && TYPE_NFN_FIELDS (type) == 0
808 && TYPE_TYPEDEF_FIELD_COUNT (type) == 0)
c906108c 809 {
74a9bb82 810 if (TYPE_STUB (type))
aff410f1
MS
811 fprintfi_filtered (level + 4, stream,
812 _("<incomplete type>\n"));
c906108c 813 else
aff410f1
MS
814 fprintfi_filtered (level + 4, stream,
815 _("<no data fields>\n"));
c906108c
SS
816 }
817
818 /* Start off with no specific section type, so we can print
819 one for the first field we find, and use that section type
aff410f1 820 thereafter until we find another type. */
c906108c
SS
821
822 section_type = s_none;
823
c5aa993b
JM
824 /* For a class, if all members are private, there's no need
825 for a "private:" label; similarly, for a struct or union
826 masquerading as a class, if all members are public, there's
aff410f1 827 no need for a "public:" label. */
c5aa993b 828
0cc2414c 829 if (TYPE_DECLARED_CLASS (type))
c5aa993b
JM
830 {
831 QUIT;
832 len = TYPE_NFIELDS (type);
833 for (i = TYPE_N_BASECLASSES (type); i < len; i++)
834 if (!TYPE_FIELD_PRIVATE (type, i))
835 {
836 need_access_label = 1;
837 break;
838 }
839 QUIT;
840 if (!need_access_label)
841 {
842 len2 = TYPE_NFN_FIELDS (type);
843 for (j = 0; j < len2; j++)
844 {
845 len = TYPE_FN_FIELDLIST_LENGTH (type, j);
846 for (i = 0; i < len; i++)
3e43a32a
MS
847 if (!TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type,
848 j), i))
c5aa993b
JM
849 {
850 need_access_label = 1;
851 break;
852 }
853 if (need_access_label)
854 break;
855 }
856 }
857 }
0cc2414c 858 else
c5aa993b
JM
859 {
860 QUIT;
861 len = TYPE_NFIELDS (type);
862 for (i = TYPE_N_BASECLASSES (type); i < len; i++)
aff410f1
MS
863 if (TYPE_FIELD_PRIVATE (type, i)
864 || TYPE_FIELD_PROTECTED (type, i))
c5aa993b
JM
865 {
866 need_access_label = 1;
867 break;
868 }
869 QUIT;
870 if (!need_access_label)
871 {
872 len2 = TYPE_NFN_FIELDS (type);
873 for (j = 0; j < len2; j++)
874 {
875 QUIT;
876 len = TYPE_FN_FIELDLIST_LENGTH (type, j);
877 for (i = 0; i < len; i++)
3e43a32a
MS
878 if (TYPE_FN_FIELD_PROTECTED (TYPE_FN_FIELDLIST1 (type,
879 j), i)
880 || TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type,
881 j),
882 i))
c5aa993b
JM
883 {
884 need_access_label = 1;
885 break;
886 }
887 if (need_access_label)
888 break;
889 }
890 }
891 }
c906108c
SS
892
893 /* If there is a base class for this type,
894 do not print the field that it occupies. */
895
896 len = TYPE_NFIELDS (type);
d48cc9dd 897 vptr_fieldno = get_vptr_fieldno (type, &basetype);
c906108c
SS
898 for (i = TYPE_N_BASECLASSES (type); i < len; i++)
899 {
900 QUIT;
d48cc9dd
DJ
901
902 /* If we have a virtual table pointer, omit it. Even if
903 virtual table pointers are not specifically marked in
904 the debug info, they should be artificial. */
fd9e29b5 905 if ((i == vptr_fieldno && type == basetype)
d48cc9dd 906 || TYPE_FIELD_ARTIFICIAL (type, i))
c906108c
SS
907 continue;
908
0cc2414c 909 if (need_access_label)
c906108c
SS
910 {
911 if (TYPE_FIELD_PROTECTED (type, i))
912 {
913 if (section_type != s_protected)
914 {
915 section_type = s_protected;
916 fprintfi_filtered (level + 2, stream,
917 "protected:\n");
918 }
919 }
920 else if (TYPE_FIELD_PRIVATE (type, i))
921 {
922 if (section_type != s_private)
923 {
924 section_type = s_private;
aff410f1
MS
925 fprintfi_filtered (level + 2, stream,
926 "private:\n");
c906108c
SS
927 }
928 }
929 else
930 {
931 if (section_type != s_public)
932 {
933 section_type = s_public;
aff410f1
MS
934 fprintfi_filtered (level + 2, stream,
935 "public:\n");
c906108c
SS
936 }
937 }
938 }
939
940 print_spaces_filtered (level + 4, stream);
d6a843b5
JK
941 if (field_is_static (&TYPE_FIELD (type, i)))
942 fprintf_filtered (stream, "static ");
c906108c
SS
943 c_print_type (TYPE_FIELD_TYPE (type, i),
944 TYPE_FIELD_NAME (type, i),
945 stream, show - 1, level + 4);
d6a843b5 946 if (!field_is_static (&TYPE_FIELD (type, i))
c906108c
SS
947 && TYPE_FIELD_PACKED (type, i))
948 {
949 /* It is a bitfield. This code does not attempt
950 to look at the bitpos and reconstruct filler,
951 unnamed fields. This would lead to misleading
952 results if the compiler does not put out fields
953 for such things (I don't know what it does). */
954 fprintf_filtered (stream, " : %d",
955 TYPE_FIELD_BITSIZE (type, i));
956 }
957 fprintf_filtered (stream, ";\n");
958 }
959
b02dede2 960 /* If there are both fields and methods, put a blank line
aff410f1
MS
961 between them. Make sure to count only method that we
962 will display; artificial methods will be hidden. */
c906108c 963 len = TYPE_NFN_FIELDS (type);
b02dede2
DJ
964 real_len = 0;
965 for (i = 0; i < len; i++)
966 {
967 struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
968 int len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
969 int j;
c5504eaf 970
b02dede2
DJ
971 for (j = 0; j < len2; j++)
972 if (!TYPE_FN_FIELD_ARTIFICIAL (f, j))
973 real_len++;
974 }
975 if (real_len > 0 && section_type != s_none)
c5aa993b 976 fprintf_filtered (stream, "\n");
c906108c 977
0963b4bd 978 /* C++: print out the methods. */
c906108c
SS
979 for (i = 0; i < len; i++)
980 {
981 struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
982 int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
0d5cff50
DE
983 const char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
984 const char *name = type_name_no_tag (type);
aff410f1
MS
985 int is_constructor = name && strcmp (method_name,
986 name) == 0;
c5504eaf 987
c906108c
SS
988 for (j = 0; j < len2; j++)
989 {
1d06ead6
TT
990 const char *mangled_name;
991 char *demangled_name;
992 struct cleanup *inner_cleanup;
993 const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
c5aa993b 994 int is_full_physname_constructor =
c5504eaf
MS
995 is_constructor_name (physname)
996 || is_destructor_name (physname)
997 || method_name[0] == '~';
015a42b4 998
b02dede2
DJ
999 /* Do not print out artificial methods. */
1000 if (TYPE_FN_FIELD_ARTIFICIAL (f, j))
1001 continue;
c906108c 1002
1d06ead6
TT
1003 inner_cleanup = make_cleanup (null_cleanup, NULL);
1004
c906108c
SS
1005 QUIT;
1006 if (TYPE_FN_FIELD_PROTECTED (f, j))
1007 {
1008 if (section_type != s_protected)
1009 {
1010 section_type = s_protected;
1011 fprintfi_filtered (level + 2, stream,
1012 "protected:\n");
1013 }
1014 }
1015 else if (TYPE_FN_FIELD_PRIVATE (f, j))
1016 {
1017 if (section_type != s_private)
1018 {
1019 section_type = s_private;
aff410f1
MS
1020 fprintfi_filtered (level + 2, stream,
1021 "private:\n");
c906108c
SS
1022 }
1023 }
1024 else
1025 {
1026 if (section_type != s_public)
1027 {
1028 section_type = s_public;
aff410f1
MS
1029 fprintfi_filtered (level + 2, stream,
1030 "public:\n");
c906108c
SS
1031 }
1032 }
1033
1034 print_spaces_filtered (level + 4, stream);
1035 if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
1036 fprintf_filtered (stream, "virtual ");
1037 else if (TYPE_FN_FIELD_STATIC_P (f, j))
1038 fprintf_filtered (stream, "static ");
1039 if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0)
1040 {
1041 /* Keep GDB from crashing here. */
aff410f1
MS
1042 fprintf_filtered (stream,
1043 _("<undefined type> %s;\n"),
c5aa993b 1044 TYPE_FN_FIELD_PHYSNAME (f, j));
c906108c
SS
1045 break;
1046 }
aff410f1
MS
1047 else if (!is_constructor /* Constructors don't
1048 have declared
1049 types. */
1050 && !is_full_physname_constructor /* " " */
5aafa1cc 1051 && !is_type_conversion_operator (type, i, j))
c906108c
SS
1052 {
1053 type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)),
1054 "", stream, -1);
1055 fputs_filtered (" ", stream);
1056 }
1057 if (TYPE_FN_FIELD_STUB (f, j))
1d06ead6
TT
1058 {
1059 char *tem;
1060
1061 /* Build something we can demangle. */
1062 tem = gdb_mangle_name (type, i, j);
1063 make_cleanup (xfree, tem);
1064 mangled_name = tem;
1065 }
c906108c
SS
1066 else
1067 mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j);
1068
1069 demangled_name =
1070 cplus_demangle (mangled_name,
1071 DMGL_ANSI | DMGL_PARAMS);
1072 if (demangled_name == NULL)
1073 {
aff410f1
MS
1074 /* In some cases (for instance with the HP
1075 demangling), if a function has more than 10
1076 arguments, the demangling will fail.
1077 Let's try to reconstruct the function
1078 signature from the symbol information. */
c906108c 1079 if (!TYPE_FN_FIELD_STUB (f, j))
ad2f7632
DJ
1080 {
1081 int staticp = TYPE_FN_FIELD_STATIC_P (f, j);
1082 struct type *mtype = TYPE_FN_FIELD_TYPE (f, j);
c5504eaf 1083
ad2f7632
DJ
1084 cp_type_print_method_args (mtype,
1085 "",
1086 method_name,
1087 staticp,
1088 stream);
1089 }
c906108c 1090 else
aff410f1
MS
1091 fprintf_filtered (stream,
1092 _("<badly mangled name '%s'>"),
c906108c
SS
1093 mangled_name);
1094 }
1095 else
1096 {
1097 char *p;
dfcd3bfb
JM
1098 char *demangled_no_class
1099 = remove_qualifiers (demangled_name);
c5aa993b 1100
aff410f1
MS
1101 /* Get rid of the `static' appended by the
1102 demangler. */
c906108c
SS
1103 p = strstr (demangled_no_class, " static");
1104 if (p != NULL)
1105 {
1106 int length = p - demangled_no_class;
1d06ead6 1107 char *demangled_no_static;
c5504eaf 1108
aff410f1
MS
1109 demangled_no_static
1110 = (char *) xmalloc (length + 1);
1111 strncpy (demangled_no_static,
1112 demangled_no_class, length);
c5aa993b 1113 *(demangled_no_static + length) = '\0';
c906108c 1114 fputs_filtered (demangled_no_static, stream);
b8c9b27d 1115 xfree (demangled_no_static);
c906108c
SS
1116 }
1117 else
1118 fputs_filtered (demangled_no_class, stream);
b8c9b27d 1119 xfree (demangled_name);
c906108c
SS
1120 }
1121
1d06ead6 1122 do_cleanups (inner_cleanup);
c906108c
SS
1123
1124 fprintf_filtered (stream, ";\n");
1125 }
1126 }
1127
98751a41
JK
1128 /* Print typedefs defined in this class. */
1129
1130 if (TYPE_TYPEDEF_FIELD_COUNT (type) != 0)
1131 {
1132 if (TYPE_NFIELDS (type) != 0 || TYPE_NFN_FIELDS (type) != 0)
1133 fprintf_filtered (stream, "\n");
1134
1135 for (i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); i++)
1136 {
1137 struct type *target = TYPE_TYPEDEF_FIELD_TYPE (type, i);
1138
1139 /* Dereference the typedef declaration itself. */
1140 gdb_assert (TYPE_CODE (target) == TYPE_CODE_TYPEDEF);
1141 target = TYPE_TARGET_TYPE (target);
1142
1143 print_spaces_filtered (level + 4, stream);
1144 fprintf_filtered (stream, "typedef ");
1145 c_print_type (target, TYPE_TYPEDEF_FIELD_NAME (type, i),
1146 stream, show - 1, level + 4);
1147 fprintf_filtered (stream, ";\n");
1148 }
1149 }
1150
c4093a6a
JM
1151 fprintfi_filtered (level, stream, "}");
1152
c5aa993b 1153 if (TYPE_LOCALTYPE_PTR (type) && show >= 0)
aff410f1
MS
1154 fprintfi_filtered (level,
1155 stream, _(" (Local at %s:%d)\n"),
c5aa993b
JM
1156 TYPE_LOCALTYPE_FILE (type),
1157 TYPE_LOCALTYPE_LINE (type));
c906108c 1158 }
c906108c
SS
1159 break;
1160
1161 case TYPE_CODE_ENUM:
47663de5 1162 c_type_print_modifier (type, stream, 0, 1);
c5aa993b 1163 fprintf_filtered (stream, "enum ");
c906108c
SS
1164 /* Print the tag name if it exists.
1165 The aCC compiler emits a spurious
1166 "{unnamed struct}"/"{unnamed union}"/"{unnamed enum}"
1167 tag for unnamed struct/union/enum's, which we don't
aff410f1 1168 want to print. */
5aafa1cc
PM
1169 if (TYPE_TAG_NAME (type) != NULL
1170 && strncmp (TYPE_TAG_NAME (type), "{unnamed", 8))
c906108c
SS
1171 {
1172 fputs_filtered (TYPE_TAG_NAME (type), stream);
1173 if (show > 0)
1174 fputs_filtered (" ", stream);
1175 }
1176
1177 wrap_here (" ");
1178 if (show < 0)
1179 {
aff410f1
MS
1180 /* If we just printed a tag name, no need to print anything
1181 else. */
c906108c
SS
1182 if (TYPE_TAG_NAME (type) == NULL)
1183 fprintf_filtered (stream, "{...}");
1184 }
1185 else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
1186 {
14e75d8e
JK
1187 LONGEST lastval = 0;
1188
c906108c
SS
1189 fprintf_filtered (stream, "{");
1190 len = TYPE_NFIELDS (type);
c906108c
SS
1191 for (i = 0; i < len; i++)
1192 {
1193 QUIT;
c5aa993b
JM
1194 if (i)
1195 fprintf_filtered (stream, ", ");
c906108c
SS
1196 wrap_here (" ");
1197 fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
14e75d8e 1198 if (lastval != TYPE_FIELD_ENUMVAL (type, i))
c906108c 1199 {
14e75d8e
JK
1200 fprintf_filtered (stream, " = %s",
1201 plongest (TYPE_FIELD_ENUMVAL (type, i)));
1202 lastval = TYPE_FIELD_ENUMVAL (type, i);
c906108c
SS
1203 }
1204 lastval++;
1205 }
1206 fprintf_filtered (stream, "}");
1207 }
1208 break;
1209
1210 case TYPE_CODE_VOID:
1211 fprintf_filtered (stream, "void");
1212 break;
1213
1214 case TYPE_CODE_UNDEF:
3d263c1d 1215 fprintf_filtered (stream, _("struct <unknown>"));
c906108c
SS
1216 break;
1217
1218 case TYPE_CODE_ERROR:
b00fdb78 1219 fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type));
c906108c
SS
1220 break;
1221
1222 case TYPE_CODE_RANGE:
0963b4bd 1223 /* This should not occur. */
3d263c1d 1224 fprintf_filtered (stream, _("<range type>"));
c906108c
SS
1225 break;
1226
5c4e30ca
DC
1227 case TYPE_CODE_NAMESPACE:
1228 fputs_filtered ("namespace ", stream);
1229 fputs_filtered (TYPE_TAG_NAME (type), stream);
1230 break;
1231
c906108c 1232 default:
aff410f1
MS
1233 /* Handle types not explicitly handled by the other cases, such
1234 as fundamental types. For these, just print whatever the
1235 type name is, as recorded in the type itself. If there is no
1236 type name, then complain. */
c906108c
SS
1237 if (TYPE_NAME (type) != NULL)
1238 {
47663de5 1239 c_type_print_modifier (type, stream, 0, 1);
c906108c
SS
1240 fputs_filtered (TYPE_NAME (type), stream);
1241 }
1242 else
1243 {
aff410f1
MS
1244 /* At least for dump_symtab, it is important that this not
1245 be an error (). */
3d263c1d 1246 fprintf_filtered (stream, _("<invalid type code %d>"),
c906108c
SS
1247 TYPE_CODE (type));
1248 }
1249 break;
1250 }
1251}
This page took 1.386149 seconds and 4 git commands to generate.