]>
Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Support for printing C and C++ types for GDB, the GNU debugger. |
61baf725 | 2 | Copyright (C) 1986-2017 Free Software Foundation, Inc. |
c906108c | 3 | |
c5aa993b | 4 | This file is part of GDB. |
c906108c | 5 | |
c5aa993b JM |
6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 8 | the Free Software Foundation; either version 3 of the License, or |
c5aa993b | 9 | (at your option) any later version. |
c906108c | 10 | |
c5aa993b JM |
11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
c906108c | 15 | |
c5aa993b | 16 | You should have received a copy of the GNU General Public License |
a9762ec7 | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c SS |
18 | |
19 | #include "defs.h" | |
04ea0df1 | 20 | #include "gdb_obstack.h" |
aff410f1 | 21 | #include "bfd.h" /* Binary File Description. */ |
c906108c SS |
22 | #include "symtab.h" |
23 | #include "gdbtypes.h" | |
24 | #include "expression.h" | |
25 | #include "value.h" | |
26 | #include "gdbcore.h" | |
27 | #include "target.h" | |
c906108c SS |
28 | #include "language.h" |
29 | #include "demangle.h" | |
30 | #include "c-lang.h" | |
31 | #include "typeprint.h" | |
015a42b4 | 32 | #include "cp-abi.h" |
bd69fc68 | 33 | #include "cp-support.h" |
c906108c | 34 | |
c191a687 KS |
35 | /* A list of access specifiers used for printing. */ |
36 | ||
37 | enum access_specifier | |
38 | { | |
39 | s_none, | |
40 | s_public, | |
41 | s_private, | |
42 | s_protected | |
43 | }; | |
44 | ||
aff410f1 MS |
45 | static void c_type_print_varspec_prefix (struct type *, |
46 | struct ui_file *, | |
79d43c61 TT |
47 | int, int, int, |
48 | const struct type_print_options *); | |
c906108c | 49 | |
aff410f1 MS |
50 | /* Print "const", "volatile", or address space modifiers. */ |
51 | static void c_type_print_modifier (struct type *, | |
52 | struct ui_file *, | |
47663de5 | 53 | int, int); |
c5aa993b | 54 | \f |
bd69fc68 TT |
55 | |
56 | /* A callback function for cp_canonicalize_string_full that uses | |
57 | find_typedef_in_hash. */ | |
58 | ||
59 | static const char * | |
60 | find_typedef_for_canonicalize (struct type *t, void *data) | |
61 | { | |
9a3c8263 | 62 | return find_typedef_in_hash ((const struct type_print_options *) data, t); |
bd69fc68 TT |
63 | } |
64 | ||
65 | /* Print NAME on STREAM. If the 'raw' field of FLAGS is not set, | |
66 | canonicalize NAME using the local typedefs first. */ | |
67 | ||
68 | static void | |
69 | print_name_maybe_canonical (const char *name, | |
70 | const struct type_print_options *flags, | |
71 | struct ui_file *stream) | |
72 | { | |
2f408ecb | 73 | std::string s; |
bd69fc68 TT |
74 | |
75 | if (!flags->raw) | |
76 | s = cp_canonicalize_string_full (name, | |
77 | find_typedef_for_canonicalize, | |
78 | (void *) flags); | |
79 | ||
2f408ecb | 80 | fputs_filtered (!s.empty () ? s.c_str () : name, stream); |
bd69fc68 TT |
81 | } |
82 | ||
83 | \f | |
84 | ||
c906108c SS |
85 | /* LEVEL is the depth to indent lines by. */ |
86 | ||
87 | void | |
aff410f1 MS |
88 | c_print_type (struct type *type, |
89 | const char *varstring, | |
90 | struct ui_file *stream, | |
79d43c61 TT |
91 | int show, int level, |
92 | const struct type_print_options *flags) | |
c906108c | 93 | { |
52f0bd74 | 94 | enum type_code code; |
c906108c | 95 | int demangled_args; |
9750e763 | 96 | int need_post_space; |
bd69fc68 | 97 | const char *local_name; |
c906108c SS |
98 | |
99 | if (show > 0) | |
f168693b | 100 | type = check_typedef (type); |
c906108c | 101 | |
bd69fc68 TT |
102 | local_name = find_typedef_in_hash (flags, type); |
103 | if (local_name != NULL) | |
104 | { | |
105 | fputs_filtered (local_name, stream); | |
106 | if (varstring != NULL && *varstring != '\0') | |
107 | fputs_filtered (" ", stream); | |
108 | } | |
109 | else | |
110 | { | |
111 | c_type_print_base (type, stream, show, level, flags); | |
112 | code = TYPE_CODE (type); | |
113 | if ((varstring != NULL && *varstring != '\0') | |
114 | /* Need a space if going to print stars or brackets; | |
115 | but not if we will print just a type name. */ | |
116 | || ((show > 0 || TYPE_NAME (type) == 0) | |
117 | && (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC | |
118 | || code == TYPE_CODE_METHOD | |
119 | || (code == TYPE_CODE_ARRAY | |
120 | && !TYPE_VECTOR (type)) | |
121 | || code == TYPE_CODE_MEMBERPTR | |
122 | || code == TYPE_CODE_METHODPTR | |
e1cb3213 | 123 | || TYPE_IS_REFERENCE (type)))) |
bd69fc68 TT |
124 | fputs_filtered (" ", stream); |
125 | need_post_space = (varstring != NULL && strcmp (varstring, "") != 0); | |
126 | c_type_print_varspec_prefix (type, stream, show, 0, need_post_space, | |
127 | flags); | |
128 | } | |
c906108c SS |
129 | |
130 | if (varstring != NULL) | |
131 | { | |
132 | fputs_filtered (varstring, stream); | |
133 | ||
aff410f1 | 134 | /* For demangled function names, we have the arglist as part of |
0963b4bd | 135 | the name, so don't print an additional pair of ()'s. */ |
bd69fc68 TT |
136 | if (local_name == NULL) |
137 | { | |
138 | demangled_args = strchr (varstring, '(') != NULL; | |
139 | c_type_print_varspec_suffix (type, stream, show, | |
140 | 0, demangled_args, | |
141 | flags); | |
142 | } | |
c906108c SS |
143 | } |
144 | } | |
c5aa993b | 145 | |
5c6ce71d TT |
146 | /* Print a typedef using C syntax. TYPE is the underlying type. |
147 | NEW_SYMBOL is the symbol naming the type. STREAM is the stream on | |
148 | which to print. */ | |
149 | ||
150 | void | |
aff410f1 MS |
151 | c_print_typedef (struct type *type, |
152 | struct symbol *new_symbol, | |
5c6ce71d TT |
153 | struct ui_file *stream) |
154 | { | |
f168693b | 155 | type = check_typedef (type); |
5c6ce71d TT |
156 | fprintf_filtered (stream, "typedef "); |
157 | type_print (type, "", stream, 0); | |
158 | if (TYPE_NAME ((SYMBOL_TYPE (new_symbol))) == 0 | |
159 | || strcmp (TYPE_NAME ((SYMBOL_TYPE (new_symbol))), | |
b1d61bc9 PM |
160 | SYMBOL_LINKAGE_NAME (new_symbol)) != 0 |
161 | || TYPE_CODE (SYMBOL_TYPE (new_symbol)) == TYPE_CODE_TYPEDEF) | |
5c6ce71d TT |
162 | fprintf_filtered (stream, " %s", SYMBOL_PRINT_NAME (new_symbol)); |
163 | fprintf_filtered (stream, ";\n"); | |
164 | } | |
165 | ||
c906108c | 166 | /* If TYPE is a derived type, then print out derivation information. |
aff410f1 MS |
167 | Print only the actual base classes of this type, not the base |
168 | classes of the base classes. I.e. for the derivation hierarchy: | |
c906108c | 169 | |
c5aa993b JM |
170 | class A { int a; }; |
171 | class B : public A {int b; }; | |
172 | class C : public B {int c; }; | |
c906108c SS |
173 | |
174 | Print the type of class C as: | |
175 | ||
c5aa993b JM |
176 | class C : public B { |
177 | int c; | |
178 | } | |
c906108c | 179 | |
aff410f1 MS |
180 | Not as the following (like gdb used to), which is not legal C++ |
181 | syntax for derived types and may be confused with the multiple | |
182 | inheritance form: | |
c906108c | 183 | |
c5aa993b JM |
184 | class C : public B : public A { |
185 | int c; | |
186 | } | |
c906108c | 187 | |
aff410f1 | 188 | In general, gdb should try to print the types as closely as |
62a49610 | 189 | possible to the form that they appear in the source code. */ |
c906108c SS |
190 | |
191 | static void | |
aff410f1 | 192 | cp_type_print_derivation_info (struct ui_file *stream, |
bd69fc68 TT |
193 | struct type *type, |
194 | const struct type_print_options *flags) | |
c906108c | 195 | { |
0d5cff50 | 196 | const char *name; |
c906108c SS |
197 | int i; |
198 | ||
199 | for (i = 0; i < TYPE_N_BASECLASSES (type); i++) | |
200 | { | |
bd69fc68 | 201 | wrap_here (" "); |
c906108c SS |
202 | fputs_filtered (i == 0 ? ": " : ", ", stream); |
203 | fprintf_filtered (stream, "%s%s ", | |
aff410f1 MS |
204 | BASETYPE_VIA_PUBLIC (type, i) |
205 | ? "public" : (TYPE_FIELD_PROTECTED (type, i) | |
206 | ? "protected" : "private"), | |
c5aa993b | 207 | BASETYPE_VIA_VIRTUAL (type, i) ? " virtual" : ""); |
c906108c | 208 | name = type_name_no_tag (TYPE_BASECLASS (type, i)); |
bd69fc68 TT |
209 | if (name) |
210 | print_name_maybe_canonical (name, flags, stream); | |
211 | else | |
212 | fprintf_filtered (stream, "(null)"); | |
c906108c SS |
213 | } |
214 | if (i > 0) | |
215 | { | |
216 | fputs_filtered (" ", stream); | |
217 | } | |
218 | } | |
ad2f7632 | 219 | |
c906108c | 220 | /* Print the C++ method arguments ARGS to the file STREAM. */ |
c5aa993b | 221 | |
392a587b | 222 | static void |
0d5cff50 DE |
223 | cp_type_print_method_args (struct type *mtype, const char *prefix, |
224 | const char *varstring, int staticp, | |
6c8702eb TT |
225 | struct ui_file *stream, |
226 | const struct type_print_options *flags) | |
c906108c | 227 | { |
ad2f7632 DJ |
228 | struct field *args = TYPE_FIELDS (mtype); |
229 | int nargs = TYPE_NFIELDS (mtype); | |
230 | int varargs = TYPE_VARARGS (mtype); | |
c906108c | 231 | int i; |
c5aa993b | 232 | |
aff410f1 MS |
233 | fprintf_symbol_filtered (stream, prefix, |
234 | language_cplus, DMGL_ANSI); | |
235 | fprintf_symbol_filtered (stream, varstring, | |
236 | language_cplus, DMGL_ANSI); | |
c906108c | 237 | fputs_filtered ("(", stream); |
ad2f7632 | 238 | |
5f4d1085 KS |
239 | /* Skip the class variable. We keep this here to accommodate older |
240 | compilers and debug formats which may not support artificial | |
241 | parameters. */ | |
ad2f7632 DJ |
242 | i = staticp ? 0 : 1; |
243 | if (nargs > i) | |
c906108c | 244 | { |
ad2f7632 | 245 | while (i < nargs) |
c5aa993b | 246 | { |
5f4d1085 KS |
247 | struct field arg = args[i++]; |
248 | ||
249 | /* Skip any artificial arguments. */ | |
250 | if (FIELD_ARTIFICIAL (arg)) | |
251 | continue; | |
252 | ||
253 | c_print_type (arg.type, "", stream, 0, 0, flags); | |
ad2f7632 DJ |
254 | |
255 | if (i == nargs && varargs) | |
256 | fprintf_filtered (stream, ", ..."); | |
257 | else if (i < nargs) | |
bd69fc68 TT |
258 | { |
259 | fprintf_filtered (stream, ", "); | |
260 | wrap_here (" "); | |
261 | } | |
c5aa993b | 262 | } |
c906108c | 263 | } |
ad2f7632 DJ |
264 | else if (varargs) |
265 | fprintf_filtered (stream, "..."); | |
c906108c | 266 | else if (current_language->la_language == language_cplus) |
ad2f7632 | 267 | fprintf_filtered (stream, "void"); |
c5aa993b | 268 | |
c906108c | 269 | fprintf_filtered (stream, ")"); |
94af9270 KS |
270 | |
271 | /* For non-static methods, read qualifiers from the type of | |
272 | THIS. */ | |
273 | if (!staticp) | |
274 | { | |
275 | struct type *domain; | |
276 | ||
277 | gdb_assert (nargs > 0); | |
278 | gdb_assert (TYPE_CODE (args[0].type) == TYPE_CODE_PTR); | |
279 | domain = TYPE_TARGET_TYPE (args[0].type); | |
280 | ||
281 | if (TYPE_CONST (domain)) | |
282 | fprintf_filtered (stream, " const"); | |
283 | ||
284 | if (TYPE_VOLATILE (domain)) | |
285 | fprintf_filtered (stream, " volatile"); | |
06d66ee9 TT |
286 | |
287 | if (TYPE_RESTRICT (domain)) | |
288 | fprintf_filtered (stream, " restrict"); | |
a2c2acaf MW |
289 | |
290 | if (TYPE_ATOMIC (domain)) | |
291 | fprintf_filtered (stream, " _Atomic"); | |
94af9270 | 292 | } |
c906108c SS |
293 | } |
294 | ||
295 | ||
296 | /* Print any asterisks or open-parentheses needed before the | |
297 | variable name (to describe its type). | |
298 | ||
299 | On outermost call, pass 0 for PASSED_A_PTR. | |
300 | On outermost call, SHOW > 0 means should ignore | |
301 | any typename for TYPE and show its details. | |
9750e763 KB |
302 | SHOW is always zero on recursive calls. |
303 | ||
304 | NEED_POST_SPACE is non-zero when a space will be be needed | |
305 | between a trailing qualifier and a field, variable, or function | |
306 | name. */ | |
c906108c | 307 | |
a737a51b | 308 | static void |
aff410f1 MS |
309 | c_type_print_varspec_prefix (struct type *type, |
310 | struct ui_file *stream, | |
311 | int show, int passed_a_ptr, | |
79d43c61 TT |
312 | int need_post_space, |
313 | const struct type_print_options *flags) | |
c906108c | 314 | { |
0d5cff50 | 315 | const char *name; |
c5504eaf | 316 | |
c906108c SS |
317 | if (type == 0) |
318 | return; | |
319 | ||
320 | if (TYPE_NAME (type) && show <= 0) | |
321 | return; | |
322 | ||
323 | QUIT; | |
324 | ||
325 | switch (TYPE_CODE (type)) | |
326 | { | |
327 | case TYPE_CODE_PTR: | |
aff410f1 | 328 | c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), |
79d43c61 | 329 | stream, show, 1, 1, flags); |
c906108c | 330 | fprintf_filtered (stream, "*"); |
9750e763 | 331 | c_type_print_modifier (type, stream, 1, need_post_space); |
c906108c SS |
332 | break; |
333 | ||
0d5de010 | 334 | case TYPE_CODE_MEMBERPTR: |
aff410f1 | 335 | c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), |
79d43c61 | 336 | stream, show, 0, 0, flags); |
4bfb94b8 | 337 | name = type_name_no_tag (TYPE_SELF_TYPE (type)); |
c906108c | 338 | if (name) |
bd69fc68 | 339 | print_name_maybe_canonical (name, flags, stream); |
c906108c | 340 | else |
4bfb94b8 | 341 | c_type_print_base (TYPE_SELF_TYPE (type), |
79d43c61 | 342 | stream, -1, passed_a_ptr, flags); |
0d5de010 | 343 | fprintf_filtered (stream, "::*"); |
c906108c SS |
344 | break; |
345 | ||
0d5de010 | 346 | case TYPE_CODE_METHODPTR: |
aff410f1 | 347 | c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), |
79d43c61 | 348 | stream, show, 0, 0, flags); |
0d5de010 | 349 | fprintf_filtered (stream, "("); |
4bfb94b8 | 350 | name = type_name_no_tag (TYPE_SELF_TYPE (type)); |
0d5de010 | 351 | if (name) |
bd69fc68 | 352 | print_name_maybe_canonical (name, flags, stream); |
0d5de010 | 353 | else |
4bfb94b8 | 354 | c_type_print_base (TYPE_SELF_TYPE (type), |
79d43c61 | 355 | stream, -1, passed_a_ptr, flags); |
0d5de010 | 356 | fprintf_filtered (stream, "::*"); |
c906108c SS |
357 | break; |
358 | ||
359 | case TYPE_CODE_REF: | |
e1cb3213 | 360 | case TYPE_CODE_RVALUE_REF: |
aff410f1 | 361 | c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), |
79d43c61 | 362 | stream, show, 1, 0, flags); |
e1cb3213 | 363 | fprintf_filtered (stream, TYPE_CODE(type) == TYPE_CODE_REF ? "&" : "&&"); |
9750e763 | 364 | c_type_print_modifier (type, stream, 1, need_post_space); |
c906108c SS |
365 | break; |
366 | ||
0d5de010 | 367 | case TYPE_CODE_METHOD: |
c906108c | 368 | case TYPE_CODE_FUNC: |
aff410f1 | 369 | c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), |
79d43c61 | 370 | stream, show, 0, 0, flags); |
c906108c SS |
371 | if (passed_a_ptr) |
372 | fprintf_filtered (stream, "("); | |
373 | break; | |
374 | ||
375 | case TYPE_CODE_ARRAY: | |
aff410f1 | 376 | c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), |
79d43c61 | 377 | stream, show, 0, 0, flags); |
c906108c SS |
378 | if (passed_a_ptr) |
379 | fprintf_filtered (stream, "("); | |
380 | break; | |
381 | ||
248f8055 | 382 | case TYPE_CODE_TYPEDEF: |
aff410f1 | 383 | c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), |
79d43c61 | 384 | stream, show, passed_a_ptr, 0, flags); |
248f8055 DJ |
385 | break; |
386 | ||
c906108c SS |
387 | case TYPE_CODE_UNDEF: |
388 | case TYPE_CODE_STRUCT: | |
389 | case TYPE_CODE_UNION: | |
390 | case TYPE_CODE_ENUM: | |
81516450 | 391 | case TYPE_CODE_FLAGS: |
c906108c SS |
392 | case TYPE_CODE_INT: |
393 | case TYPE_CODE_FLT: | |
394 | case TYPE_CODE_VOID: | |
395 | case TYPE_CODE_ERROR: | |
396 | case TYPE_CODE_CHAR: | |
397 | case TYPE_CODE_BOOL: | |
398 | case TYPE_CODE_SET: | |
399 | case TYPE_CODE_RANGE: | |
400 | case TYPE_CODE_STRING: | |
c906108c | 401 | case TYPE_CODE_COMPLEX: |
5c4e30ca | 402 | case TYPE_CODE_NAMESPACE: |
7678ef8f | 403 | case TYPE_CODE_DECFLOAT: |
c906108c | 404 | /* These types need no prefix. They are listed here so that |
c5aa993b | 405 | gcc -Wall will reveal any types that haven't been handled. */ |
c906108c | 406 | break; |
c4093a6a | 407 | default: |
3d263c1d | 408 | error (_("type not handled in c_type_print_varspec_prefix()")); |
c4093a6a | 409 | break; |
c906108c SS |
410 | } |
411 | } | |
412 | ||
64b00020 DE |
413 | /* Print out "const" and "volatile" attributes, |
414 | and address space id if present. | |
c906108c SS |
415 | TYPE is a pointer to the type being printed out. |
416 | STREAM is the output destination. | |
a737a51b DE |
417 | NEED_PRE_SPACE = 1 indicates an initial white space is needed. |
418 | NEED_POST_SPACE = 1 indicates a final white space is needed. */ | |
c906108c SS |
419 | |
420 | static void | |
47663de5 MS |
421 | c_type_print_modifier (struct type *type, struct ui_file *stream, |
422 | int need_pre_space, int need_post_space) | |
c906108c | 423 | { |
47663de5 | 424 | int did_print_modifier = 0; |
321432c0 | 425 | const char *address_space_id; |
c5aa993b | 426 | |
7f0b5c30 JB |
427 | /* We don't print `const' qualifiers for references --- since all |
428 | operators affect the thing referenced, not the reference itself, | |
429 | every reference is `const'. */ | |
e1cb3213 | 430 | if (TYPE_CONST (type) && !TYPE_IS_REFERENCE (type)) |
c906108c SS |
431 | { |
432 | if (need_pre_space) | |
c5aa993b | 433 | fprintf_filtered (stream, " "); |
c906108c | 434 | fprintf_filtered (stream, "const"); |
47663de5 | 435 | did_print_modifier = 1; |
c906108c | 436 | } |
c5aa993b | 437 | |
c906108c SS |
438 | if (TYPE_VOLATILE (type)) |
439 | { | |
47663de5 | 440 | if (did_print_modifier || need_pre_space) |
c5aa993b | 441 | fprintf_filtered (stream, " "); |
c906108c | 442 | fprintf_filtered (stream, "volatile"); |
47663de5 | 443 | did_print_modifier = 1; |
c906108c SS |
444 | } |
445 | ||
06d66ee9 TT |
446 | if (TYPE_RESTRICT (type)) |
447 | { | |
448 | if (did_print_modifier || need_pre_space) | |
449 | fprintf_filtered (stream, " "); | |
450 | fprintf_filtered (stream, "restrict"); | |
451 | did_print_modifier = 1; | |
452 | } | |
453 | ||
a2c2acaf MW |
454 | if (TYPE_ATOMIC (type)) |
455 | { | |
456 | if (did_print_modifier || need_pre_space) | |
457 | fprintf_filtered (stream, " "); | |
458 | fprintf_filtered (stream, "_Atomic"); | |
459 | did_print_modifier = 1; | |
460 | } | |
461 | ||
50810684 UW |
462 | address_space_id = address_space_int_to_name (get_type_arch (type), |
463 | TYPE_INSTANCE_FLAGS (type)); | |
47663de5 MS |
464 | if (address_space_id) |
465 | { | |
466 | if (did_print_modifier || need_pre_space) | |
467 | fprintf_filtered (stream, " "); | |
468 | fprintf_filtered (stream, "@%s", address_space_id); | |
469 | did_print_modifier = 1; | |
470 | } | |
471 | ||
472 | if (did_print_modifier && need_post_space) | |
c906108c SS |
473 | fprintf_filtered (stream, " "); |
474 | } | |
475 | ||
476 | ||
0d5de010 DJ |
477 | /* Print out the arguments of TYPE, which should have TYPE_CODE_METHOD |
478 | or TYPE_CODE_FUNC, to STREAM. Artificial arguments, such as "this" | |
3167638f JK |
479 | in non-static methods, are displayed if LINKAGE_NAME is zero. If |
480 | LINKAGE_NAME is non-zero and LANGUAGE is language_cplus the topmost | |
481 | parameter types get removed their possible const and volatile qualifiers to | |
482 | match demangled linkage name parameters part of such function type. | |
483 | LANGUAGE is the language in which TYPE was defined. This is a necessary | |
9c37b5ae | 484 | evil since this code is used by the C and C++. */ |
c906108c | 485 | |
94af9270 KS |
486 | void |
487 | c_type_print_args (struct type *type, struct ui_file *stream, | |
79d43c61 TT |
488 | int linkage_name, enum language language, |
489 | const struct type_print_options *flags) | |
c906108c | 490 | { |
df54f8eb | 491 | int i; |
0d5de010 | 492 | int printed_any = 0; |
c906108c SS |
493 | |
494 | fprintf_filtered (stream, "("); | |
ad2f7632 | 495 | |
0d5de010 DJ |
496 | for (i = 0; i < TYPE_NFIELDS (type); i++) |
497 | { | |
bc9a5551 JK |
498 | struct type *param_type; |
499 | ||
3167638f | 500 | if (TYPE_FIELD_ARTIFICIAL (type, i) && linkage_name) |
94af9270 KS |
501 | continue; |
502 | ||
0d5de010 | 503 | if (printed_any) |
c906108c | 504 | { |
0d5de010 DJ |
505 | fprintf_filtered (stream, ", "); |
506 | wrap_here (" "); | |
c906108c | 507 | } |
0d5de010 | 508 | |
bc9a5551 JK |
509 | param_type = TYPE_FIELD_TYPE (type, i); |
510 | ||
3167638f | 511 | if (language == language_cplus && linkage_name) |
bc9a5551 JK |
512 | { |
513 | /* C++ standard, 13.1 Overloadable declarations, point 3, item: | |
514 | - Parameter declarations that differ only in the presence or | |
515 | absence of const and/or volatile are equivalent. | |
516 | ||
517 | And the const/volatile qualifiers are not present in the mangled | |
518 | names as produced by GCC. */ | |
519 | ||
520 | param_type = make_cv_type (0, 0, param_type, NULL); | |
521 | } | |
522 | ||
9c37b5ae | 523 | c_print_type (param_type, "", stream, -1, 0, flags); |
0d5de010 | 524 | printed_any = 1; |
c906108c | 525 | } |
0d5de010 DJ |
526 | |
527 | if (printed_any && TYPE_VARARGS (type)) | |
c906108c | 528 | { |
0d5de010 DJ |
529 | /* Print out a trailing ellipsis for varargs functions. Ignore |
530 | TYPE_VARARGS if the function has no named arguments; that | |
531 | represents unprototyped (K&R style) C functions. */ | |
532 | if (printed_any && TYPE_VARARGS (type)) | |
533 | { | |
534 | fprintf_filtered (stream, ", "); | |
535 | wrap_here (" "); | |
536 | fprintf_filtered (stream, "..."); | |
537 | } | |
c906108c | 538 | } |
0d5de010 | 539 | else if (!printed_any |
9c37b5ae | 540 | && (TYPE_PROTOTYPED (type) || language == language_cplus)) |
0d5de010 | 541 | fprintf_filtered (stream, "void"); |
c5aa993b | 542 | |
c906108c SS |
543 | fprintf_filtered (stream, ")"); |
544 | } | |
545 | ||
dfcd3bfb JM |
546 | /* Return true iff the j'th overloading of the i'th method of TYPE |
547 | is a type conversion operator, like `operator int () { ... }'. | |
548 | When listing a class's methods, we don't print the return type of | |
549 | such operators. */ | |
a737a51b | 550 | |
dfcd3bfb JM |
551 | static int |
552 | is_type_conversion_operator (struct type *type, int i, int j) | |
553 | { | |
554 | /* I think the whole idea of recognizing type conversion operators | |
555 | by their name is pretty terrible. But I don't think our present | |
556 | data structure gives us any other way to tell. If you know of | |
557 | some other way, feel free to rewrite this function. */ | |
0d5cff50 | 558 | const char *name = TYPE_FN_FIELDLIST_NAME (type, i); |
dfcd3bfb | 559 | |
8090b426 | 560 | if (!startswith (name, CP_OPERATOR_STR)) |
dfcd3bfb JM |
561 | return 0; |
562 | ||
563 | name += 8; | |
564 | if (! strchr (" \t\f\n\r", *name)) | |
565 | return 0; | |
566 | ||
567 | while (strchr (" \t\f\n\r", *name)) | |
568 | name++; | |
569 | ||
b0129042 DJ |
570 | if (!('a' <= *name && *name <= 'z') |
571 | && !('A' <= *name && *name <= 'Z') | |
572 | && *name != '_') | |
573 | /* If this doesn't look like the start of an identifier, then it | |
574 | isn't a type conversion operator. */ | |
575 | return 0; | |
61012eef | 576 | else if (startswith (name, "new")) |
dfcd3bfb | 577 | name += 3; |
61012eef | 578 | else if (startswith (name, "delete")) |
dfcd3bfb JM |
579 | name += 6; |
580 | else | |
39c22d1a JM |
581 | /* If it doesn't look like new or delete, it's a type conversion |
582 | operator. */ | |
583 | return 1; | |
dfcd3bfb JM |
584 | |
585 | /* Is that really the end of the name? */ | |
586 | if (('a' <= *name && *name <= 'z') | |
587 | || ('A' <= *name && *name <= 'Z') | |
588 | || ('0' <= *name && *name <= '9') | |
589 | || *name == '_') | |
590 | /* No, so the identifier following "operator" must be a type name, | |
591 | and this is a type conversion operator. */ | |
592 | return 1; | |
593 | ||
594 | /* That was indeed the end of the name, so it was `operator new' or | |
aff410f1 MS |
595 | `operator delete', neither of which are type conversion |
596 | operators. */ | |
dfcd3bfb JM |
597 | return 0; |
598 | } | |
599 | ||
dfcd3bfb JM |
600 | /* Given a C++ qualified identifier QID, strip off the qualifiers, |
601 | yielding the unqualified name. The return value is a pointer into | |
602 | the original string. | |
603 | ||
604 | It's a pity we don't have this information in some more structured | |
605 | form. Even the author of this function feels that writing little | |
606 | parsers like this everywhere is stupid. */ | |
a737a51b | 607 | |
dfcd3bfb JM |
608 | static char * |
609 | remove_qualifiers (char *qid) | |
610 | { | |
0963b4bd | 611 | int quoted = 0; /* Zero if we're not in quotes; |
aff410f1 MS |
612 | '"' if we're in a double-quoted string; |
613 | '\'' if we're in a single-quoted string. */ | |
0963b4bd | 614 | int depth = 0; /* Number of unclosed parens we've seen. */ |
dfcd3bfb JM |
615 | char *parenstack = (char *) alloca (strlen (qid)); |
616 | char *scan; | |
aff410f1 MS |
617 | char *last = 0; /* The character after the rightmost |
618 | `::' token we've seen so far. */ | |
dfcd3bfb JM |
619 | |
620 | for (scan = qid; *scan; scan++) | |
621 | { | |
622 | if (quoted) | |
623 | { | |
624 | if (*scan == quoted) | |
625 | quoted = 0; | |
626 | else if (*scan == '\\' && *(scan + 1)) | |
627 | scan++; | |
628 | } | |
629 | else if (scan[0] == ':' && scan[1] == ':') | |
630 | { | |
631 | /* If we're inside parenthesis (i.e., an argument list) or | |
632 | angle brackets (i.e., a list of template arguments), then | |
633 | we don't record the position of this :: token, since it's | |
aff410f1 MS |
634 | not relevant to the top-level structure we're trying to |
635 | operate on. */ | |
dfcd3bfb JM |
636 | if (depth == 0) |
637 | { | |
638 | last = scan + 2; | |
639 | scan++; | |
640 | } | |
641 | } | |
642 | else if (*scan == '"' || *scan == '\'') | |
643 | quoted = *scan; | |
644 | else if (*scan == '(') | |
645 | parenstack[depth++] = ')'; | |
646 | else if (*scan == '[') | |
647 | parenstack[depth++] = ']'; | |
648 | /* We're going to treat <> as a pair of matching characters, | |
649 | since we're more likely to see those in template id's than | |
650 | real less-than characters. What a crock. */ | |
651 | else if (*scan == '<') | |
652 | parenstack[depth++] = '>'; | |
653 | else if (*scan == ')' || *scan == ']' || *scan == '>') | |
654 | { | |
655 | if (depth > 0 && parenstack[depth - 1] == *scan) | |
656 | depth--; | |
657 | else | |
658 | { | |
aff410f1 MS |
659 | /* We're going to do a little error recovery here. If |
660 | we don't find a match for *scan on the paren stack, | |
661 | but there is something lower on the stack that does | |
662 | match, we pop the stack to that point. */ | |
dfcd3bfb JM |
663 | int i; |
664 | ||
665 | for (i = depth - 1; i >= 0; i--) | |
666 | if (parenstack[i] == *scan) | |
667 | { | |
668 | depth = i; | |
669 | break; | |
670 | } | |
671 | } | |
672 | } | |
673 | } | |
674 | ||
675 | if (last) | |
676 | return last; | |
677 | else | |
678 | /* We didn't find any :: tokens at the top level, so declare the | |
679 | whole thing an unqualified identifier. */ | |
680 | return qid; | |
681 | } | |
682 | ||
c906108c SS |
683 | /* Print any array sizes, function arguments or close parentheses |
684 | needed after the variable name (to describe its type). | |
685 | Args work like c_type_print_varspec_prefix. */ | |
686 | ||
687 | void | |
aff410f1 MS |
688 | c_type_print_varspec_suffix (struct type *type, |
689 | struct ui_file *stream, | |
690 | int show, int passed_a_ptr, | |
79d43c61 TT |
691 | int demangled_args, |
692 | const struct type_print_options *flags) | |
c906108c SS |
693 | { |
694 | if (type == 0) | |
695 | return; | |
696 | ||
697 | if (TYPE_NAME (type) && show <= 0) | |
698 | return; | |
699 | ||
700 | QUIT; | |
701 | ||
702 | switch (TYPE_CODE (type)) | |
703 | { | |
704 | case TYPE_CODE_ARRAY: | |
dbc98a8b KW |
705 | { |
706 | LONGEST low_bound, high_bound; | |
42056501 | 707 | int is_vector = TYPE_VECTOR (type); |
c5aa993b | 708 | |
dbc98a8b KW |
709 | if (passed_a_ptr) |
710 | fprintf_filtered (stream, ")"); | |
c5aa993b | 711 | |
42056501 | 712 | fprintf_filtered (stream, (is_vector ? |
2f27adfe | 713 | " __attribute__ ((vector_size(" : "[")); |
1d42e4c4 SA |
714 | /* Bounds are not yet resolved, print a bounds placeholder instead. */ |
715 | if (TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCEXPR | |
716 | || TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCLIST) | |
717 | fprintf_filtered (stream, "variable length"); | |
718 | else if (get_array_bounds (type, &low_bound, &high_bound)) | |
318102b9 SP |
719 | fprintf_filtered (stream, "%s", |
720 | plongest (high_bound - low_bound + 1)); | |
42056501 | 721 | fprintf_filtered (stream, (is_vector ? ")))" : "]")); |
dbc98a8b | 722 | |
aff410f1 | 723 | c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, |
79d43c61 | 724 | show, 0, 0, flags); |
dbc98a8b | 725 | } |
c906108c SS |
726 | break; |
727 | ||
0d5de010 | 728 | case TYPE_CODE_MEMBERPTR: |
aff410f1 | 729 | c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, |
79d43c61 | 730 | show, 0, 0, flags); |
c906108c SS |
731 | break; |
732 | ||
0d5de010 DJ |
733 | case TYPE_CODE_METHODPTR: |
734 | fprintf_filtered (stream, ")"); | |
aff410f1 | 735 | c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, |
79d43c61 | 736 | show, 0, 0, flags); |
c906108c SS |
737 | break; |
738 | ||
739 | case TYPE_CODE_PTR: | |
740 | case TYPE_CODE_REF: | |
e1cb3213 | 741 | case TYPE_CODE_RVALUE_REF: |
aff410f1 | 742 | c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, |
79d43c61 | 743 | show, 1, 0, flags); |
c906108c SS |
744 | break; |
745 | ||
0d5de010 | 746 | case TYPE_CODE_METHOD: |
c906108c SS |
747 | case TYPE_CODE_FUNC: |
748 | if (passed_a_ptr) | |
749 | fprintf_filtered (stream, ")"); | |
750 | if (!demangled_args) | |
79d43c61 TT |
751 | c_type_print_args (type, stream, 0, current_language->la_language, |
752 | flags); | |
aff410f1 | 753 | c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, |
79d43c61 | 754 | show, passed_a_ptr, 0, flags); |
248f8055 DJ |
755 | break; |
756 | ||
757 | case TYPE_CODE_TYPEDEF: | |
aff410f1 | 758 | c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, |
79d43c61 | 759 | show, passed_a_ptr, 0, flags); |
c906108c SS |
760 | break; |
761 | ||
762 | case TYPE_CODE_UNDEF: | |
763 | case TYPE_CODE_STRUCT: | |
764 | case TYPE_CODE_UNION: | |
81516450 | 765 | case TYPE_CODE_FLAGS: |
c906108c SS |
766 | case TYPE_CODE_ENUM: |
767 | case TYPE_CODE_INT: | |
768 | case TYPE_CODE_FLT: | |
769 | case TYPE_CODE_VOID: | |
770 | case TYPE_CODE_ERROR: | |
771 | case TYPE_CODE_CHAR: | |
772 | case TYPE_CODE_BOOL: | |
773 | case TYPE_CODE_SET: | |
774 | case TYPE_CODE_RANGE: | |
775 | case TYPE_CODE_STRING: | |
c906108c | 776 | case TYPE_CODE_COMPLEX: |
5c4e30ca | 777 | case TYPE_CODE_NAMESPACE: |
7678ef8f | 778 | case TYPE_CODE_DECFLOAT: |
c906108c | 779 | /* These types do not need a suffix. They are listed so that |
aff410f1 MS |
780 | gcc -Wall will report types that may not have been |
781 | considered. */ | |
c906108c | 782 | break; |
c4093a6a | 783 | default: |
3d263c1d | 784 | error (_("type not handled in c_type_print_varspec_suffix()")); |
c4093a6a | 785 | break; |
c906108c SS |
786 | } |
787 | } | |
788 | ||
bd69fc68 TT |
789 | /* A helper for c_type_print_base that displays template |
790 | parameters and their bindings, if needed. | |
791 | ||
792 | TABLE is the local bindings table to use. If NULL, no printing is | |
793 | done. Note that, at this point, TABLE won't have any useful | |
794 | information in it -- but it is also used as a flag to | |
795 | print_name_maybe_canonical to activate searching the global typedef | |
796 | table. | |
797 | ||
798 | TYPE is the type whose template arguments are being displayed. | |
799 | ||
800 | STREAM is the stream on which to print. */ | |
801 | ||
802 | static void | |
803 | c_type_print_template_args (const struct type_print_options *flags, | |
804 | struct type *type, struct ui_file *stream) | |
805 | { | |
806 | int first = 1, i; | |
807 | ||
808 | if (flags->raw) | |
809 | return; | |
810 | ||
811 | for (i = 0; i < TYPE_N_TEMPLATE_ARGUMENTS (type); ++i) | |
812 | { | |
813 | struct symbol *sym = TYPE_TEMPLATE_ARGUMENT (type, i); | |
814 | ||
815 | if (SYMBOL_CLASS (sym) != LOC_TYPEDEF) | |
816 | continue; | |
817 | ||
818 | if (first) | |
819 | { | |
820 | wrap_here (" "); | |
821 | fprintf_filtered (stream, _("[with %s = "), | |
822 | SYMBOL_LINKAGE_NAME (sym)); | |
823 | first = 0; | |
824 | } | |
825 | else | |
826 | { | |
827 | fputs_filtered (", ", stream); | |
828 | wrap_here (" "); | |
829 | fprintf_filtered (stream, "%s = ", SYMBOL_LINKAGE_NAME (sym)); | |
830 | } | |
831 | ||
832 | c_print_type (SYMBOL_TYPE (sym), "", stream, -1, 0, flags); | |
833 | } | |
834 | ||
835 | if (!first) | |
836 | fputs_filtered (_("] "), stream); | |
837 | } | |
838 | ||
c191a687 KS |
839 | /* Output an access specifier to STREAM, if needed. LAST_ACCESS is the |
840 | last access specifier output (typically returned by this function). */ | |
841 | ||
842 | static enum access_specifier | |
843 | output_access_specifier (struct ui_file *stream, | |
844 | enum access_specifier last_access, | |
845 | int level, bool is_protected, bool is_private) | |
846 | { | |
847 | if (is_protected) | |
848 | { | |
849 | if (last_access != s_protected) | |
850 | { | |
851 | last_access = s_protected; | |
852 | fprintfi_filtered (level + 2, stream, | |
853 | "protected:\n"); | |
854 | } | |
855 | } | |
856 | else if (is_private) | |
857 | { | |
858 | if (last_access != s_private) | |
859 | { | |
860 | last_access = s_private; | |
861 | fprintfi_filtered (level + 2, stream, | |
862 | "private:\n"); | |
863 | } | |
864 | } | |
865 | else | |
866 | { | |
867 | if (last_access != s_public) | |
868 | { | |
869 | last_access = s_public; | |
870 | fprintfi_filtered (level + 2, stream, | |
871 | "public:\n"); | |
872 | } | |
873 | } | |
874 | ||
875 | return last_access; | |
876 | } | |
877 | ||
c906108c | 878 | /* Print the name of the type (or the ultimate pointer target, |
aff410f1 MS |
879 | function value or array element), or the description of a structure |
880 | or union. | |
881 | ||
882 | SHOW positive means print details about the type (e.g. enum | |
883 | values), and print structure elements passing SHOW - 1 for show. | |
884 | ||
885 | SHOW negative means just print the type name or struct tag if there | |
886 | is one. If there is no name, print something sensible but concise | |
887 | like "struct {...}". | |
888 | ||
889 | SHOW zero means just print the type name or struct tag if there is | |
890 | one. If there is no name, print something sensible but not as | |
891 | concise like "struct {int x; int y;}". | |
c906108c SS |
892 | |
893 | LEVEL is the number of spaces to indent by. | |
894 | We increase it for some recursive calls. */ | |
895 | ||
896 | void | |
aff410f1 | 897 | c_type_print_base (struct type *type, struct ui_file *stream, |
79d43c61 | 898 | int show, int level, const struct type_print_options *flags) |
c906108c | 899 | { |
b02dede2 DJ |
900 | int i; |
901 | int len, real_len; | |
c191a687 | 902 | enum access_specifier section_type; |
c906108c SS |
903 | int need_access_label = 0; |
904 | int j, len2; | |
905 | ||
906 | QUIT; | |
907 | ||
c906108c SS |
908 | if (type == NULL) |
909 | { | |
3d263c1d | 910 | fputs_filtered (_("<type unknown>"), stream); |
c906108c SS |
911 | return; |
912 | } | |
913 | ||
aff410f1 MS |
914 | /* When SHOW is zero or less, and there is a valid type name, then |
915 | always just print the type name directly from the type. */ | |
916 | /* If we have "typedef struct foo {. . .} bar;" do we want to print | |
917 | it as "struct foo" or as "bar"? Pick the latter, because C++ | |
918 | folk tend to expect things like "class5 *foo" rather than "struct | |
919 | class5 *foo". */ | |
c906108c SS |
920 | |
921 | if (show <= 0 | |
922 | && TYPE_NAME (type) != NULL) | |
923 | { | |
47663de5 | 924 | c_type_print_modifier (type, stream, 0, 1); |
bd69fc68 | 925 | print_name_maybe_canonical (TYPE_NAME (type), flags, stream); |
c906108c SS |
926 | return; |
927 | } | |
928 | ||
f168693b | 929 | type = check_typedef (type); |
c5aa993b | 930 | |
c906108c SS |
931 | switch (TYPE_CODE (type)) |
932 | { | |
933 | case TYPE_CODE_TYPEDEF: | |
aff410f1 MS |
934 | /* If we get here, the typedef doesn't have a name, and we |
935 | couldn't resolve TYPE_TARGET_TYPE. Not much we can do. */ | |
8c540a24 DE |
936 | gdb_assert (TYPE_NAME (type) == NULL); |
937 | gdb_assert (TYPE_TARGET_TYPE (type) == NULL); | |
938 | fprintf_filtered (stream, _("<unnamed typedef>")); | |
939 | break; | |
940 | ||
7022349d PA |
941 | case TYPE_CODE_FUNC: |
942 | case TYPE_CODE_METHOD: | |
943 | if (TYPE_TARGET_TYPE (type) == NULL) | |
944 | type_print_unknown_return_type (stream); | |
945 | else | |
946 | c_type_print_base (TYPE_TARGET_TYPE (type), | |
947 | stream, show, level, flags); | |
948 | break; | |
c906108c SS |
949 | case TYPE_CODE_ARRAY: |
950 | case TYPE_CODE_PTR: | |
0d5de010 | 951 | case TYPE_CODE_MEMBERPTR: |
c906108c | 952 | case TYPE_CODE_REF: |
e1cb3213 | 953 | case TYPE_CODE_RVALUE_REF: |
0d5de010 | 954 | case TYPE_CODE_METHODPTR: |
aff410f1 | 955 | c_type_print_base (TYPE_TARGET_TYPE (type), |
79d43c61 | 956 | stream, show, level, flags); |
c906108c SS |
957 | break; |
958 | ||
959 | case TYPE_CODE_STRUCT: | |
1c5b7826 | 960 | case TYPE_CODE_UNION: |
bd69fc68 TT |
961 | { |
962 | struct type_print_options local_flags = *flags; | |
963 | struct type_print_options semi_local_flags = *flags; | |
964 | struct cleanup *local_cleanups = make_cleanup (null_cleanup, NULL); | |
965 | ||
966 | local_flags.local_typedefs = NULL; | |
967 | semi_local_flags.local_typedefs = NULL; | |
968 | ||
969 | if (!flags->raw) | |
970 | { | |
971 | if (flags->local_typedefs) | |
972 | local_flags.local_typedefs | |
973 | = copy_typedef_hash (flags->local_typedefs); | |
974 | else | |
975 | local_flags.local_typedefs = create_typedef_hash (); | |
976 | ||
977 | make_cleanup_free_typedef_hash (local_flags.local_typedefs); | |
978 | } | |
979 | ||
980 | c_type_print_modifier (type, stream, 0, 1); | |
981 | if (TYPE_CODE (type) == TYPE_CODE_UNION) | |
982 | fprintf_filtered (stream, "union "); | |
983 | else if (TYPE_DECLARED_CLASS (type)) | |
984 | fprintf_filtered (stream, "class "); | |
985 | else | |
986 | fprintf_filtered (stream, "struct "); | |
987 | ||
988 | /* Print the tag if it exists. The HP aCC compiler emits a | |
989 | spurious "{unnamed struct}"/"{unnamed union}"/"{unnamed | |
990 | enum}" tag for unnamed struct/union/enum's, which we don't | |
991 | want to print. */ | |
992 | if (TYPE_TAG_NAME (type) != NULL | |
61012eef | 993 | && !startswith (TYPE_TAG_NAME (type), "{unnamed")) |
bd69fc68 TT |
994 | { |
995 | /* When printing the tag name, we are still effectively | |
996 | printing in the outer context, hence the use of FLAGS | |
997 | here. */ | |
998 | print_name_maybe_canonical (TYPE_TAG_NAME (type), flags, stream); | |
999 | if (show > 0) | |
1000 | fputs_filtered (" ", stream); | |
1001 | } | |
1002 | ||
1003 | if (show < 0) | |
1004 | { | |
1005 | /* If we just printed a tag name, no need to print anything | |
1006 | else. */ | |
1007 | if (TYPE_TAG_NAME (type) == NULL) | |
1008 | fprintf_filtered (stream, "{...}"); | |
1009 | } | |
1010 | else if (show > 0 || TYPE_TAG_NAME (type) == NULL) | |
1011 | { | |
1012 | struct type *basetype; | |
1013 | int vptr_fieldno; | |
1014 | ||
1015 | c_type_print_template_args (&local_flags, type, stream); | |
1016 | ||
1017 | /* Add in template parameters when printing derivation info. */ | |
1018 | add_template_parameters (local_flags.local_typedefs, type); | |
1019 | cp_type_print_derivation_info (stream, type, &local_flags); | |
1020 | ||
1021 | /* This holds just the global typedefs and the template | |
1022 | parameters. */ | |
1023 | semi_local_flags.local_typedefs | |
1024 | = copy_typedef_hash (local_flags.local_typedefs); | |
1025 | if (semi_local_flags.local_typedefs) | |
1026 | make_cleanup_free_typedef_hash (semi_local_flags.local_typedefs); | |
1027 | ||
1028 | /* Now add in the local typedefs. */ | |
1029 | recursively_update_typedef_hash (local_flags.local_typedefs, type); | |
1030 | ||
1031 | fprintf_filtered (stream, "{\n"); | |
1032 | if (TYPE_NFIELDS (type) == 0 && TYPE_NFN_FIELDS (type) == 0 | |
1033 | && TYPE_TYPEDEF_FIELD_COUNT (type) == 0) | |
1034 | { | |
1035 | if (TYPE_STUB (type)) | |
1036 | fprintfi_filtered (level + 4, stream, | |
1037 | _("<incomplete type>\n")); | |
1038 | else | |
1039 | fprintfi_filtered (level + 4, stream, | |
1040 | _("<no data fields>\n")); | |
1041 | } | |
1042 | ||
1043 | /* Start off with no specific section type, so we can print | |
1044 | one for the first field we find, and use that section type | |
1045 | thereafter until we find another type. */ | |
1046 | ||
1047 | section_type = s_none; | |
1048 | ||
1049 | /* For a class, if all members are private, there's no need | |
1050 | for a "private:" label; similarly, for a struct or union | |
1051 | masquerading as a class, if all members are public, there's | |
1052 | no need for a "public:" label. */ | |
1053 | ||
1054 | if (TYPE_DECLARED_CLASS (type)) | |
1055 | { | |
1056 | QUIT; | |
1057 | len = TYPE_NFIELDS (type); | |
1058 | for (i = TYPE_N_BASECLASSES (type); i < len; i++) | |
1059 | if (!TYPE_FIELD_PRIVATE (type, i)) | |
c5aa993b | 1060 | { |
bd69fc68 TT |
1061 | need_access_label = 1; |
1062 | break; | |
c5aa993b | 1063 | } |
bd69fc68 TT |
1064 | QUIT; |
1065 | if (!need_access_label) | |
c5aa993b | 1066 | { |
bd69fc68 TT |
1067 | len2 = TYPE_NFN_FIELDS (type); |
1068 | for (j = 0; j < len2; j++) | |
1069 | { | |
1070 | len = TYPE_FN_FIELDLIST_LENGTH (type, j); | |
1071 | for (i = 0; i < len; i++) | |
1072 | if (!TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type, | |
1073 | j), i)) | |
1074 | { | |
1075 | need_access_label = 1; | |
1076 | break; | |
1077 | } | |
1078 | if (need_access_label) | |
1079 | break; | |
1080 | } | |
c5aa993b | 1081 | } |
c191a687 KS |
1082 | QUIT; |
1083 | if (!need_access_label) | |
1084 | { | |
1085 | for (i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); ++i) | |
1086 | { | |
1087 | if (!TYPE_TYPEDEF_FIELD_PRIVATE (type, i)) | |
1088 | { | |
1089 | need_access_label = 1; | |
1090 | break; | |
1091 | } | |
1092 | } | |
1093 | } | |
bd69fc68 TT |
1094 | } |
1095 | else | |
1096 | { | |
1097 | QUIT; | |
1098 | len = TYPE_NFIELDS (type); | |
1099 | for (i = TYPE_N_BASECLASSES (type); i < len; i++) | |
1100 | if (TYPE_FIELD_PRIVATE (type, i) | |
1101 | || TYPE_FIELD_PROTECTED (type, i)) | |
c5aa993b | 1102 | { |
bd69fc68 TT |
1103 | need_access_label = 1; |
1104 | break; | |
c5aa993b | 1105 | } |
bd69fc68 TT |
1106 | QUIT; |
1107 | if (!need_access_label) | |
1108 | { | |
1109 | len2 = TYPE_NFN_FIELDS (type); | |
1110 | for (j = 0; j < len2; j++) | |
1111 | { | |
1112 | QUIT; | |
1113 | len = TYPE_FN_FIELDLIST_LENGTH (type, j); | |
1114 | for (i = 0; i < len; i++) | |
1115 | if (TYPE_FN_FIELD_PROTECTED (TYPE_FN_FIELDLIST1 (type, | |
1116 | j), i) | |
1117 | || TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type, | |
1118 | j), | |
1119 | i)) | |
1120 | { | |
1121 | need_access_label = 1; | |
1122 | break; | |
1123 | } | |
1124 | if (need_access_label) | |
1125 | break; | |
1126 | } | |
1127 | } | |
c191a687 KS |
1128 | QUIT; |
1129 | if (!need_access_label) | |
1130 | { | |
1131 | for (i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); ++i) | |
1132 | { | |
1133 | if (TYPE_TYPEDEF_FIELD_PROTECTED (type, i) | |
1134 | || TYPE_TYPEDEF_FIELD_PRIVATE (type, i)) | |
1135 | { | |
1136 | need_access_label = 1; | |
1137 | break; | |
1138 | } | |
1139 | } | |
1140 | } | |
bd69fc68 | 1141 | } |
c906108c | 1142 | |
bd69fc68 TT |
1143 | /* If there is a base class for this type, |
1144 | do not print the field that it occupies. */ | |
c906108c | 1145 | |
bd69fc68 TT |
1146 | len = TYPE_NFIELDS (type); |
1147 | vptr_fieldno = get_vptr_fieldno (type, &basetype); | |
1148 | for (i = TYPE_N_BASECLASSES (type); i < len; i++) | |
1149 | { | |
1150 | QUIT; | |
d48cc9dd | 1151 | |
bd69fc68 TT |
1152 | /* If we have a virtual table pointer, omit it. Even if |
1153 | virtual table pointers are not specifically marked in | |
1154 | the debug info, they should be artificial. */ | |
1155 | if ((i == vptr_fieldno && type == basetype) | |
1156 | || TYPE_FIELD_ARTIFICIAL (type, i)) | |
1157 | continue; | |
c906108c | 1158 | |
bd69fc68 TT |
1159 | if (need_access_label) |
1160 | { | |
c191a687 KS |
1161 | section_type = output_access_specifier |
1162 | (stream, section_type, level, | |
1163 | TYPE_FIELD_PROTECTED (type, i), | |
1164 | TYPE_FIELD_PRIVATE (type, i)); | |
bd69fc68 | 1165 | } |
c906108c | 1166 | |
bd69fc68 TT |
1167 | print_spaces_filtered (level + 4, stream); |
1168 | if (field_is_static (&TYPE_FIELD (type, i))) | |
1169 | fprintf_filtered (stream, "static "); | |
1170 | c_print_type (TYPE_FIELD_TYPE (type, i), | |
1171 | TYPE_FIELD_NAME (type, i), | |
1172 | stream, show - 1, level + 4, | |
1173 | &local_flags); | |
1174 | if (!field_is_static (&TYPE_FIELD (type, i)) | |
1175 | && TYPE_FIELD_PACKED (type, i)) | |
1176 | { | |
1177 | /* It is a bitfield. This code does not attempt | |
1178 | to look at the bitpos and reconstruct filler, | |
1179 | unnamed fields. This would lead to misleading | |
1180 | results if the compiler does not put out fields | |
1181 | for such things (I don't know what it does). */ | |
1182 | fprintf_filtered (stream, " : %d", | |
1183 | TYPE_FIELD_BITSIZE (type, i)); | |
1184 | } | |
1185 | fprintf_filtered (stream, ";\n"); | |
1186 | } | |
c906108c | 1187 | |
b02dede2 | 1188 | /* If there are both fields and methods, put a blank line |
aff410f1 MS |
1189 | between them. Make sure to count only method that we |
1190 | will display; artificial methods will be hidden. */ | |
c906108c | 1191 | len = TYPE_NFN_FIELDS (type); |
53342f27 TT |
1192 | if (!flags->print_methods) |
1193 | len = 0; | |
b02dede2 DJ |
1194 | real_len = 0; |
1195 | for (i = 0; i < len; i++) | |
1196 | { | |
1197 | struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); | |
1198 | int len2 = TYPE_FN_FIELDLIST_LENGTH (type, i); | |
1199 | int j; | |
c5504eaf | 1200 | |
b02dede2 DJ |
1201 | for (j = 0; j < len2; j++) |
1202 | if (!TYPE_FN_FIELD_ARTIFICIAL (f, j)) | |
1203 | real_len++; | |
1204 | } | |
1205 | if (real_len > 0 && section_type != s_none) | |
c5aa993b | 1206 | fprintf_filtered (stream, "\n"); |
c906108c | 1207 | |
0963b4bd | 1208 | /* C++: print out the methods. */ |
c906108c SS |
1209 | for (i = 0; i < len; i++) |
1210 | { | |
1211 | struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); | |
1212 | int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i); | |
0d5cff50 DE |
1213 | const char *method_name = TYPE_FN_FIELDLIST_NAME (type, i); |
1214 | const char *name = type_name_no_tag (type); | |
aff410f1 MS |
1215 | int is_constructor = name && strcmp (method_name, |
1216 | name) == 0; | |
c5504eaf | 1217 | |
c906108c SS |
1218 | for (j = 0; j < len2; j++) |
1219 | { | |
1d06ead6 | 1220 | const char *mangled_name; |
331b71e5 | 1221 | gdb::unique_xmalloc_ptr<char> mangled_name_holder; |
1d06ead6 | 1222 | char *demangled_name; |
1d06ead6 | 1223 | const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j); |
c5aa993b | 1224 | int is_full_physname_constructor = |
7d27a96d TT |
1225 | TYPE_FN_FIELD_CONSTRUCTOR (f, j) |
1226 | || is_constructor_name (physname) | |
c5504eaf MS |
1227 | || is_destructor_name (physname) |
1228 | || method_name[0] == '~'; | |
015a42b4 | 1229 | |
b02dede2 DJ |
1230 | /* Do not print out artificial methods. */ |
1231 | if (TYPE_FN_FIELD_ARTIFICIAL (f, j)) | |
1232 | continue; | |
c906108c SS |
1233 | |
1234 | QUIT; | |
c191a687 KS |
1235 | section_type = output_access_specifier |
1236 | (stream, section_type, level, | |
1237 | TYPE_FN_FIELD_PROTECTED (f, j), | |
1238 | TYPE_FN_FIELD_PRIVATE (f, j)); | |
c906108c SS |
1239 | |
1240 | print_spaces_filtered (level + 4, stream); | |
1241 | if (TYPE_FN_FIELD_VIRTUAL_P (f, j)) | |
1242 | fprintf_filtered (stream, "virtual "); | |
1243 | else if (TYPE_FN_FIELD_STATIC_P (f, j)) | |
1244 | fprintf_filtered (stream, "static "); | |
1245 | if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0) | |
1246 | { | |
1247 | /* Keep GDB from crashing here. */ | |
aff410f1 MS |
1248 | fprintf_filtered (stream, |
1249 | _("<undefined type> %s;\n"), | |
c5aa993b | 1250 | TYPE_FN_FIELD_PHYSNAME (f, j)); |
c906108c SS |
1251 | break; |
1252 | } | |
aff410f1 MS |
1253 | else if (!is_constructor /* Constructors don't |
1254 | have declared | |
1255 | types. */ | |
1256 | && !is_full_physname_constructor /* " " */ | |
5aafa1cc | 1257 | && !is_type_conversion_operator (type, i, j)) |
c906108c | 1258 | { |
6c8702eb | 1259 | c_print_type (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)), |
bd69fc68 TT |
1260 | "", stream, -1, 0, |
1261 | &local_flags); | |
c906108c SS |
1262 | fputs_filtered (" ", stream); |
1263 | } | |
1264 | if (TYPE_FN_FIELD_STUB (f, j)) | |
1d06ead6 | 1265 | { |
1d06ead6 | 1266 | /* Build something we can demangle. */ |
331b71e5 TT |
1267 | mangled_name_holder.reset (gdb_mangle_name (type, i, j)); |
1268 | mangled_name = mangled_name_holder.get (); | |
1d06ead6 | 1269 | } |
c906108c SS |
1270 | else |
1271 | mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j); | |
1272 | ||
1273 | demangled_name = | |
8de20a37 TT |
1274 | gdb_demangle (mangled_name, |
1275 | DMGL_ANSI | DMGL_PARAMS); | |
c906108c SS |
1276 | if (demangled_name == NULL) |
1277 | { | |
aff410f1 | 1278 | /* In some cases (for instance with the HP |
bd69fc68 TT |
1279 | demangling), if a function has more than 10 |
1280 | arguments, the demangling will fail. | |
1281 | Let's try to reconstruct the function | |
1282 | signature from the symbol information. */ | |
c906108c | 1283 | if (!TYPE_FN_FIELD_STUB (f, j)) |
ad2f7632 DJ |
1284 | { |
1285 | int staticp = TYPE_FN_FIELD_STATIC_P (f, j); | |
1286 | struct type *mtype = TYPE_FN_FIELD_TYPE (f, j); | |
c5504eaf | 1287 | |
ad2f7632 DJ |
1288 | cp_type_print_method_args (mtype, |
1289 | "", | |
1290 | method_name, | |
1291 | staticp, | |
bd69fc68 | 1292 | stream, &local_flags); |
ad2f7632 | 1293 | } |
c906108c | 1294 | else |
aff410f1 MS |
1295 | fprintf_filtered (stream, |
1296 | _("<badly mangled name '%s'>"), | |
c906108c SS |
1297 | mangled_name); |
1298 | } | |
1299 | else | |
1300 | { | |
1301 | char *p; | |
dfcd3bfb JM |
1302 | char *demangled_no_class |
1303 | = remove_qualifiers (demangled_name); | |
c5aa993b | 1304 | |
aff410f1 MS |
1305 | /* Get rid of the `static' appended by the |
1306 | demangler. */ | |
c906108c SS |
1307 | p = strstr (demangled_no_class, " static"); |
1308 | if (p != NULL) | |
1309 | { | |
1310 | int length = p - demangled_no_class; | |
1d06ead6 | 1311 | char *demangled_no_static; |
c5504eaf | 1312 | |
aff410f1 MS |
1313 | demangled_no_static |
1314 | = (char *) xmalloc (length + 1); | |
1315 | strncpy (demangled_no_static, | |
1316 | demangled_no_class, length); | |
c5aa993b | 1317 | *(demangled_no_static + length) = '\0'; |
c906108c | 1318 | fputs_filtered (demangled_no_static, stream); |
b8c9b27d | 1319 | xfree (demangled_no_static); |
c906108c SS |
1320 | } |
1321 | else | |
1322 | fputs_filtered (demangled_no_class, stream); | |
b8c9b27d | 1323 | xfree (demangled_name); |
c906108c SS |
1324 | } |
1325 | ||
c906108c SS |
1326 | fprintf_filtered (stream, ";\n"); |
1327 | } | |
1328 | } | |
1329 | ||
98751a41 JK |
1330 | /* Print typedefs defined in this class. */ |
1331 | ||
53342f27 | 1332 | if (TYPE_TYPEDEF_FIELD_COUNT (type) != 0 && flags->print_typedefs) |
98751a41 JK |
1333 | { |
1334 | if (TYPE_NFIELDS (type) != 0 || TYPE_NFN_FIELDS (type) != 0) | |
1335 | fprintf_filtered (stream, "\n"); | |
1336 | ||
a579cd9a MW |
1337 | for (i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); i++) |
1338 | { | |
1339 | struct type *target = TYPE_TYPEDEF_FIELD_TYPE (type, i); | |
1340 | ||
1341 | /* Dereference the typedef declaration itself. */ | |
1342 | gdb_assert (TYPE_CODE (target) == TYPE_CODE_TYPEDEF); | |
1343 | target = TYPE_TARGET_TYPE (target); | |
1344 | ||
c191a687 KS |
1345 | if (need_access_label) |
1346 | { | |
1347 | section_type = output_access_specifier | |
1348 | (stream, section_type, level, | |
1349 | TYPE_TYPEDEF_FIELD_PROTECTED (type, i), | |
1350 | TYPE_TYPEDEF_FIELD_PRIVATE (type, i)); | |
1351 | } | |
a579cd9a MW |
1352 | print_spaces_filtered (level + 4, stream); |
1353 | fprintf_filtered (stream, "typedef "); | |
1354 | ||
1355 | /* We want to print typedefs with substitutions | |
1356 | from the template parameters or globally-known | |
1357 | typedefs but not local typedefs. */ | |
1358 | c_print_type (target, | |
1359 | TYPE_TYPEDEF_FIELD_NAME (type, i), | |
1360 | stream, show - 1, level + 4, | |
1361 | &semi_local_flags); | |
1362 | fprintf_filtered (stream, ";\n"); | |
1363 | } | |
1364 | } | |
98751a41 | 1365 | |
bd69fc68 | 1366 | fprintfi_filtered (level, stream, "}"); |
bd69fc68 | 1367 | } |
c4093a6a | 1368 | |
bd69fc68 TT |
1369 | do_cleanups (local_cleanups); |
1370 | } | |
c906108c SS |
1371 | break; |
1372 | ||
1373 | case TYPE_CODE_ENUM: | |
47663de5 | 1374 | c_type_print_modifier (type, stream, 0, 1); |
c5aa993b | 1375 | fprintf_filtered (stream, "enum "); |
3d567982 TT |
1376 | if (TYPE_DECLARED_CLASS (type)) |
1377 | fprintf_filtered (stream, "class "); | |
c906108c SS |
1378 | /* Print the tag name if it exists. |
1379 | The aCC compiler emits a spurious | |
1380 | "{unnamed struct}"/"{unnamed union}"/"{unnamed enum}" | |
1381 | tag for unnamed struct/union/enum's, which we don't | |
aff410f1 | 1382 | want to print. */ |
5aafa1cc | 1383 | if (TYPE_TAG_NAME (type) != NULL |
61012eef | 1384 | && !startswith (TYPE_TAG_NAME (type), "{unnamed")) |
c906108c | 1385 | { |
bd69fc68 | 1386 | print_name_maybe_canonical (TYPE_TAG_NAME (type), flags, stream); |
c906108c SS |
1387 | if (show > 0) |
1388 | fputs_filtered (" ", stream); | |
1389 | } | |
1390 | ||
1391 | wrap_here (" "); | |
1392 | if (show < 0) | |
1393 | { | |
aff410f1 MS |
1394 | /* If we just printed a tag name, no need to print anything |
1395 | else. */ | |
c906108c SS |
1396 | if (TYPE_TAG_NAME (type) == NULL) |
1397 | fprintf_filtered (stream, "{...}"); | |
1398 | } | |
1399 | else if (show > 0 || TYPE_TAG_NAME (type) == NULL) | |
1400 | { | |
14e75d8e JK |
1401 | LONGEST lastval = 0; |
1402 | ||
3d567982 TT |
1403 | /* We can't handle this case perfectly, as DWARF does not |
1404 | tell us whether or not the underlying type was specified | |
1405 | in the source (and other debug formats don't provide this | |
1406 | at all). We choose to print the underlying type, if it | |
1407 | has a name, when in C++ on the theory that it's better to | |
1408 | print too much than too little; but conversely not to | |
1409 | print something egregiously outside the current | |
1410 | language's syntax. */ | |
1411 | if (current_language->la_language == language_cplus | |
1412 | && TYPE_TARGET_TYPE (type) != NULL) | |
1413 | { | |
1414 | struct type *underlying = check_typedef (TYPE_TARGET_TYPE (type)); | |
1415 | ||
1416 | if (TYPE_NAME (underlying) != NULL) | |
1417 | fprintf_filtered (stream, ": %s ", TYPE_NAME (underlying)); | |
1418 | } | |
1419 | ||
c906108c SS |
1420 | fprintf_filtered (stream, "{"); |
1421 | len = TYPE_NFIELDS (type); | |
c906108c SS |
1422 | for (i = 0; i < len; i++) |
1423 | { | |
1424 | QUIT; | |
c5aa993b JM |
1425 | if (i) |
1426 | fprintf_filtered (stream, ", "); | |
c906108c SS |
1427 | wrap_here (" "); |
1428 | fputs_filtered (TYPE_FIELD_NAME (type, i), stream); | |
14e75d8e | 1429 | if (lastval != TYPE_FIELD_ENUMVAL (type, i)) |
c906108c | 1430 | { |
14e75d8e JK |
1431 | fprintf_filtered (stream, " = %s", |
1432 | plongest (TYPE_FIELD_ENUMVAL (type, i))); | |
1433 | lastval = TYPE_FIELD_ENUMVAL (type, i); | |
c906108c SS |
1434 | } |
1435 | lastval++; | |
1436 | } | |
1437 | fprintf_filtered (stream, "}"); | |
1438 | } | |
1439 | break; | |
1440 | ||
81516450 DE |
1441 | case TYPE_CODE_FLAGS: |
1442 | { | |
1443 | struct type_print_options local_flags = *flags; | |
1444 | ||
1445 | local_flags.local_typedefs = NULL; | |
1446 | ||
1447 | c_type_print_modifier (type, stream, 0, 1); | |
1448 | fprintf_filtered (stream, "flag "); | |
1449 | print_name_maybe_canonical (TYPE_NAME (type), flags, stream); | |
1450 | if (show > 0) | |
1451 | { | |
1452 | fputs_filtered (" ", stream); | |
1453 | fprintf_filtered (stream, "{\n"); | |
1454 | if (TYPE_NFIELDS (type) == 0) | |
1455 | { | |
1456 | if (TYPE_STUB (type)) | |
1457 | fprintfi_filtered (level + 4, stream, | |
1458 | _("<incomplete type>\n")); | |
1459 | else | |
1460 | fprintfi_filtered (level + 4, stream, | |
1461 | _("<no data fields>\n")); | |
1462 | } | |
1463 | len = TYPE_NFIELDS (type); | |
1464 | for (i = 0; i < len; i++) | |
1465 | { | |
1466 | QUIT; | |
1467 | print_spaces_filtered (level + 4, stream); | |
1468 | /* We pass "show" here and not "show - 1" to get enum types | |
1469 | printed. There's no other way to see them. */ | |
1470 | c_print_type (TYPE_FIELD_TYPE (type, i), | |
1471 | TYPE_FIELD_NAME (type, i), | |
1472 | stream, show, level + 4, | |
1473 | &local_flags); | |
6b850546 DT |
1474 | fprintf_filtered (stream, " @%s", |
1475 | plongest (TYPE_FIELD_BITPOS (type, i))); | |
81516450 DE |
1476 | if (TYPE_FIELD_BITSIZE (type, i) > 1) |
1477 | { | |
6b850546 DT |
1478 | fprintf_filtered (stream, "-%s", |
1479 | plongest (TYPE_FIELD_BITPOS (type, i) | |
1480 | + TYPE_FIELD_BITSIZE (type, i) | |
1481 | - 1)); | |
81516450 DE |
1482 | } |
1483 | fprintf_filtered (stream, ";\n"); | |
1484 | } | |
1485 | fprintfi_filtered (level, stream, "}"); | |
1486 | } | |
1487 | } | |
1488 | break; | |
1489 | ||
c906108c SS |
1490 | case TYPE_CODE_VOID: |
1491 | fprintf_filtered (stream, "void"); | |
1492 | break; | |
1493 | ||
1494 | case TYPE_CODE_UNDEF: | |
3d263c1d | 1495 | fprintf_filtered (stream, _("struct <unknown>")); |
c906108c SS |
1496 | break; |
1497 | ||
1498 | case TYPE_CODE_ERROR: | |
b00fdb78 | 1499 | fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type)); |
c906108c SS |
1500 | break; |
1501 | ||
1502 | case TYPE_CODE_RANGE: | |
0963b4bd | 1503 | /* This should not occur. */ |
3d263c1d | 1504 | fprintf_filtered (stream, _("<range type>")); |
c906108c SS |
1505 | break; |
1506 | ||
5c4e30ca DC |
1507 | case TYPE_CODE_NAMESPACE: |
1508 | fputs_filtered ("namespace ", stream); | |
1509 | fputs_filtered (TYPE_TAG_NAME (type), stream); | |
1510 | break; | |
1511 | ||
c906108c | 1512 | default: |
aff410f1 MS |
1513 | /* Handle types not explicitly handled by the other cases, such |
1514 | as fundamental types. For these, just print whatever the | |
1515 | type name is, as recorded in the type itself. If there is no | |
1516 | type name, then complain. */ | |
c906108c SS |
1517 | if (TYPE_NAME (type) != NULL) |
1518 | { | |
47663de5 | 1519 | c_type_print_modifier (type, stream, 0, 1); |
bd69fc68 | 1520 | print_name_maybe_canonical (TYPE_NAME (type), flags, stream); |
c906108c SS |
1521 | } |
1522 | else | |
1523 | { | |
aff410f1 MS |
1524 | /* At least for dump_symtab, it is important that this not |
1525 | be an error (). */ | |
3d263c1d | 1526 | fprintf_filtered (stream, _("<invalid type code %d>"), |
c906108c SS |
1527 | TYPE_CODE (type)); |
1528 | } | |
1529 | break; | |
1530 | } | |
1531 | } |