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