]>
Commit | Line | Data |
---|---|---|
8d08fdba MS |
1 | /* Call-backs for C++ error reporting. |
2 | This code is non-reentrant. | |
4995028c | 3 | Copyright (C) 1993, 94-97, 1998, 1999 Free Software Foundation, Inc. |
8d08fdba MS |
4 | |
5 | This file is part of GNU CC. | |
6 | ||
7 | GNU CC is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | GNU CC is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GNU CC; see the file COPYING. If not, write to | |
e9fa0c7c RK |
19 | the Free Software Foundation, 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. */ | |
8d08fdba MS |
21 | |
22 | #include "config.h" | |
8d052bc7 | 23 | #include "system.h" |
8d08fdba MS |
24 | #include "tree.h" |
25 | #include "cp-tree.h" | |
26 | #include "obstack.h" | |
54f92bfb | 27 | #include "toplev.h" |
8d08fdba MS |
28 | |
29 | typedef char* cp_printer (); | |
30 | ||
31 | #define A args_as_string | |
32 | #define C code_as_string | |
33 | #define D decl_as_string | |
34 | #define E expr_as_string | |
4995028c | 35 | #define F fndecl_as_string |
8d08fdba MS |
36 | #define L language_as_string |
37 | #define O op_as_string | |
38 | #define P parm_as_string | |
c91a56d2 | 39 | #define Q assop_as_string |
8d08fdba | 40 | #define T type_as_string |
f30432d7 | 41 | #define V cv_as_string |
8d08fdba | 42 | |
3e3f722c | 43 | #define o (cp_printer *) 0 |
8d08fdba | 44 | cp_printer * cp_printers[256] = |
3e3f722c | 45 | { |
8d08fdba | 46 | /*0 1 2 3 4 5 6 7 8 9 A B C D E F */ |
3e3f722c ML |
47 | o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x00 */ |
48 | o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x10 */ | |
49 | o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x20 */ | |
50 | o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x30 */ | |
4995028c | 51 | o, A, o, C, D, E, F, o, o, o, o, o, L, o, o, O, /* 0x40 */ |
3e3f722c ML |
52 | P, Q, o, o, T, o, V, o, o, o, o, o, o, o, o, o, /* 0x50 */ |
53 | o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x60 */ | |
54 | o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x70 */ | |
8d08fdba MS |
55 | }; |
56 | #undef C | |
57 | #undef D | |
58 | #undef E | |
4995028c | 59 | #undef F |
8d08fdba MS |
60 | #undef L |
61 | #undef O | |
62 | #undef P | |
c91a56d2 | 63 | #undef Q |
8d08fdba | 64 | #undef T |
f30432d7 | 65 | #undef V |
3e3f722c | 66 | #undef o |
8d08fdba MS |
67 | |
68 | #define obstack_chunk_alloc xmalloc | |
69 | #define obstack_chunk_free free | |
70 | ||
71 | /* Obstack where we build text strings for overloading, etc. */ | |
72 | static struct obstack scratch_obstack; | |
73 | static char *scratch_firstobj; | |
74 | ||
75 | # define OB_INIT() (scratch_firstobj ? (obstack_free (&scratch_obstack, scratch_firstobj), 0) : 0) | |
76 | # define OB_PUTC(C) (obstack_1grow (&scratch_obstack, (C))) | |
77 | # define OB_PUTC2(C1,C2) \ | |
78 | (obstack_1grow (&scratch_obstack, (C1)), obstack_1grow (&scratch_obstack, (C2))) | |
79 | # define OB_PUTS(S) (obstack_grow (&scratch_obstack, (S), sizeof (S) - 1)) | |
80 | # define OB_PUTID(ID) \ | |
81 | (obstack_grow (&scratch_obstack, IDENTIFIER_POINTER (ID), \ | |
82 | IDENTIFIER_LENGTH (ID))) | |
83 | # define OB_PUTCP(S) (obstack_grow (&scratch_obstack, (S), strlen (S))) | |
84 | # define OB_FINISH() (obstack_1grow (&scratch_obstack, '\0')) | |
71e89f27 | 85 | # define OB_PUTI(CST) do { sprintf (digit_buffer, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT)(CST)); \ |
8d08fdba | 86 | OB_PUTCP (digit_buffer); } while (0) |
51c184be | 87 | # define OB_UNPUT(N) obstack_blank (&scratch_obstack, - (N)); |
8d08fdba | 88 | |
0aafb128 MM |
89 | # define OB_END_TEMPLATE_ID() \ |
90 | ((obstack_next_free (&scratch_obstack) != obstack_base (&scratch_obstack) \ | |
91 | && obstack_next_free (&scratch_obstack)[-1] == '>') \ | |
92 | ? OB_PUTC2 (' ', '>') : OB_PUTC ('>')) | |
93 | ||
8d08fdba MS |
94 | # define NEXT_CODE(t) (TREE_CODE (TREE_TYPE (t))) |
95 | ||
49c249e1 JM |
96 | enum pad { none, before, after }; |
97 | ||
98 | static void dump_type PROTO((tree, int)); | |
294471c3 | 99 | static void dump_type_real PROTO((tree, int, int)); |
07389efe | 100 | static void dump_simple_decl PROTO((tree, tree, int)); |
49c249e1 JM |
101 | static void dump_decl PROTO((tree, int)); |
102 | static void dump_function_decl PROTO((tree, int)); | |
103 | static void dump_expr PROTO((tree, int)); | |
9c0758dd KG |
104 | static void dump_unary_op PROTO((const char *, tree, int)); |
105 | static void dump_binary_op PROTO((const char *, tree)); | |
294471c3 MM |
106 | static void dump_aggr_type PROTO((tree, int, int)); |
107 | static void dump_type_prefix PROTO((tree, int, int)); | |
108 | static void dump_type_suffix PROTO((tree, int, int)); | |
49c249e1 JM |
109 | static void dump_function_name PROTO((tree)); |
110 | static void dump_expr_list PROTO((tree)); | |
111 | static void dump_global_iord PROTO((tree)); | |
91063b51 | 112 | static void dump_qualifiers PROTO((tree, enum pad)); |
b2bb2710 | 113 | static void dump_char PROTO((int)); |
4995028c NS |
114 | static void dump_parameters PROTO((tree, int, int)); |
115 | static void dump_exception_spec PROTO((tree, int)); | |
9c0758dd | 116 | static const char *aggr_variety PROTO((tree)); |
49c249e1 | 117 | static tree ident_fndecl PROTO((tree)); |
d8e178a0 | 118 | static int interesting_scope_p PROTO((tree)); |
8d08fdba MS |
119 | |
120 | void | |
121 | init_error () | |
122 | { | |
123 | gcc_obstack_init (&scratch_obstack); | |
124 | scratch_firstobj = (char *)obstack_alloc (&scratch_obstack, 0); | |
125 | } | |
126 | ||
bbcec105 JM |
127 | /* Returns nonzero if SCOPE is something we want to print for random decls. */ |
128 | ||
129 | static int | |
130 | interesting_scope_p (scope) | |
131 | tree scope; | |
132 | { | |
133 | if (scope == NULL_TREE | |
134 | || scope == global_namespace) | |
135 | return 0; | |
136 | ||
137 | return (TREE_CODE (scope) == NAMESPACE_DECL | |
138 | || AGGREGATE_TYPE_P (scope)); | |
139 | } | |
140 | ||
8d08fdba | 141 | static void |
91063b51 | 142 | dump_qualifiers (t, p) |
8d08fdba MS |
143 | tree t; |
144 | enum pad p; | |
145 | { | |
91063b51 | 146 | if (TYPE_QUALS (t)) |
8d08fdba MS |
147 | { |
148 | if (p == before) OB_PUTC (' '); | |
91063b51 MM |
149 | switch (TYPE_QUALS (t)) |
150 | { | |
151 | case TYPE_QUAL_CONST: | |
152 | OB_PUTS ("const"); | |
153 | break; | |
154 | ||
155 | case TYPE_QUAL_VOLATILE: | |
156 | OB_PUTS ("volatile"); | |
157 | break; | |
158 | ||
159 | case TYPE_QUAL_RESTRICT: | |
160 | OB_PUTS ("__restrict"); | |
161 | break; | |
162 | ||
163 | case TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE: | |
164 | OB_PUTS ("const volatile"); | |
165 | break; | |
166 | ||
167 | case TYPE_QUAL_CONST | TYPE_QUAL_RESTRICT: | |
168 | OB_PUTS ("const __restrict"); | |
169 | break; | |
170 | ||
171 | case TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT: | |
172 | OB_PUTS ("volatile __restrict"); | |
173 | break; | |
174 | ||
175 | case TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT: | |
176 | OB_PUTS ("const volatile __restrict"); | |
177 | break; | |
178 | ||
179 | default: | |
180 | my_friendly_abort (0); | |
181 | } | |
8d08fdba MS |
182 | if (p == after) OB_PUTC (' '); |
183 | } | |
184 | } | |
185 | ||
186 | /* This must be large enough to hold any printed integer or floating-point | |
187 | value. */ | |
188 | static char digit_buffer[128]; | |
189 | ||
e92cc029 MS |
190 | /* Dump into the obstack a human-readable equivalent of TYPE. */ |
191 | ||
8d08fdba | 192 | static void |
294471c3 | 193 | dump_type_real (t, v, canonical_name) |
8d08fdba MS |
194 | tree t; |
195 | int v; /* verbose? */ | |
6df38d6d | 196 | int canonical_name; |
8d08fdba MS |
197 | { |
198 | if (t == NULL_TREE) | |
199 | return; | |
200 | ||
201 | if (TYPE_PTRMEMFUNC_P (t)) | |
202 | goto offset_type; | |
203 | ||
204 | switch (TREE_CODE (t)) | |
205 | { | |
206 | case ERROR_MARK: | |
51c184be | 207 | OB_PUTS ("{error}"); |
8d08fdba MS |
208 | break; |
209 | ||
210 | case UNKNOWN_TYPE: | |
51c184be | 211 | OB_PUTS ("{unknown type}"); |
8d08fdba MS |
212 | break; |
213 | ||
dcd08efc JM |
214 | case TREE_LIST: |
215 | /* A list of function parms. */ | |
216 | dump_parameters (t, 0, canonical_name); | |
217 | break; | |
218 | ||
8d08fdba MS |
219 | case IDENTIFIER_NODE: |
220 | OB_PUTID (t); | |
221 | break; | |
222 | ||
223 | case TREE_VEC: | |
294471c3 | 224 | dump_type_real (BINFO_TYPE (t), v, canonical_name); |
8d08fdba MS |
225 | break; |
226 | ||
227 | case RECORD_TYPE: | |
228 | case UNION_TYPE: | |
229 | case ENUMERAL_TYPE: | |
6eabb241 | 230 | dump_aggr_type (t, v, canonical_name); |
8d08fdba MS |
231 | break; |
232 | ||
233 | case TYPE_DECL: | |
67c2a928 | 234 | case TEMPLATE_DECL: |
009425e1 | 235 | case NAMESPACE_DECL: |
7177d104 | 236 | dump_decl (t, v); |
8d08fdba MS |
237 | break; |
238 | ||
37c46b43 MS |
239 | case COMPLEX_TYPE: |
240 | OB_PUTS ("complex "); | |
294471c3 | 241 | dump_type_real (TREE_TYPE (t), v, canonical_name); |
37c46b43 MS |
242 | break; |
243 | ||
8d08fdba MS |
244 | case INTEGER_TYPE: |
245 | if (!TREE_UNSIGNED (TYPE_MAIN_VARIANT (t)) && TREE_UNSIGNED (t)) | |
246 | OB_PUTS ("unsigned "); | |
247 | else if (TREE_UNSIGNED (TYPE_MAIN_VARIANT (t)) && !TREE_UNSIGNED (t)) | |
248 | OB_PUTS ("signed "); | |
249 | ||
250 | /* fall through. */ | |
251 | case REAL_TYPE: | |
252 | case VOID_TYPE: | |
2986ae00 | 253 | case BOOLEAN_TYPE: |
3df095e2 MM |
254 | { |
255 | tree type; | |
91063b51 | 256 | dump_qualifiers (t, after); |
3df095e2 MM |
257 | type = canonical_name ? TYPE_MAIN_VARIANT (t) : t; |
258 | if (TYPE_NAME (type) && TYPE_IDENTIFIER (type)) | |
259 | OB_PUTID (TYPE_IDENTIFIER (type)); | |
260 | else | |
261 | /* Types like intQI_type_node and friends have no names. | |
262 | These don't come up in user error messages, but it's nice | |
263 | to be able to print them from the debugger. */ | |
264 | OB_PUTS ("{anonymous}"); | |
265 | } | |
8d08fdba MS |
266 | break; |
267 | ||
73b0fce8 | 268 | case TEMPLATE_TEMPLATE_PARM: |
7ddedda4 | 269 | if (!TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (t)) |
73b0fce8 KL |
270 | { |
271 | /* For parameters inside template signature. */ | |
272 | if (TYPE_IDENTIFIER (t)) | |
273 | OB_PUTID (TYPE_IDENTIFIER (t)); | |
274 | else | |
275 | OB_PUTS ("{anonymous template template parm}"); | |
276 | } | |
277 | else | |
278 | { | |
279 | int i; | |
7ddedda4 | 280 | tree args = TYPE_TI_ARGS (t); |
73b0fce8 KL |
281 | OB_PUTID (TYPE_IDENTIFIER (t)); |
282 | OB_PUTC ('<'); | |
283 | for (i = 0; i < TREE_VEC_LENGTH (args); i++) | |
284 | { | |
285 | tree arg = TREE_VEC_ELT (args, i); | |
286 | if (TREE_CODE_CLASS (TREE_CODE (arg)) == 't' | |
287 | || TREE_CODE (arg) == TEMPLATE_DECL) | |
294471c3 | 288 | dump_type_real (arg, 0, canonical_name); |
73b0fce8 KL |
289 | else |
290 | dump_expr (arg, 0); | |
291 | if (i < TREE_VEC_LENGTH (args)-1) | |
292 | OB_PUTC2 (',', ' '); | |
293 | } | |
0aafb128 | 294 | OB_END_TEMPLATE_ID (); |
73b0fce8 KL |
295 | } |
296 | break; | |
297 | ||
8d08fdba | 298 | case TEMPLATE_TYPE_PARM: |
91063b51 | 299 | dump_qualifiers (t, after); |
ec255269 MS |
300 | if (TYPE_IDENTIFIER (t)) |
301 | OB_PUTID (TYPE_IDENTIFIER (t)); | |
302 | else | |
303 | OB_PUTS ("{anonymous template type parm}"); | |
8d08fdba MS |
304 | break; |
305 | ||
8d08fdba MS |
306 | /* This is not always necessary for pointers and such, but doing this |
307 | reduces code size. */ | |
308 | case ARRAY_TYPE: | |
309 | case POINTER_TYPE: | |
310 | case REFERENCE_TYPE: | |
311 | case OFFSET_TYPE: | |
312 | offset_type: | |
313 | case FUNCTION_TYPE: | |
314 | case METHOD_TYPE: | |
294471c3 MM |
315 | dump_type_prefix (t, v, canonical_name); |
316 | dump_type_suffix (t, v, canonical_name); | |
8d08fdba MS |
317 | break; |
318 | ||
5566b478 MS |
319 | case TYPENAME_TYPE: |
320 | OB_PUTS ("typename "); | |
294471c3 | 321 | dump_type_real (TYPE_CONTEXT (t), 0, canonical_name); |
5566b478 | 322 | OB_PUTS ("::"); |
7ac7b28f | 323 | dump_decl (TYPENAME_TYPE_FULLNAME (t), v); |
5566b478 MS |
324 | break; |
325 | ||
b894fc05 JM |
326 | case TYPEOF_TYPE: |
327 | OB_PUTS ("__typeof ("); | |
328 | dump_expr (TYPE_FIELDS (t), 1); | |
329 | OB_PUTC (')'); | |
330 | break; | |
331 | ||
8d08fdba | 332 | default: |
51c184be MS |
333 | sorry ("`%s' not supported by dump_type", |
334 | tree_code_name[(int) TREE_CODE (t)]); | |
8d08fdba MS |
335 | } |
336 | } | |
337 | ||
9c0758dd | 338 | static const char * |
51c184be | 339 | aggr_variety (t) |
8d08fdba | 340 | tree t; |
8d08fdba | 341 | { |
8d08fdba | 342 | if (TREE_CODE (t) == ENUMERAL_TYPE) |
51c184be | 343 | return "enum"; |
8d08fdba | 344 | else if (TREE_CODE (t) == UNION_TYPE) |
51c184be | 345 | return "union"; |
8d08fdba | 346 | else if (TYPE_LANG_SPECIFIC (t) && CLASSTYPE_DECLARED_CLASS (t)) |
51c184be | 347 | return "class"; |
8d08fdba | 348 | else |
51c184be MS |
349 | return "struct"; |
350 | } | |
351 | ||
294471c3 MM |
352 | static void |
353 | dump_type (t, v) | |
354 | tree t; | |
355 | int v; /* verbose? */ | |
356 | { | |
357 | dump_type_real (t, v, 0); | |
358 | } | |
359 | ||
e92cc029 MS |
360 | /* Print out a class declaration, in the form `class foo'. */ |
361 | ||
51c184be | 362 | static void |
294471c3 | 363 | dump_aggr_type (t, v, canonical_name) |
51c184be MS |
364 | tree t; |
365 | int v; /* verbose? */ | |
294471c3 | 366 | int canonical_name; |
51c184be MS |
367 | { |
368 | tree name; | |
9c0758dd | 369 | const char *variety = aggr_variety (t); |
8d08fdba | 370 | |
91063b51 | 371 | dump_qualifiers (t, after); |
8d08fdba MS |
372 | |
373 | if (v > 0) | |
374 | { | |
375 | OB_PUTCP (variety); | |
376 | OB_PUTC (' '); | |
377 | } | |
378 | ||
294471c3 | 379 | name = TYPE_NAME (canonical_name ? TYPE_MAIN_VARIANT (t) : t); |
8d08fdba | 380 | |
0aa5b426 | 381 | if (name && CP_DECL_CONTEXT (name) != global_namespace) |
8d08fdba MS |
382 | { |
383 | /* FUNCTION_DECL or RECORD_TYPE */ | |
384 | dump_decl (DECL_CONTEXT (name), 0); | |
385 | OB_PUTC2 (':', ':'); | |
386 | } | |
387 | ||
ddd5a7c1 | 388 | /* kludge around weird behavior on g++.brendan/line1.C */ |
f30432d7 | 389 | if (name && TREE_CODE (name) != IDENTIFIER_NODE) |
8d08fdba MS |
390 | name = DECL_NAME (name); |
391 | ||
f30432d7 | 392 | if (name == 0 || ANON_AGGRNAME_P (name)) |
8d08fdba | 393 | { |
51c184be | 394 | OB_PUTS ("{anonymous"); |
8d08fdba MS |
395 | if (!v) |
396 | { | |
397 | OB_PUTC (' '); | |
398 | OB_PUTCP (variety); | |
399 | } | |
51c184be | 400 | OB_PUTC ('}'); |
8d08fdba MS |
401 | } |
402 | else | |
403 | OB_PUTID (name); | |
404 | } | |
405 | ||
406 | /* Dump into the obstack the initial part of the output for a given type. | |
407 | This is necessary when dealing with things like functions returning | |
408 | functions. Examples: | |
409 | ||
410 | return type of `int (* fee ())()': pointer -> function -> int. Both | |
411 | pointer (and reference and offset) and function (and member) types must | |
412 | deal with prefix and suffix. | |
413 | ||
414 | Arrays must also do this for DECL nodes, like int a[], and for things like | |
415 | int *[]&. */ | |
416 | ||
417 | static void | |
294471c3 | 418 | dump_type_prefix (t, v, canonical_name) |
8d08fdba MS |
419 | tree t; |
420 | int v; /* verbosity */ | |
294471c3 | 421 | int canonical_name; |
8d08fdba MS |
422 | { |
423 | if (TYPE_PTRMEMFUNC_P (t)) | |
424 | { | |
425 | t = TYPE_PTRMEMFUNC_FN_TYPE (t); | |
426 | goto offset_type; | |
427 | } | |
428 | ||
429 | switch (TREE_CODE (t)) | |
430 | { | |
431 | case POINTER_TYPE: | |
91063b51 | 432 | case REFERENCE_TYPE: |
8d08fdba MS |
433 | { |
434 | tree sub = TREE_TYPE (t); | |
435 | ||
294471c3 | 436 | dump_type_prefix (sub, v, canonical_name); |
8d08fdba MS |
437 | /* A tree for a member pointer looks like pointer to offset, |
438 | so let the OFFSET_TYPE case handle it. */ | |
91063b51 | 439 | if (!TYPE_PTRMEM_P (t)) |
8d08fdba MS |
440 | { |
441 | switch (TREE_CODE (sub)) | |
442 | { | |
443 | /* We don't want int ( *)() */ | |
444 | case FUNCTION_TYPE: | |
445 | case METHOD_TYPE: | |
446 | break; | |
447 | ||
39211cd5 MS |
448 | case ARRAY_TYPE: |
449 | OB_PUTC2 (' ', '('); | |
450 | break; | |
451 | ||
8d08fdba MS |
452 | case POINTER_TYPE: |
453 | /* We don't want "char * *" */ | |
91063b51 | 454 | if (TYPE_QUALS (sub) == TYPE_UNQUALIFIED) |
8d08fdba MS |
455 | break; |
456 | /* But we do want "char *const *" */ | |
457 | ||
458 | default: | |
459 | OB_PUTC (' '); | |
460 | } | |
91063b51 MM |
461 | if (TREE_CODE (t) == POINTER_TYPE) |
462 | OB_PUTC ('*'); | |
463 | else | |
464 | OB_PUTC ('&'); | |
465 | dump_qualifiers (t, none); | |
8d08fdba MS |
466 | } |
467 | } | |
8d08fdba MS |
468 | break; |
469 | ||
470 | case OFFSET_TYPE: | |
471 | offset_type: | |
294471c3 | 472 | dump_type_prefix (TREE_TYPE (t), v, canonical_name); |
51c184be MS |
473 | if (TREE_CODE (t) == OFFSET_TYPE) /* pmfs deal with this in d_t_p */ |
474 | { | |
475 | OB_PUTC (' '); | |
294471c3 | 476 | dump_type_real (TYPE_OFFSET_BASETYPE (t), 0, canonical_name); |
51c184be MS |
477 | OB_PUTC2 (':', ':'); |
478 | } | |
8d08fdba | 479 | OB_PUTC ('*'); |
91063b51 | 480 | dump_qualifiers (t, none); |
8d08fdba MS |
481 | break; |
482 | ||
483 | /* Can only be reached through function pointer -- this would not be | |
484 | correct if FUNCTION_DECLs used it. */ | |
485 | case FUNCTION_TYPE: | |
294471c3 | 486 | dump_type_prefix (TREE_TYPE (t), v, canonical_name); |
8d08fdba MS |
487 | OB_PUTC2 (' ', '('); |
488 | break; | |
489 | ||
490 | case METHOD_TYPE: | |
294471c3 | 491 | dump_type_prefix (TREE_TYPE (t), v, canonical_name); |
8d08fdba | 492 | OB_PUTC2 (' ', '('); |
294471c3 | 493 | dump_aggr_type (TYPE_METHOD_BASETYPE (t), 0, canonical_name); |
8d08fdba MS |
494 | OB_PUTC2 (':', ':'); |
495 | break; | |
496 | ||
497 | case ARRAY_TYPE: | |
294471c3 | 498 | dump_type_prefix (TREE_TYPE (t), v, canonical_name); |
8d08fdba MS |
499 | break; |
500 | ||
501 | case ENUMERAL_TYPE: | |
502 | case ERROR_MARK: | |
503 | case IDENTIFIER_NODE: | |
504 | case INTEGER_TYPE: | |
2986ae00 | 505 | case BOOLEAN_TYPE: |
8d08fdba MS |
506 | case REAL_TYPE: |
507 | case RECORD_TYPE: | |
508 | case TEMPLATE_TYPE_PARM: | |
73b0fce8 | 509 | case TEMPLATE_TEMPLATE_PARM: |
8d08fdba MS |
510 | case TREE_LIST: |
511 | case TYPE_DECL: | |
512 | case TREE_VEC: | |
8d08fdba MS |
513 | case UNION_TYPE: |
514 | case UNKNOWN_TYPE: | |
515 | case VOID_TYPE: | |
5566b478 | 516 | case TYPENAME_TYPE: |
37c46b43 | 517 | case COMPLEX_TYPE: |
294471c3 | 518 | dump_type_real (t, v, canonical_name); |
8d08fdba MS |
519 | break; |
520 | ||
521 | default: | |
51c184be MS |
522 | sorry ("`%s' not supported by dump_type_prefix", |
523 | tree_code_name[(int) TREE_CODE (t)]); | |
8d08fdba MS |
524 | } |
525 | } | |
526 | ||
527 | static void | |
294471c3 | 528 | dump_type_suffix (t, v, canonical_name) |
8d08fdba MS |
529 | tree t; |
530 | int v; /* verbose? */ | |
294471c3 | 531 | int canonical_name; |
8d08fdba MS |
532 | { |
533 | if (TYPE_PTRMEMFUNC_P (t)) | |
534 | t = TYPE_PTRMEMFUNC_FN_TYPE (t); | |
535 | ||
536 | switch (TREE_CODE (t)) | |
537 | { | |
538 | case POINTER_TYPE: | |
539 | case REFERENCE_TYPE: | |
540 | case OFFSET_TYPE: | |
39211cd5 MS |
541 | if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE) |
542 | OB_PUTC (')'); | |
294471c3 | 543 | dump_type_suffix (TREE_TYPE (t), v, canonical_name); |
8d08fdba MS |
544 | break; |
545 | ||
546 | /* Can only be reached through function pointer */ | |
547 | case FUNCTION_TYPE: | |
548 | case METHOD_TYPE: | |
549 | { | |
550 | tree arg; | |
4995028c | 551 | OB_PUTC (')'); |
8d08fdba MS |
552 | arg = TYPE_ARG_TYPES (t); |
553 | if (TREE_CODE (t) == METHOD_TYPE) | |
554 | arg = TREE_CHAIN (arg); | |
555 | ||
4995028c NS |
556 | /* Function pointers don't have default args. Not in standard C++, |
557 | anyway; they may in g++, but we'll just pretend otherwise. */ | |
558 | dump_parameters (arg, 0, canonical_name); | |
559 | ||
8d08fdba | 560 | if (TREE_CODE (t) == METHOD_TYPE) |
91063b51 | 561 | dump_qualifiers |
8d08fdba | 562 | (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t))), before); |
294471c3 | 563 | dump_type_suffix (TREE_TYPE (t), v, canonical_name); |
4995028c | 564 | dump_exception_spec (TYPE_RAISES_EXCEPTIONS (t), canonical_name); |
8d08fdba MS |
565 | break; |
566 | } | |
567 | ||
568 | case ARRAY_TYPE: | |
569 | OB_PUTC ('['); | |
570 | if (TYPE_DOMAIN (t)) | |
5156628f MS |
571 | { |
572 | if (TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (t))) == INTEGER_CST) | |
573 | OB_PUTI (TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (t))) + 1); | |
574 | else if (TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (t))) == MINUS_EXPR) | |
575 | dump_expr (TREE_OPERAND (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0), 0); | |
576 | else | |
577 | dump_expr (fold (build_binary_op | |
578 | (PLUS_EXPR, TYPE_MAX_VALUE (TYPE_DOMAIN (t)), | |
337c90cc | 579 | integer_one_node)), 0); |
5156628f | 580 | } |
8d08fdba | 581 | OB_PUTC (']'); |
294471c3 | 582 | dump_type_suffix (TREE_TYPE (t), v, canonical_name); |
8d08fdba MS |
583 | break; |
584 | ||
585 | case ENUMERAL_TYPE: | |
586 | case ERROR_MARK: | |
587 | case IDENTIFIER_NODE: | |
588 | case INTEGER_TYPE: | |
2986ae00 | 589 | case BOOLEAN_TYPE: |
8d08fdba MS |
590 | case REAL_TYPE: |
591 | case RECORD_TYPE: | |
592 | case TEMPLATE_TYPE_PARM: | |
73b0fce8 | 593 | case TEMPLATE_TEMPLATE_PARM: |
8d08fdba MS |
594 | case TREE_LIST: |
595 | case TYPE_DECL: | |
596 | case TREE_VEC: | |
8d08fdba MS |
597 | case UNION_TYPE: |
598 | case UNKNOWN_TYPE: | |
599 | case VOID_TYPE: | |
5566b478 | 600 | case TYPENAME_TYPE: |
37c46b43 | 601 | case COMPLEX_TYPE: |
8d08fdba MS |
602 | break; |
603 | ||
604 | default: | |
51c184be MS |
605 | sorry ("`%s' not supported by dump_type_suffix", |
606 | tree_code_name[(int) TREE_CODE (t)]); | |
8d08fdba MS |
607 | } |
608 | } | |
609 | ||
610 | /* Return a function declaration which corresponds to the IDENTIFIER_NODE | |
611 | argument. */ | |
e92cc029 | 612 | |
49c249e1 | 613 | static tree |
8d08fdba MS |
614 | ident_fndecl (t) |
615 | tree t; | |
616 | { | |
700f8a87 | 617 | tree n = lookup_name (t, 0); |
8d08fdba | 618 | |
f30432d7 MS |
619 | if (n == NULL_TREE) |
620 | return NULL_TREE; | |
621 | ||
8d08fdba MS |
622 | if (TREE_CODE (n) == FUNCTION_DECL) |
623 | return n; | |
624 | else if (TREE_CODE (n) == TREE_LIST | |
625 | && TREE_CODE (TREE_VALUE (n)) == FUNCTION_DECL) | |
626 | return TREE_VALUE (n); | |
8926095f MS |
627 | |
628 | my_friendly_abort (66); | |
629 | return NULL_TREE; | |
8d08fdba MS |
630 | } |
631 | ||
632 | #ifndef NO_DOLLAR_IN_LABEL | |
633 | # define GLOBAL_THING "_GLOBAL_$" | |
634 | #else | |
635 | # ifndef NO_DOT_IN_LABEL | |
636 | # define GLOBAL_THING "_GLOBAL_." | |
637 | # else | |
638 | # define GLOBAL_THING "_GLOBAL__" | |
639 | # endif | |
640 | #endif | |
641 | ||
642 | #define GLOBAL_IORD_P(NODE) \ | |
fc378698 | 643 | ! strncmp (IDENTIFIER_POINTER(NODE), GLOBAL_THING, sizeof (GLOBAL_THING) - 1) |
8d08fdba | 644 | |
49c249e1 | 645 | static void |
8d08fdba MS |
646 | dump_global_iord (t) |
647 | tree t; | |
648 | { | |
9c0758dd | 649 | const char *name = IDENTIFIER_POINTER (t); |
8d08fdba MS |
650 | |
651 | OB_PUTS ("(static "); | |
652 | if (name [sizeof (GLOBAL_THING) - 1] == 'I') | |
653 | OB_PUTS ("initializers"); | |
654 | else if (name [sizeof (GLOBAL_THING) - 1] == 'D') | |
655 | OB_PUTS ("destructors"); | |
656 | else | |
657 | my_friendly_abort (352); | |
658 | ||
659 | OB_PUTS (" for "); | |
660 | OB_PUTCP (input_filename); | |
661 | OB_PUTC (')'); | |
662 | } | |
663 | ||
07389efe MM |
664 | static void |
665 | dump_simple_decl (t, type, v) | |
666 | tree t; | |
667 | tree type; | |
668 | int v; | |
669 | { | |
670 | if (v > 0) | |
671 | { | |
672 | dump_type_prefix (type, v, 0); | |
673 | OB_PUTC (' '); | |
07389efe | 674 | } |
bbcec105 | 675 | if (interesting_scope_p (DECL_CONTEXT (t))) |
07389efe | 676 | { |
2642b9bf JM |
677 | dump_decl (DECL_CONTEXT (t), 0); |
678 | OB_PUTC2 (':',':'); | |
07389efe MM |
679 | } |
680 | if (DECL_NAME (t)) | |
681 | dump_decl (DECL_NAME (t), v); | |
682 | else | |
683 | OB_PUTS ("{anon}"); | |
684 | if (v > 0) | |
685 | dump_type_suffix (type, v, 0); | |
686 | } | |
687 | ||
8d08fdba MS |
688 | static void |
689 | dump_decl (t, v) | |
690 | tree t; | |
691 | int v; /* verbosity */ | |
692 | { | |
693 | if (t == NULL_TREE) | |
694 | return; | |
695 | ||
696 | switch (TREE_CODE (t)) | |
697 | { | |
698 | case ERROR_MARK: | |
699 | OB_PUTS (" /* decl error */ "); | |
700 | break; | |
701 | ||
7177d104 | 702 | case TYPE_DECL: |
8d2733ca MS |
703 | { |
704 | /* Don't say 'typedef class A' */ | |
fc378698 | 705 | if (DECL_ARTIFICIAL (t)) |
8d2733ca | 706 | { |
a9936d39 MM |
707 | if (v > 0 && TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TYPE_PARM) |
708 | /* Say `class T' not just `T'. */ | |
709 | OB_PUTS ("class "); | |
710 | ||
fc378698 | 711 | dump_type (TREE_TYPE (t), v); |
8d2733ca MS |
712 | break; |
713 | } | |
714 | } | |
715 | if (v > 0) | |
716 | OB_PUTS ("typedef "); | |
07389efe MM |
717 | dump_simple_decl (t, DECL_ORIGINAL_TYPE (t) |
718 | ? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t), v); | |
7177d104 MS |
719 | break; |
720 | ||
8d08fdba | 721 | case VAR_DECL: |
b7484fbe | 722 | if (DECL_NAME (t) && VTABLE_NAME_P (DECL_NAME (t))) |
8d08fdba MS |
723 | { |
724 | OB_PUTS ("vtable for "); | |
52bf7d5d MM |
725 | if (TYPE_P (DECL_CONTEXT (t))) |
726 | dump_type (DECL_CONTEXT (t), v); | |
727 | else | |
728 | /* This case can arise with -fno-vtable-thunks. See | |
729 | expand_upcast_fixups. It's not clear what to print | |
730 | here. */ | |
731 | OB_PUTS ("{unknown type}"); | |
8d08fdba MS |
732 | break; |
733 | } | |
734 | /* else fall through */ | |
735 | case FIELD_DECL: | |
736 | case PARM_DECL: | |
07389efe | 737 | dump_simple_decl (t, TREE_TYPE (t), v); |
8d08fdba MS |
738 | break; |
739 | ||
a9aedbc2 | 740 | case NAMESPACE_DECL: |
0aa5b426 | 741 | if (CP_DECL_CONTEXT (t) != global_namespace) |
30394414 | 742 | { |
2c73f9f5 | 743 | dump_decl (DECL_CONTEXT (t), v); |
30394414 JM |
744 | OB_PUTC2 (':',':'); |
745 | } | |
0c8feefe MM |
746 | if (DECL_NAME (t) == anonymous_namespace_name) |
747 | OB_PUTS ("{anonymous}"); | |
748 | else | |
749 | OB_PUTID (DECL_NAME (t)); | |
a9aedbc2 MS |
750 | break; |
751 | ||
3e3f722c ML |
752 | case SCOPE_REF: |
753 | dump_decl (TREE_OPERAND (t, 0), 0); | |
754 | OB_PUTS ("::"); | |
755 | dump_decl (TREE_OPERAND (t, 1), 0); | |
756 | break; | |
757 | ||
8d08fdba MS |
758 | case ARRAY_REF: |
759 | dump_decl (TREE_OPERAND (t, 0), v); | |
760 | OB_PUTC ('['); | |
761 | dump_decl (TREE_OPERAND (t, 1), v); | |
762 | OB_PUTC (']'); | |
763 | break; | |
764 | ||
765 | /* So that we can do dump_decl in dump_aggr_type and have it work for | |
766 | both class and function scope. */ | |
767 | case RECORD_TYPE: | |
768 | case UNION_TYPE: | |
769 | case ENUMERAL_TYPE: | |
770 | dump_type (t, v); | |
771 | break; | |
772 | ||
8d08fdba MS |
773 | case TYPE_EXPR: |
774 | my_friendly_abort (69); | |
775 | break; | |
776 | ||
777 | /* These special cases are duplicated here so that other functions | |
e92cc029 | 778 | can feed identifiers to cp_error and get them demangled properly. */ |
8d08fdba | 779 | case IDENTIFIER_NODE: |
f30432d7 MS |
780 | { tree f; |
781 | if (DESTRUCTOR_NAME_P (t) | |
782 | && (f = ident_fndecl (t)) | |
783 | && DECL_LANGUAGE (f) == lang_cplusplus) | |
784 | { | |
785 | OB_PUTC ('~'); | |
786 | dump_decl (DECL_NAME (f), 0); | |
787 | } | |
788 | else if (IDENTIFIER_TYPENAME_P (t)) | |
789 | { | |
790 | OB_PUTS ("operator "); | |
791 | /* Not exactly IDENTIFIER_TYPE_VALUE. */ | |
792 | dump_type (TREE_TYPE (t), 0); | |
793 | break; | |
794 | } | |
795 | else if (IDENTIFIER_OPNAME_P (t)) | |
796 | { | |
9c0758dd | 797 | const char *name_string = operator_name_string (t); |
f30432d7 MS |
798 | OB_PUTS ("operator "); |
799 | OB_PUTCP (name_string); | |
800 | } | |
801 | else | |
802 | OB_PUTID (t); | |
803 | } | |
8d08fdba MS |
804 | break; |
805 | ||
8f032717 MM |
806 | case OVERLOAD: |
807 | t = OVL_CURRENT (t); | |
808 | /* Fall through. */ | |
809 | ||
8d08fdba MS |
810 | case FUNCTION_DECL: |
811 | if (GLOBAL_IORD_P (DECL_ASSEMBLER_NAME (t))) | |
812 | dump_global_iord (DECL_ASSEMBLER_NAME (t)); | |
da20811c JM |
813 | else if (! DECL_LANG_SPECIFIC (t)) |
814 | OB_PUTS ("{internal}"); | |
8d08fdba MS |
815 | else |
816 | dump_function_decl (t, v); | |
817 | break; | |
818 | ||
819 | case TEMPLATE_DECL: | |
51c184be | 820 | { |
98c1c668 JM |
821 | tree orig_args = DECL_TEMPLATE_PARMS (t); |
822 | tree args; | |
823 | int i; | |
824 | for (args = orig_args = nreverse (orig_args); | |
825 | args; | |
826 | args = TREE_CHAIN (args)) | |
51c184be | 827 | { |
98c1c668 | 828 | int len = TREE_VEC_LENGTH (TREE_VALUE (args)); |
a292b002 | 829 | |
98c1c668 JM |
830 | OB_PUTS ("template <"); |
831 | for (i = 0; i < len; i++) | |
a292b002 | 832 | { |
98c1c668 JM |
833 | tree arg = TREE_VEC_ELT (TREE_VALUE (args), i); |
834 | tree defval = TREE_PURPOSE (arg); | |
835 | arg = TREE_VALUE (arg); | |
836 | if (TREE_CODE (arg) == TYPE_DECL) | |
837 | { | |
73b0fce8 | 838 | if (DECL_NAME (arg)) |
b7a29012 JM |
839 | { |
840 | OB_PUTS ("class "); | |
841 | OB_PUTID (DECL_NAME (arg)); | |
842 | } | |
73b0fce8 | 843 | else |
b7a29012 | 844 | OB_PUTS ("class"); |
98c1c668 JM |
845 | } |
846 | else | |
847 | dump_decl (arg, 1); | |
848 | ||
849 | if (defval) | |
850 | { | |
851 | OB_PUTS (" = "); | |
e7e66632 KL |
852 | if (TREE_CODE (arg) == TYPE_DECL |
853 | || TREE_CODE (arg) == TEMPLATE_DECL) | |
67c2a928 JM |
854 | dump_type (defval, 1); |
855 | else | |
e7e66632 | 856 | dump_expr (defval, 1); |
98c1c668 | 857 | } |
a292b002 | 858 | |
98c1c668 JM |
859 | OB_PUTC2 (',', ' '); |
860 | } | |
861 | if (len != 0) | |
862 | OB_UNPUT (2); | |
0aafb128 MM |
863 | OB_END_TEMPLATE_ID (); |
864 | OB_PUTC (' '); | |
51c184be | 865 | } |
98c1c668 | 866 | nreverse(orig_args); |
8d08fdba | 867 | |
5566b478 MS |
868 | if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == TYPE_DECL) |
869 | dump_type (TREE_TYPE (t), v); | |
52bf7d5d MM |
870 | else if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == VAR_DECL) |
871 | dump_decl (DECL_TEMPLATE_RESULT (t), v); | |
6467930b MS |
872 | else if (TREE_TYPE (t) == NULL_TREE) |
873 | my_friendly_abort (353); | |
51c184be MS |
874 | else switch (NEXT_CODE (t)) |
875 | { | |
876 | case METHOD_TYPE: | |
877 | case FUNCTION_TYPE: | |
878 | dump_function_decl (t, v); | |
879 | break; | |
880 | ||
881 | default: | |
abff8e06 JM |
882 | /* This case can occur with some illegal code. */ |
883 | dump_type (TREE_TYPE (t), v); | |
51c184be MS |
884 | } |
885 | } | |
8d08fdba MS |
886 | break; |
887 | ||
74cd8397 JM |
888 | case TEMPLATE_ID_EXPR: |
889 | { | |
890 | tree args; | |
aa36c081 JM |
891 | tree name = TREE_OPERAND (t, 0); |
892 | if (is_overloaded_fn (name)) | |
893 | name = DECL_NAME (get_first_fn (name)); | |
894 | dump_decl (name, v); | |
74cd8397 JM |
895 | OB_PUTC ('<'); |
896 | for (args = TREE_OPERAND (t, 1); args; args = TREE_CHAIN (args)) | |
897 | { | |
73b0fce8 KL |
898 | if (TREE_CODE_CLASS (TREE_CODE (TREE_VALUE (args))) == 't' |
899 | || TREE_CODE (TREE_VALUE (args)) == TEMPLATE_DECL) | |
74cd8397 JM |
900 | dump_type (TREE_VALUE (args), 0); |
901 | else | |
902 | dump_expr (TREE_VALUE (args), 0); | |
903 | if (TREE_CHAIN (args)) | |
904 | OB_PUTC2 (',', ' '); | |
905 | } | |
0aafb128 | 906 | OB_END_TEMPLATE_ID (); |
74cd8397 JM |
907 | } |
908 | break; | |
909 | ||
0fb9f1c3 | 910 | case LOOKUP_EXPR: |
f9d94ea4 | 911 | dump_decl (TREE_OPERAND (t, 0), v); |
0fb9f1c3 JM |
912 | break; |
913 | ||
8d08fdba MS |
914 | case LABEL_DECL: |
915 | OB_PUTID (DECL_NAME (t)); | |
916 | break; | |
917 | ||
918 | case CONST_DECL: | |
6467930b | 919 | if ((TREE_TYPE (t) != NULL_TREE && NEXT_CODE (t) == ENUMERAL_TYPE) |
03555413 | 920 | || (DECL_INITIAL (t) && |
f84b4be9 | 921 | TREE_CODE (DECL_INITIAL (t)) == TEMPLATE_PARM_INDEX)) |
07389efe | 922 | dump_simple_decl (t, TREE_TYPE (t), v); |
224c649b BH |
923 | else if (DECL_NAME (t)) |
924 | dump_decl (DECL_NAME (t), v); | |
03555413 | 925 | else if (DECL_INITIAL (t)) |
8d08fdba | 926 | dump_expr (DECL_INITIAL (t), 0); |
03555413 MM |
927 | else |
928 | OB_PUTS ("enumerator"); | |
8d08fdba MS |
929 | break; |
930 | ||
cffa8729 MS |
931 | case USING_DECL: |
932 | OB_PUTS ("using "); | |
933 | dump_type (DECL_INITIAL (t), 0); | |
934 | OB_PUTS ("::"); | |
935 | OB_PUTID (DECL_NAME (t)); | |
936 | break; | |
937 | ||
8d08fdba | 938 | default: |
51c184be MS |
939 | sorry ("`%s' not supported by dump_decl", |
940 | tree_code_name[(int) TREE_CODE (t)]); | |
8d08fdba MS |
941 | } |
942 | } | |
943 | ||
4995028c NS |
944 | /* Pretty print a function decl. There are several ways we want to print a |
945 | function declaration. We use V to tell us what. | |
946 | V - 01 23 | |
947 | args - ++ ++ | |
948 | retval - -+ ++ | |
949 | default- -+ -+ | |
950 | throw - -- ++ | |
951 | As cp_error can only apply the '#' flag once to give 0 and 1 for V, there | |
952 | is %D which doesn't print the throw specs, and %F which does. */ | |
8d08fdba MS |
953 | |
954 | static void | |
955 | dump_function_decl (t, v) | |
956 | tree t; | |
957 | int v; | |
958 | { | |
98c1c668 JM |
959 | tree name; |
960 | tree fntype; | |
961 | tree parmtypes; | |
8d08fdba | 962 | tree cname = NULL_TREE; |
8d08fdba | 963 | |
98c1c668 JM |
964 | if (TREE_CODE (t) == TEMPLATE_DECL) |
965 | t = DECL_TEMPLATE_RESULT (t); | |
966 | ||
967 | name = DECL_ASSEMBLER_NAME (t); | |
968 | fntype = TREE_TYPE (t); | |
969 | parmtypes = TYPE_ARG_TYPES (fntype); | |
970 | ||
8d08fdba | 971 | /* Friends have DECL_CLASS_CONTEXT set, but not DECL_CONTEXT. */ |
2642b9bf | 972 | if (DECL_CLASS_SCOPE_P (t)) |
8d08fdba MS |
973 | cname = DECL_CLASS_CONTEXT (t); |
974 | /* this is for partially instantiated template methods */ | |
975 | else if (TREE_CODE (fntype) == METHOD_TYPE) | |
976 | cname = TREE_TYPE (TREE_VALUE (parmtypes)); | |
977 | ||
61cd552e MM |
978 | /* Print the return type. */ |
979 | if (v > 0) | |
8d08fdba MS |
980 | { |
981 | if (DECL_STATIC_FUNCTION_P (t)) | |
982 | OB_PUTS ("static "); | |
983 | ||
aa45967f | 984 | if (! DECL_CONV_FN_P (t) |
8d08fdba | 985 | && ! DECL_CONSTRUCTOR_P (t) |
aa45967f | 986 | && ! DECL_DESTRUCTOR_P (t)) |
8d08fdba | 987 | { |
294471c3 | 988 | dump_type_prefix (TREE_TYPE (fntype), 1, 0); |
8d08fdba MS |
989 | OB_PUTC (' '); |
990 | } | |
991 | } | |
992 | ||
61cd552e | 993 | /* Print the function name. */ |
8d08fdba MS |
994 | if (cname) |
995 | { | |
996 | dump_type (cname, 0); | |
997 | OB_PUTC2 (':', ':'); | |
998 | if (TREE_CODE (fntype) == METHOD_TYPE && parmtypes) | |
999 | parmtypes = TREE_CHAIN (parmtypes); | |
1000 | if (DECL_CONSTRUCTOR_FOR_VBASE_P (t)) | |
1001 | /* Skip past "in_charge" identifier. */ | |
1002 | parmtypes = TREE_CHAIN (parmtypes); | |
1003 | } | |
2642b9bf JM |
1004 | else if (CP_DECL_CONTEXT (t) != global_namespace) |
1005 | { | |
1006 | dump_decl (DECL_CONTEXT (t), 0); | |
1007 | OB_PUTC2 (':',':'); | |
1008 | } | |
8d08fdba | 1009 | |
f30432d7 | 1010 | if (DESTRUCTOR_NAME_P (name) && DECL_LANGUAGE (t) == lang_cplusplus) |
8d08fdba MS |
1011 | parmtypes = TREE_CHAIN (parmtypes); |
1012 | ||
1013 | dump_function_name (t); | |
61cd552e MM |
1014 | |
1015 | /* If V is negative, we don't print the argument types. */ | |
1016 | if (v < 0) | |
1017 | return; | |
1018 | ||
4995028c NS |
1019 | dump_parameters (parmtypes, v & 1, 0); |
1020 | ||
aa45967f | 1021 | if (v && ! DECL_CONV_FN_P (t)) |
294471c3 | 1022 | dump_type_suffix (TREE_TYPE (fntype), 1, 0); |
8d08fdba MS |
1023 | |
1024 | if (TREE_CODE (fntype) == METHOD_TYPE) | |
6eabb241 MM |
1025 | dump_qualifiers (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype))), |
1026 | before); | |
4995028c NS |
1027 | |
1028 | if (v >= 2) | |
1029 | dump_exception_spec (TYPE_RAISES_EXCEPTIONS (fntype), 0); | |
1030 | } | |
1031 | ||
1032 | /* Print a parameter list. V indicates if we show default values or not. If | |
1033 | these are for a member function, the member object ptr | |
1034 | (and any other hidden args) should have already been removed. */ | |
1035 | ||
1036 | static void | |
1037 | dump_parameters (parmtypes, v, canonical_name) | |
1038 | tree parmtypes; | |
1039 | int v; | |
1040 | int canonical_name; | |
1041 | { | |
1042 | int first; | |
1043 | OB_PUTC ('('); | |
1044 | ||
1045 | for (first = 1; parmtypes != void_list_node; | |
1046 | parmtypes = TREE_CHAIN (parmtypes)) | |
1047 | { | |
1048 | if (!first) | |
1049 | OB_PUTC2 (',', ' '); | |
1050 | first = 0; | |
1051 | if (!parmtypes) | |
1052 | { | |
1053 | OB_PUTS ("..."); | |
1054 | break; | |
1055 | } | |
1056 | dump_type_real (TREE_VALUE (parmtypes), 0, canonical_name); | |
1057 | ||
1058 | if (TREE_PURPOSE (parmtypes) && v) | |
1059 | { | |
1060 | OB_PUTS (" = "); | |
1061 | dump_expr (TREE_PURPOSE (parmtypes), 0); | |
1062 | } | |
1063 | } | |
1064 | ||
1065 | OB_PUTC (')'); | |
1066 | } | |
1067 | ||
1068 | /* Print an exception specification. T is the exception specification. */ | |
1069 | ||
1070 | static void | |
1071 | dump_exception_spec (t, canonical_name) | |
1072 | tree t; | |
1073 | int canonical_name; | |
1074 | { | |
1075 | if (t) | |
1076 | { | |
1077 | OB_PUTS (" throw ("); | |
1078 | if (TREE_VALUE (t) != NULL_TREE) | |
1079 | while (1) | |
1080 | { | |
1081 | dump_type_real (TREE_VALUE (t), 0, canonical_name); | |
1082 | t = TREE_CHAIN (t); | |
1083 | if (!t) | |
1084 | break; | |
1085 | OB_PUTC2 (',', ' '); | |
1086 | } | |
1087 | OB_PUTC (')'); | |
1088 | } | |
8d08fdba MS |
1089 | } |
1090 | ||
1091 | /* Handle the function name for a FUNCTION_DECL node, grokking operators | |
1092 | and destructors properly. */ | |
e92cc029 | 1093 | |
8d08fdba MS |
1094 | static void |
1095 | dump_function_name (t) | |
1096 | tree t; | |
1097 | { | |
1098 | tree name = DECL_NAME (t); | |
1099 | ||
aa45967f | 1100 | if (DECL_DESTRUCTOR_P (t)) |
8d08fdba MS |
1101 | { |
1102 | OB_PUTC ('~'); | |
1103 | dump_decl (name, 0); | |
1104 | } | |
aa45967f | 1105 | else if (DECL_CONV_FN_P (t)) |
8d08fdba MS |
1106 | { |
1107 | /* This cannot use the hack that the operator's return | |
1108 | type is stashed off of its name because it may be | |
1109 | used for error reporting. In the case of conflicting | |
1110 | declarations, both will have the same name, yet | |
1111 | the types will be different, hence the TREE_TYPE field | |
1112 | of the first name will be clobbered by the second. */ | |
1113 | OB_PUTS ("operator "); | |
1114 | dump_type (TREE_TYPE (TREE_TYPE (t)), 0); | |
1115 | } | |
1116 | else if (IDENTIFIER_OPNAME_P (name)) | |
1117 | { | |
9c0758dd | 1118 | const char *name_string = operator_name_string (name); |
8d08fdba MS |
1119 | OB_PUTS ("operator "); |
1120 | OB_PUTCP (name_string); | |
1121 | } | |
1122 | else | |
1123 | dump_decl (name, 0); | |
386b8a85 | 1124 | |
36a117a5 MM |
1125 | if (DECL_LANG_SPECIFIC (t) && DECL_USE_TEMPLATE (t) |
1126 | && DECL_TEMPLATE_INFO (t) | |
1127 | && (DECL_TEMPLATE_SPECIALIZATION (t) | |
1128 | || TREE_CODE (DECL_TI_TEMPLATE (t)) != TEMPLATE_DECL | |
1129 | || DECL_TEMPLATE_SPECIALIZATION (DECL_TI_TEMPLATE (t)) | |
1130 | || PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t)))) | |
386b8a85 | 1131 | { |
75650646 | 1132 | tree args = DECL_TEMPLATE_INFO (t) ? DECL_TI_ARGS (t) : NULL_TREE; |
36a117a5 | 1133 | OB_PUTC ('<'); |
75650646 | 1134 | |
36a117a5 MM |
1135 | /* Be careful only to print things when we have them, so as not |
1136 | to crash producing error messages. */ | |
1137 | if (args) | |
386b8a85 | 1138 | { |
36a117a5 | 1139 | if (TREE_CODE (args) == TREE_LIST) |
75650646 | 1140 | { |
36a117a5 MM |
1141 | tree arg; |
1142 | int need_comma = 0; | |
1143 | ||
1144 | for (arg = args; arg; arg = TREE_CHAIN (arg)) | |
386b8a85 | 1145 | { |
36a117a5 | 1146 | tree a = TREE_VALUE (arg); |
386b8a85 | 1147 | |
36a117a5 MM |
1148 | if (need_comma) |
1149 | OB_PUTS (", "); | |
1150 | ||
1151 | if (a) | |
1152 | { | |
1153 | if (TREE_CODE_CLASS (TREE_CODE (a)) == 't' | |
1154 | || TREE_CODE (a) == TEMPLATE_DECL) | |
1155 | dump_type (a, 0); | |
1156 | else | |
1157 | dump_expr (a, 0); | |
75650646 | 1158 | } |
36a117a5 MM |
1159 | |
1160 | need_comma = 1; | |
386b8a85 | 1161 | } |
36a117a5 MM |
1162 | } |
1163 | else if (TREE_CODE (args) == TREE_VEC) | |
1164 | { | |
1165 | int i; | |
1166 | int need_comma = 0; | |
1167 | ||
1168 | if (TREE_VEC_LENGTH (args) > 0 | |
1169 | && TREE_CODE (TREE_VEC_ELT (args, 0)) == TREE_VEC) | |
1170 | args = TREE_VEC_ELT (args, | |
1171 | TREE_VEC_LENGTH (args) - 1); | |
1172 | ||
1173 | for (i = 0; i < TREE_VEC_LENGTH (args); i++) | |
386b8a85 | 1174 | { |
36a117a5 | 1175 | tree a = TREE_VEC_ELT (args, i); |
386b8a85 | 1176 | |
36a117a5 MM |
1177 | if (need_comma) |
1178 | OB_PUTS (", "); | |
1179 | ||
1180 | if (a) | |
1181 | { | |
1182 | if (TREE_CODE_CLASS (TREE_CODE (a)) == 't' | |
1183 | || TREE_CODE (a) == TEMPLATE_DECL) | |
1184 | dump_type (a, 0); | |
1185 | else | |
1186 | dump_expr (a, 0); | |
75650646 | 1187 | } |
36a117a5 MM |
1188 | |
1189 | need_comma = 1; | |
386b8a85 JM |
1190 | } |
1191 | } | |
1192 | } | |
0aafb128 | 1193 | OB_END_TEMPLATE_ID (); |
386b8a85 | 1194 | } |
8d08fdba MS |
1195 | } |
1196 | ||
1197 | static void | |
1198 | dump_char (c) | |
b2bb2710 | 1199 | int c; |
8d08fdba MS |
1200 | { |
1201 | switch (c) | |
1202 | { | |
a0a33927 | 1203 | case TARGET_NEWLINE: |
8d08fdba MS |
1204 | OB_PUTS ("\\n"); |
1205 | break; | |
a0a33927 | 1206 | case TARGET_TAB: |
8d08fdba MS |
1207 | OB_PUTS ("\\t"); |
1208 | break; | |
a0a33927 | 1209 | case TARGET_VT: |
8d08fdba MS |
1210 | OB_PUTS ("\\v"); |
1211 | break; | |
a0a33927 | 1212 | case TARGET_BS: |
8d08fdba MS |
1213 | OB_PUTS ("\\b"); |
1214 | break; | |
a0a33927 | 1215 | case TARGET_CR: |
8d08fdba MS |
1216 | OB_PUTS ("\\r"); |
1217 | break; | |
a0a33927 | 1218 | case TARGET_FF: |
8d08fdba MS |
1219 | OB_PUTS ("\\f"); |
1220 | break; | |
a0a33927 | 1221 | case TARGET_BELL: |
8d08fdba MS |
1222 | OB_PUTS ("\\a"); |
1223 | break; | |
1224 | case '\\': | |
1225 | OB_PUTS ("\\\\"); | |
1226 | break; | |
1227 | case '\'': | |
1228 | OB_PUTS ("\\'"); | |
1229 | break; | |
1230 | case '\"': | |
1231 | OB_PUTS ("\\\""); | |
1232 | break; | |
1233 | default: | |
faa25e97 | 1234 | if (ISPRINT (c)) |
8d08fdba MS |
1235 | OB_PUTC (c); |
1236 | else | |
1237 | { | |
1238 | sprintf (digit_buffer, "\\%03o", (int) c); | |
1239 | OB_PUTCP (digit_buffer); | |
1240 | } | |
1241 | } | |
1242 | } | |
1243 | ||
1244 | /* Print out a list of initializers (subr of dump_expr) */ | |
e92cc029 | 1245 | |
8d08fdba MS |
1246 | static void |
1247 | dump_expr_list (l) | |
1248 | tree l; | |
1249 | { | |
1250 | while (l) | |
1251 | { | |
1252 | dump_expr (TREE_VALUE (l), 0); | |
1253 | if (TREE_CHAIN (l)) | |
1254 | OB_PUTC2 (',', ' '); | |
1255 | l = TREE_CHAIN (l); | |
1256 | } | |
1257 | } | |
1258 | ||
1259 | /* Print out an expression */ | |
e92cc029 | 1260 | |
8d08fdba MS |
1261 | static void |
1262 | dump_expr (t, nop) | |
1263 | tree t; | |
1264 | int nop; /* suppress parens */ | |
1265 | { | |
1266 | switch (TREE_CODE (t)) | |
1267 | { | |
1268 | case VAR_DECL: | |
1269 | case PARM_DECL: | |
1270 | case FIELD_DECL: | |
1271 | case CONST_DECL: | |
1272 | case FUNCTION_DECL: | |
ec255269 | 1273 | case TEMPLATE_DECL: |
6b57ac29 | 1274 | case NAMESPACE_DECL: |
8d08fdba MS |
1275 | dump_decl (t, -1); |
1276 | break; | |
1277 | ||
1278 | case INTEGER_CST: | |
1279 | { | |
1280 | tree type = TREE_TYPE (t); | |
1281 | my_friendly_assert (type != 0, 81); | |
1282 | ||
1283 | /* If it's an enum, output its tag, rather than its value. */ | |
1284 | if (TREE_CODE (type) == ENUMERAL_TYPE) | |
1285 | { | |
9c0758dd | 1286 | const char *p = enum_name_string (t, type); |
8d08fdba MS |
1287 | OB_PUTCP (p); |
1288 | } | |
b7484fbe MS |
1289 | else if (type == boolean_type_node) |
1290 | { | |
72b7eeff MS |
1291 | if (t == boolean_false_node |
1292 | || (TREE_INT_CST_LOW (t) == 0 | |
1293 | && TREE_INT_CST_HIGH (t) == 0)) | |
b7484fbe MS |
1294 | OB_PUTS ("false"); |
1295 | else if (t == boolean_true_node) | |
1296 | OB_PUTS ("true"); | |
b7484fbe MS |
1297 | } |
1298 | else if (type == char_type_node) | |
8d08fdba MS |
1299 | { |
1300 | OB_PUTC ('\''); | |
1301 | dump_char (TREE_INT_CST_LOW (t)); | |
1302 | OB_PUTC ('\''); | |
1303 | } | |
1304 | else if (TREE_INT_CST_HIGH (t) | |
1305 | != (TREE_INT_CST_LOW (t) >> (HOST_BITS_PER_WIDE_INT - 1))) | |
1306 | { | |
1307 | tree val = t; | |
1308 | if (TREE_INT_CST_HIGH (val) < 0) | |
1309 | { | |
1310 | OB_PUTC ('-'); | |
1311 | val = build_int_2 (~TREE_INT_CST_LOW (val), | |
1312 | -TREE_INT_CST_HIGH (val)); | |
1313 | } | |
1314 | /* Would "%x%0*x" or "%x%*0x" get zero-padding on all | |
1315 | systems? */ | |
1316 | { | |
1317 | static char format[10]; /* "%x%09999x\0" */ | |
1318 | if (!format[0]) | |
1319 | sprintf (format, "%%x%%0%dx", HOST_BITS_PER_INT / 4); | |
1320 | sprintf (digit_buffer, format, TREE_INT_CST_HIGH (val), | |
1321 | TREE_INT_CST_LOW (val)); | |
1322 | OB_PUTCP (digit_buffer); | |
1323 | } | |
1324 | } | |
1325 | else | |
1326 | OB_PUTI (TREE_INT_CST_LOW (t)); | |
1327 | } | |
1328 | break; | |
1329 | ||
1330 | case REAL_CST: | |
1331 | #ifndef REAL_IS_NOT_DOUBLE | |
1332 | sprintf (digit_buffer, "%g", TREE_REAL_CST (t)); | |
1333 | #else | |
1334 | { | |
9c0758dd | 1335 | const unsigned char *p = (const unsigned char *) &TREE_REAL_CST (t); |
a703fb38 | 1336 | size_t i; |
8d08fdba MS |
1337 | strcpy (digit_buffer, "0x"); |
1338 | for (i = 0; i < sizeof TREE_REAL_CST (t); i++) | |
1339 | sprintf (digit_buffer + 2 + 2*i, "%02x", *p++); | |
1340 | } | |
1341 | #endif | |
1342 | OB_PUTCP (digit_buffer); | |
1343 | break; | |
1344 | ||
61a127b3 MM |
1345 | case PTRMEM_CST: |
1346 | OB_PUTC ('&'); | |
1347 | dump_type (PTRMEM_CST_CLASS (t), 0); | |
1348 | OB_PUTS ("::"); | |
1349 | OB_PUTID (DECL_NAME (PTRMEM_CST_MEMBER (t))); | |
1350 | break; | |
1351 | ||
8d08fdba MS |
1352 | case STRING_CST: |
1353 | { | |
9c0758dd | 1354 | const char *p = TREE_STRING_POINTER (t); |
8d08fdba MS |
1355 | int len = TREE_STRING_LENGTH (t) - 1; |
1356 | int i; | |
1357 | ||
1358 | OB_PUTC ('\"'); | |
1359 | for (i = 0; i < len; i++) | |
1360 | dump_char (p[i]); | |
1361 | OB_PUTC ('\"'); | |
1362 | } | |
1363 | break; | |
1364 | ||
1365 | case COMPOUND_EXPR: | |
1366 | dump_binary_op (",", t); | |
1367 | break; | |
1368 | ||
1369 | case COND_EXPR: | |
1370 | OB_PUTC ('('); | |
1371 | dump_expr (TREE_OPERAND (t, 0), 0); | |
1372 | OB_PUTS (" ? "); | |
1373 | dump_expr (TREE_OPERAND (t, 1), 0); | |
1374 | OB_PUTS (" : "); | |
1375 | dump_expr (TREE_OPERAND (t, 2), 0); | |
1376 | OB_PUTC (')'); | |
1377 | break; | |
1378 | ||
1379 | case SAVE_EXPR: | |
1380 | if (TREE_HAS_CONSTRUCTOR (t)) | |
1381 | { | |
1382 | OB_PUTS ("new "); | |
1383 | dump_type (TREE_TYPE (TREE_TYPE (t)), 0); | |
8d08fdba MS |
1384 | } |
1385 | else | |
1386 | { | |
6060a796 | 1387 | dump_expr (TREE_OPERAND (t, 0), 0); |
8d08fdba MS |
1388 | } |
1389 | break; | |
1390 | ||
02531345 | 1391 | case AGGR_INIT_EXPR: |
27b8d0cd MM |
1392 | { |
1393 | tree fn = NULL_TREE; | |
1394 | ||
1395 | if (TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR) | |
1396 | fn = TREE_OPERAND (TREE_OPERAND (t, 0), 0); | |
1397 | ||
1398 | if (fn && TREE_CODE (fn) == FUNCTION_DECL) | |
1399 | { | |
1400 | if (DECL_CONSTRUCTOR_P (fn)) | |
1401 | OB_PUTID (TYPE_IDENTIFIER (TREE_TYPE (t))); | |
1402 | else | |
1403 | dump_decl (fn, 0); | |
1404 | } | |
1405 | else | |
1406 | dump_expr (TREE_OPERAND (t, 0), 0); | |
1407 | } | |
8d08fdba | 1408 | OB_PUTC ('('); |
42976354 BK |
1409 | if (TREE_OPERAND (t, 1)) |
1410 | dump_expr_list (TREE_CHAIN (TREE_OPERAND (t, 1))); | |
8d08fdba MS |
1411 | OB_PUTC (')'); |
1412 | break; | |
1413 | ||
1414 | case CALL_EXPR: | |
1415 | { | |
1416 | tree fn = TREE_OPERAND (t, 0); | |
1417 | tree args = TREE_OPERAND (t, 1); | |
1418 | ||
1419 | if (TREE_CODE (fn) == ADDR_EXPR) | |
1420 | fn = TREE_OPERAND (fn, 0); | |
1421 | ||
6467930b | 1422 | if (TREE_TYPE (fn) != NULL_TREE && NEXT_CODE (fn) == METHOD_TYPE) |
8d08fdba MS |
1423 | { |
1424 | tree ob = TREE_VALUE (args); | |
1425 | if (TREE_CODE (ob) == ADDR_EXPR) | |
1426 | { | |
1427 | dump_expr (TREE_OPERAND (ob, 0), 0); | |
1428 | OB_PUTC ('.'); | |
1429 | } | |
1430 | else if (TREE_CODE (ob) != PARM_DECL | |
1431 | || strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this")) | |
1432 | { | |
1433 | dump_expr (ob, 0); | |
1434 | OB_PUTC2 ('-', '>'); | |
1435 | } | |
1436 | args = TREE_CHAIN (args); | |
1437 | } | |
1438 | dump_expr (fn, 0); | |
fc378698 | 1439 | OB_PUTC ('('); |
8d08fdba MS |
1440 | dump_expr_list (args); |
1441 | OB_PUTC (')'); | |
1442 | } | |
1443 | break; | |
1444 | ||
285baa06 JM |
1445 | case NEW_EXPR: |
1446 | { | |
1447 | tree type = TREE_OPERAND (t, 1); | |
1448 | if (NEW_EXPR_USE_GLOBAL (t)) | |
1449 | OB_PUTS ("::"); | |
1450 | OB_PUTS ("new "); | |
1451 | if (TREE_OPERAND (t, 0)) | |
1452 | { | |
1453 | OB_PUTC ('('); | |
1454 | dump_expr_list (TREE_OPERAND (t, 0)); | |
1455 | OB_PUTS (") "); | |
1456 | } | |
1457 | if (TREE_CODE (type) == ARRAY_REF) | |
1458 | type = build_cplus_array_type | |
1459 | (TREE_OPERAND (type, 0), | |
1460 | build_index_type (size_binop (MINUS_EXPR, TREE_OPERAND (type, 1), | |
1461 | integer_one_node))); | |
1462 | dump_type (type, 0); | |
1463 | if (TREE_OPERAND (t, 2)) | |
1464 | { | |
1465 | OB_PUTC ('('); | |
1466 | dump_expr_list (TREE_OPERAND (t, 2)); | |
1467 | OB_PUTC (')'); | |
1468 | } | |
1469 | } | |
1470 | break; | |
1471 | ||
8d08fdba MS |
1472 | case TARGET_EXPR: |
1473 | /* Note that this only works for G++ target exprs. If somebody | |
1474 | builds a general TARGET_EXPR, there's no way to represent that | |
1475 | it initializes anything other that the parameter slot for the | |
1476 | default argument. Note we may have cleared out the first | |
1477 | operand in expand_expr, so don't go killing ourselves. */ | |
1478 | if (TREE_OPERAND (t, 1)) | |
1479 | dump_expr (TREE_OPERAND (t, 1), 0); | |
1480 | break; | |
1481 | ||
1482 | case MODIFY_EXPR: | |
1483 | case PLUS_EXPR: | |
1484 | case MINUS_EXPR: | |
1485 | case MULT_EXPR: | |
1486 | case TRUNC_DIV_EXPR: | |
1487 | case TRUNC_MOD_EXPR: | |
1488 | case MIN_EXPR: | |
1489 | case MAX_EXPR: | |
1490 | case LSHIFT_EXPR: | |
1491 | case RSHIFT_EXPR: | |
1492 | case BIT_IOR_EXPR: | |
1493 | case BIT_XOR_EXPR: | |
1494 | case BIT_AND_EXPR: | |
1495 | case BIT_ANDTC_EXPR: | |
1496 | case TRUTH_ANDIF_EXPR: | |
1497 | case TRUTH_ORIF_EXPR: | |
1498 | case LT_EXPR: | |
1499 | case LE_EXPR: | |
1500 | case GT_EXPR: | |
1501 | case GE_EXPR: | |
1502 | case EQ_EXPR: | |
1503 | case NE_EXPR: | |
2adeacc9 | 1504 | case EXACT_DIV_EXPR: |
8d08fdba MS |
1505 | dump_binary_op (opname_tab[(int) TREE_CODE (t)], t); |
1506 | break; | |
1507 | ||
1508 | case CEIL_DIV_EXPR: | |
1509 | case FLOOR_DIV_EXPR: | |
1510 | case ROUND_DIV_EXPR: | |
1511 | dump_binary_op ("/", t); | |
1512 | break; | |
1513 | ||
1514 | case CEIL_MOD_EXPR: | |
1515 | case FLOOR_MOD_EXPR: | |
1516 | case ROUND_MOD_EXPR: | |
1517 | dump_binary_op ("%", t); | |
1518 | break; | |
1519 | ||
1520 | case COMPONENT_REF: | |
1521 | { | |
1522 | tree ob = TREE_OPERAND (t, 0); | |
1523 | if (TREE_CODE (ob) == INDIRECT_REF) | |
1524 | { | |
1525 | ob = TREE_OPERAND (ob, 0); | |
1526 | if (TREE_CODE (ob) != PARM_DECL | |
1527 | || strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this")) | |
1528 | { | |
1529 | dump_expr (ob, 0); | |
1530 | OB_PUTC2 ('-', '>'); | |
1531 | } | |
1532 | } | |
1533 | else | |
1534 | { | |
1535 | dump_expr (ob, 0); | |
1536 | OB_PUTC ('.'); | |
1537 | } | |
1538 | dump_expr (TREE_OPERAND (t, 1), 1); | |
1539 | } | |
1540 | break; | |
1541 | ||
28cbf42c MS |
1542 | case ARRAY_REF: |
1543 | dump_expr (TREE_OPERAND (t, 0), 0); | |
1544 | OB_PUTC ('['); | |
1545 | dump_expr (TREE_OPERAND (t, 1), 0); | |
1546 | OB_PUTC (']'); | |
1547 | break; | |
1548 | ||
8d08fdba MS |
1549 | case CONVERT_EXPR: |
1550 | dump_unary_op ("+", t, nop); | |
1551 | break; | |
1552 | ||
1553 | case ADDR_EXPR: | |
1554 | if (TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL | |
1555 | || TREE_CODE (TREE_OPERAND (t, 0)) == STRING_CST) | |
1556 | dump_expr (TREE_OPERAND (t, 0), 0); | |
1557 | else | |
1558 | dump_unary_op ("&", t, nop); | |
1559 | break; | |
1560 | ||
1561 | case INDIRECT_REF: | |
1562 | if (TREE_HAS_CONSTRUCTOR (t)) | |
1563 | { | |
1564 | t = TREE_OPERAND (t, 0); | |
1565 | my_friendly_assert (TREE_CODE (t) == CALL_EXPR, 237); | |
1566 | dump_expr (TREE_OPERAND (t, 0), 0); | |
1567 | OB_PUTC ('('); | |
1568 | dump_expr_list (TREE_CHAIN (TREE_OPERAND (t, 1))); | |
1569 | OB_PUTC (')'); | |
1570 | } | |
1571 | else | |
1572 | { | |
6467930b | 1573 | if (TREE_OPERAND (t,0) != NULL_TREE |
5082a355 | 1574 | && TREE_TYPE (TREE_OPERAND (t, 0)) |
6467930b | 1575 | && NEXT_CODE (TREE_OPERAND (t, 0)) == REFERENCE_TYPE) |
8d08fdba MS |
1576 | dump_expr (TREE_OPERAND (t, 0), nop); |
1577 | else | |
1578 | dump_unary_op ("*", t, nop); | |
1579 | } | |
1580 | break; | |
1581 | ||
1582 | case NEGATE_EXPR: | |
1583 | case BIT_NOT_EXPR: | |
1584 | case TRUTH_NOT_EXPR: | |
1585 | case PREDECREMENT_EXPR: | |
1586 | case PREINCREMENT_EXPR: | |
1587 | dump_unary_op (opname_tab [(int)TREE_CODE (t)], t, nop); | |
1588 | break; | |
1589 | ||
1590 | case POSTDECREMENT_EXPR: | |
1591 | case POSTINCREMENT_EXPR: | |
1592 | OB_PUTC ('('); | |
1593 | dump_expr (TREE_OPERAND (t, 0), 0); | |
1594 | OB_PUTCP (opname_tab[(int)TREE_CODE (t)]); | |
1595 | OB_PUTC (')'); | |
1596 | break; | |
1597 | ||
1598 | case NON_LVALUE_EXPR: | |
1599 | /* FIXME: This is a KLUDGE workaround for a parsing problem. There | |
1600 | should be another level of INDIRECT_REF so that I don't have to do | |
1601 | this. */ | |
6467930b | 1602 | if (TREE_TYPE (t) != NULL_TREE && NEXT_CODE (t) == POINTER_TYPE) |
8d08fdba MS |
1603 | { |
1604 | tree next = TREE_TYPE (TREE_TYPE (t)); | |
1605 | ||
1606 | while (TREE_CODE (next) == POINTER_TYPE) | |
1607 | next = TREE_TYPE (next); | |
1608 | ||
1609 | if (TREE_CODE (next) == FUNCTION_TYPE) | |
1610 | { | |
1611 | if (!nop) OB_PUTC ('('); | |
1612 | OB_PUTC ('*'); | |
1613 | dump_expr (TREE_OPERAND (t, 0), 1); | |
1614 | if (!nop) OB_PUTC (')'); | |
1615 | break; | |
1616 | } | |
1617 | /* else FALLTHRU */ | |
1618 | } | |
1619 | dump_expr (TREE_OPERAND (t, 0), 0); | |
1620 | break; | |
1621 | ||
1622 | case NOP_EXPR: | |
1623 | dump_expr (TREE_OPERAND (t, 0), nop); | |
1624 | break; | |
1625 | ||
1626 | case CONSTRUCTOR: | |
9a3b49ac MS |
1627 | if (TREE_TYPE (t) && TYPE_PTRMEMFUNC_P (TREE_TYPE (t))) |
1628 | { | |
1629 | tree idx = build_component_ref (t, index_identifier, NULL_TREE, 0); | |
1630 | ||
1631 | if (integer_all_onesp (idx)) | |
1632 | { | |
1633 | tree pfn = PFN_FROM_PTRMEMFUNC (t); | |
bbcec105 | 1634 | dump_unary_op ("&", pfn, 0); |
9a3b49ac MS |
1635 | break; |
1636 | } | |
e08a8f45 MM |
1637 | else if (TREE_CODE (idx) == INTEGER_CST |
1638 | && tree_int_cst_equal (idx, integer_zero_node)) | |
1639 | { | |
1640 | /* A NULL pointer-to-member constant. */ | |
1641 | OB_PUTS ("(("); | |
1642 | dump_type (TREE_TYPE (t), 0); | |
1643 | OB_PUTS (") 0)"); | |
1644 | break; | |
1645 | } | |
1646 | else if (TREE_CODE (idx) == INTEGER_CST | |
1647 | && TREE_INT_CST_HIGH (idx) == 0) | |
9a3b49ac MS |
1648 | { |
1649 | tree virtuals; | |
1650 | unsigned HOST_WIDE_INT n; | |
1651 | ||
1652 | t = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (t))); | |
1653 | t = TYPE_METHOD_BASETYPE (t); | |
83f2ccf4 | 1654 | virtuals = TYPE_BINFO_VIRTUALS (TYPE_MAIN_VARIANT (t)); |
9a3b49ac MS |
1655 | |
1656 | n = TREE_INT_CST_LOW (idx); | |
1657 | ||
1658 | /* Map vtable index back one, to allow for the null pointer to | |
1659 | member. */ | |
1660 | --n; | |
1661 | ||
1662 | while (n > 0 && virtuals) | |
1663 | { | |
1664 | --n; | |
1665 | virtuals = TREE_CHAIN (virtuals); | |
1666 | } | |
1667 | if (virtuals) | |
1668 | { | |
83f2ccf4 | 1669 | dump_expr (TREE_VALUE (virtuals), 0); |
9a3b49ac MS |
1670 | break; |
1671 | } | |
1672 | } | |
1673 | } | |
8d08fdba | 1674 | OB_PUTC ('{'); |
6467930b | 1675 | dump_expr_list (CONSTRUCTOR_ELTS (t)); |
8d08fdba MS |
1676 | OB_PUTC ('}'); |
1677 | break; | |
1678 | ||
51c184be MS |
1679 | case OFFSET_REF: |
1680 | { | |
1681 | tree ob = TREE_OPERAND (t, 0); | |
51924768 | 1682 | if (is_dummy_object (ob)) |
61a127b3 | 1683 | { |
05e0b2f4 JM |
1684 | t = TREE_OPERAND (t, 1); |
1685 | if (TREE_CODE (t) == FUNCTION_DECL) | |
61a127b3 | 1686 | /* A::f */ |
05e0b2f4 JM |
1687 | dump_expr (t, 0); |
1688 | else if (BASELINK_P (t)) | |
1689 | dump_expr (OVL_CURRENT (TREE_VALUE (t)), 0); | |
61a127b3 | 1690 | else |
05e0b2f4 | 1691 | dump_decl (t, 0); |
61a127b3 | 1692 | } |
51c184be MS |
1693 | else |
1694 | { | |
bbcec105 JM |
1695 | if (TREE_CODE (ob) == INDIRECT_REF) |
1696 | { | |
1697 | dump_expr (TREE_OPERAND (ob, 0), 0); | |
1698 | OB_PUTS (" ->* "); | |
1699 | } | |
1700 | else | |
1701 | { | |
1702 | dump_expr (ob, 0); | |
1703 | OB_PUTS (" .* "); | |
1704 | } | |
4ac14744 | 1705 | dump_expr (TREE_OPERAND (t, 1), 0); |
51c184be MS |
1706 | } |
1707 | break; | |
1708 | } | |
1709 | ||
f84b4be9 | 1710 | case TEMPLATE_PARM_INDEX: |
050367a3 | 1711 | dump_decl (TEMPLATE_PARM_DECL (t), -1); |
de22184b | 1712 | break; |
5566b478 MS |
1713 | |
1714 | case IDENTIFIER_NODE: | |
1715 | OB_PUTID (t); | |
1716 | break; | |
1717 | ||
1718 | case SCOPE_REF: | |
1719 | dump_type (TREE_OPERAND (t, 0), 0); | |
1720 | OB_PUTS ("::"); | |
1721 | dump_expr (TREE_OPERAND (t, 1), 0); | |
1722 | break; | |
1723 | ||
1724 | case CAST_EXPR: | |
e349ee73 MS |
1725 | if (TREE_OPERAND (t, 0) == NULL_TREE |
1726 | || TREE_CHAIN (TREE_OPERAND (t, 0))) | |
e76a2646 MS |
1727 | { |
1728 | dump_type (TREE_TYPE (t), 0); | |
1729 | OB_PUTC ('('); | |
6467930b | 1730 | dump_expr_list (TREE_OPERAND (t, 0)); |
e76a2646 MS |
1731 | OB_PUTC (')'); |
1732 | } | |
1733 | else | |
1734 | { | |
1735 | OB_PUTC ('('); | |
1736 | dump_type (TREE_TYPE (t), 0); | |
1737 | OB_PUTC (')'); | |
1738 | OB_PUTC ('('); | |
1739 | dump_expr_list (TREE_OPERAND (t, 0)); | |
1740 | OB_PUTC (')'); | |
1741 | } | |
1742 | break; | |
1743 | ||
1744 | case LOOKUP_EXPR: | |
1745 | OB_PUTID (TREE_OPERAND (t, 0)); | |
1746 | break; | |
1747 | ||
5a11e05b BK |
1748 | case ARROW_EXPR: |
1749 | dump_expr (TREE_OPERAND (t, 0), nop); | |
1750 | OB_PUTS ("->"); | |
1751 | break; | |
1752 | ||
e76a2646 | 1753 | case SIZEOF_EXPR: |
abff8e06 JM |
1754 | case ALIGNOF_EXPR: |
1755 | if (TREE_CODE (t) == SIZEOF_EXPR) | |
1756 | OB_PUTS ("sizeof ("); | |
1757 | else | |
1758 | { | |
1759 | my_friendly_assert (TREE_CODE (t) == ALIGNOF_EXPR, 0); | |
1760 | OB_PUTS ("__alignof__ ("); | |
1761 | } | |
e76a2646 MS |
1762 | if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (t, 0))) == 't') |
1763 | dump_type (TREE_OPERAND (t, 0), 0); | |
1764 | else | |
1765 | dump_unary_op ("*", t, 0); | |
1766 | OB_PUTC (')'); | |
1767 | break; | |
5566b478 | 1768 | |
da20811c JM |
1769 | case DEFAULT_ARG: |
1770 | OB_PUTS ("{unparsed}"); | |
1771 | break; | |
1772 | ||
6748b643 JM |
1773 | case TRY_CATCH_EXPR: |
1774 | case WITH_CLEANUP_EXPR: | |
1775 | case CLEANUP_POINT_EXPR: | |
1776 | dump_expr (TREE_OPERAND (t, 0), nop); | |
1777 | break; | |
1778 | ||
7ac7b28f MM |
1779 | case TEMPLATE_ID_EXPR: |
1780 | dump_decl (t, 0); | |
1781 | break; | |
1782 | ||
558475f0 MM |
1783 | case STMT_EXPR: |
1784 | /* We don't yet have a way of dumping statements in a | |
1785 | human-readable format. */ | |
1786 | OB_PUTS ("{ ... }"); | |
1787 | break; | |
1788 | ||
0045e0bc MM |
1789 | case BIND_EXPR: |
1790 | OB_PUTS ("{ "); | |
1791 | dump_expr (TREE_OPERAND (t, 1), nop); | |
1792 | OB_PUTS ("} "); | |
1793 | break; | |
1794 | ||
1795 | case LOOP_EXPR: | |
1796 | OB_PUTS ("while (1) { "); | |
1797 | dump_expr (TREE_OPERAND (t, 0), nop); | |
1798 | OB_PUTS ("} "); | |
1799 | break; | |
1800 | ||
1801 | case EXIT_EXPR: | |
1802 | OB_PUTS ("if ("); | |
1803 | dump_expr (TREE_OPERAND (t, 0), nop); | |
1804 | OB_PUTS (") break; "); | |
1805 | break; | |
1806 | ||
00595019 MS |
1807 | case TREE_LIST: |
1808 | if (TREE_VALUE (t) && TREE_CODE (TREE_VALUE (t)) == FUNCTION_DECL) | |
1809 | { | |
1810 | OB_PUTID (DECL_NAME (TREE_VALUE (t))); | |
1811 | break; | |
1812 | } | |
1813 | /* else fall through */ | |
1814 | ||
8d08fdba MS |
1815 | /* This list is incomplete, but should suffice for now. |
1816 | It is very important that `sorry' does not call | |
1817 | `report_error_function'. That could cause an infinite loop. */ | |
1818 | default: | |
1819 | sorry ("`%s' not supported by dump_expr", | |
1820 | tree_code_name[(int) TREE_CODE (t)]); | |
1821 | ||
1822 | /* fall through to ERROR_MARK... */ | |
1823 | case ERROR_MARK: | |
51c184be | 1824 | OB_PUTCP ("{error}"); |
8d08fdba MS |
1825 | break; |
1826 | } | |
1827 | } | |
1828 | ||
1829 | static void | |
1830 | dump_binary_op (opstring, t) | |
9c0758dd | 1831 | const char *opstring; |
8d08fdba MS |
1832 | tree t; |
1833 | { | |
1834 | OB_PUTC ('('); | |
1835 | dump_expr (TREE_OPERAND (t, 0), 1); | |
1836 | OB_PUTC (' '); | |
2adeacc9 MM |
1837 | if (opstring) |
1838 | OB_PUTCP (opstring); | |
1839 | else | |
1840 | OB_PUTS ("<unknown operator>"); | |
8d08fdba MS |
1841 | OB_PUTC (' '); |
1842 | dump_expr (TREE_OPERAND (t, 1), 1); | |
1843 | OB_PUTC (')'); | |
1844 | } | |
1845 | ||
1846 | static void | |
1847 | dump_unary_op (opstring, t, nop) | |
9c0758dd | 1848 | const char *opstring; |
8d08fdba MS |
1849 | tree t; |
1850 | int nop; | |
1851 | { | |
1852 | if (!nop) OB_PUTC ('('); | |
1853 | OB_PUTCP (opstring); | |
1854 | dump_expr (TREE_OPERAND (t, 0), 1); | |
1855 | if (!nop) OB_PUTC (')'); | |
1856 | } | |
1857 | ||
4995028c NS |
1858 | /* Print a function decl with exception specification included. */ |
1859 | ||
8d08fdba | 1860 | char * |
4995028c | 1861 | fndecl_as_string (fndecl, print_default_args_p) |
5566b478 | 1862 | tree fndecl; |
4995028c | 1863 | int print_default_args_p; |
8d08fdba | 1864 | { |
4995028c NS |
1865 | OB_INIT (); |
1866 | ||
1867 | dump_function_decl (fndecl, 2 + print_default_args_p); | |
1868 | ||
1869 | OB_FINISH (); | |
1870 | ||
1871 | return (char *)obstack_base (&scratch_obstack); | |
8d08fdba MS |
1872 | } |
1873 | ||
e1467ff2 | 1874 | /* Same, but handle a _TYPE. |
8d08fdba | 1875 | Called from convert_to_reference, mangle_class_name_for_template, |
294471c3 MM |
1876 | build_unary_op, and GNU_xref_decl. If CANONICAL_NAME is non-zero, |
1877 | when describing a typedef, we use the name of the type described, | |
1878 | rather than the name of the typedef. */ | |
e92cc029 | 1879 | |
8d08fdba | 1880 | char * |
294471c3 | 1881 | type_as_string_real (typ, v, canonical_name) |
8d08fdba MS |
1882 | tree typ; |
1883 | int v; | |
294471c3 | 1884 | int canonical_name; |
8d08fdba MS |
1885 | { |
1886 | OB_INIT (); | |
1887 | ||
294471c3 | 1888 | dump_type_real (typ, v, canonical_name); |
8d08fdba MS |
1889 | |
1890 | OB_FINISH (); | |
1891 | ||
1892 | return (char *)obstack_base (&scratch_obstack); | |
1893 | } | |
1894 | ||
294471c3 MM |
1895 | |
1896 | char * | |
1897 | type_as_string (typ, v) | |
1898 | tree typ; | |
1899 | int v; | |
1900 | { | |
1901 | return type_as_string_real (typ, v, 0); | |
1902 | } | |
1903 | ||
8d08fdba MS |
1904 | char * |
1905 | expr_as_string (decl, v) | |
1906 | tree decl; | |
7dee3f36 | 1907 | int v ATTRIBUTE_UNUSED; |
8d08fdba MS |
1908 | { |
1909 | OB_INIT (); | |
1910 | ||
1911 | dump_expr (decl, 1); | |
1912 | ||
1913 | OB_FINISH (); | |
1914 | ||
1915 | return (char *)obstack_base (&scratch_obstack); | |
1916 | } | |
1917 | ||
1918 | /* A cross between type_as_string and fndecl_as_string. | |
1919 | Only called from substitute_nice_name. */ | |
e92cc029 | 1920 | |
8d08fdba MS |
1921 | char * |
1922 | decl_as_string (decl, v) | |
1923 | tree decl; | |
1924 | int v; | |
1925 | { | |
1926 | OB_INIT (); | |
1927 | ||
1928 | dump_decl (decl, v); | |
1929 | ||
1930 | OB_FINISH (); | |
1931 | ||
1932 | return (char *)obstack_base (&scratch_obstack); | |
1933 | } | |
1934 | ||
2ba25f50 MS |
1935 | /* Generate the three forms of printable names for lang_printable_name. */ |
1936 | ||
1937 | char * | |
1938 | lang_decl_name (decl, v) | |
1939 | tree decl; | |
1940 | int v; | |
1941 | { | |
1942 | if (v >= 2) | |
1943 | return decl_as_string (decl, 1); | |
1944 | ||
1945 | OB_INIT (); | |
1946 | ||
6eb3bb27 | 1947 | if (v == 1 && DECL_CLASS_SCOPE_P (decl)) |
2ba25f50 MS |
1948 | { |
1949 | tree cname; | |
1950 | if (TREE_CODE (decl) == FUNCTION_DECL) | |
1951 | cname = DECL_CLASS_CONTEXT (decl); | |
1952 | else | |
1953 | cname = DECL_CONTEXT (decl); | |
1954 | dump_type (cname, 0); | |
1955 | OB_PUTC2 (':', ':'); | |
1956 | } | |
1957 | ||
1958 | if (TREE_CODE (decl) == FUNCTION_DECL) | |
1959 | dump_function_name (decl); | |
1960 | else | |
1961 | dump_decl (DECL_NAME (decl), 0); | |
1962 | ||
1963 | OB_FINISH (); | |
1964 | ||
1965 | return (char *)obstack_base (&scratch_obstack); | |
1966 | } | |
1967 | ||
1968 | ||
8d08fdba MS |
1969 | char * |
1970 | cp_file_of (t) | |
1971 | tree t; | |
1972 | { | |
741f2839 | 1973 | if (TREE_CODE (t) == PARM_DECL && DECL_CONTEXT (t)) |
8d08fdba MS |
1974 | return DECL_SOURCE_FILE (DECL_CONTEXT (t)); |
1975 | else if (TREE_CODE_CLASS (TREE_CODE (t)) == 't') | |
d2e5ee5c | 1976 | return DECL_SOURCE_FILE (TYPE_MAIN_DECL (t)); |
8f032717 MM |
1977 | else if (TREE_CODE (t) == OVERLOAD) |
1978 | return DECL_SOURCE_FILE (OVL_FUNCTION (t)); | |
8d08fdba MS |
1979 | else |
1980 | return DECL_SOURCE_FILE (t); | |
1981 | } | |
1982 | ||
1983 | int | |
1984 | cp_line_of (t) | |
1985 | tree t; | |
1986 | { | |
f376e137 | 1987 | int line = 0; |
741f2839 | 1988 | if (TREE_CODE (t) == PARM_DECL && DECL_CONTEXT (t)) |
f376e137 | 1989 | line = DECL_SOURCE_LINE (DECL_CONTEXT (t)); |
f3400fe2 JM |
1990 | if (TREE_CODE (t) == TYPE_DECL && DECL_ARTIFICIAL (t) |
1991 | && TYPE_MAIN_DECL (TREE_TYPE (t))) | |
f376e137 MS |
1992 | t = TREE_TYPE (t); |
1993 | ||
1994 | if (TREE_CODE_CLASS (TREE_CODE (t)) == 't') | |
d2e5ee5c | 1995 | line = DECL_SOURCE_LINE (TYPE_MAIN_DECL (t)); |
8f032717 MM |
1996 | else if (TREE_CODE (t) == OVERLOAD) |
1997 | line = DECL_SOURCE_LINE (OVL_FUNCTION (t)); | |
8d08fdba | 1998 | else |
f376e137 MS |
1999 | line = DECL_SOURCE_LINE (t); |
2000 | ||
2001 | if (line == 0) | |
2002 | return lineno; | |
2003 | ||
2004 | return line; | |
8d08fdba MS |
2005 | } |
2006 | ||
2007 | char * | |
2008 | code_as_string (c, v) | |
2009 | enum tree_code c; | |
7dee3f36 | 2010 | int v ATTRIBUTE_UNUSED; |
8d08fdba MS |
2011 | { |
2012 | return tree_code_name [c]; | |
2013 | } | |
2014 | ||
2015 | char * | |
2016 | language_as_string (c, v) | |
2017 | enum languages c; | |
7dee3f36 | 2018 | int v ATTRIBUTE_UNUSED; |
8d08fdba MS |
2019 | { |
2020 | switch (c) | |
2021 | { | |
2022 | case lang_c: | |
2023 | return "C"; | |
2024 | ||
2025 | case lang_cplusplus: | |
2026 | return "C++"; | |
2027 | ||
31b72b87 PB |
2028 | case lang_java: |
2029 | return "Java"; | |
2030 | ||
8d08fdba MS |
2031 | default: |
2032 | my_friendly_abort (355); | |
8926095f | 2033 | return 0; |
8d08fdba MS |
2034 | } |
2035 | } | |
2036 | ||
2037 | /* Return the proper printed version of a parameter to a C++ function. */ | |
e92cc029 | 2038 | |
8d08fdba MS |
2039 | char * |
2040 | parm_as_string (p, v) | |
7dee3f36 KG |
2041 | int p; |
2042 | int v ATTRIBUTE_UNUSED; | |
8d08fdba MS |
2043 | { |
2044 | if (p < 0) | |
2045 | return "`this'"; | |
2046 | ||
2047 | sprintf (digit_buffer, "%d", p+1); | |
2048 | return digit_buffer; | |
2049 | } | |
2050 | ||
2051 | char * | |
2052 | op_as_string (p, v) | |
2053 | enum tree_code p; | |
7dee3f36 | 2054 | int v ATTRIBUTE_UNUSED; |
8d08fdba MS |
2055 | { |
2056 | static char buf[] = "operator "; | |
2057 | ||
2058 | if (p == 0) | |
51c184be | 2059 | return "{unknown}"; |
8d08fdba MS |
2060 | |
2061 | strcpy (buf + 9, opname_tab [p]); | |
2062 | return buf; | |
2063 | } | |
2064 | ||
c91a56d2 MS |
2065 | char * |
2066 | assop_as_string (p, v) | |
2067 | enum tree_code p; | |
7dee3f36 | 2068 | int v ATTRIBUTE_UNUSED; |
c91a56d2 MS |
2069 | { |
2070 | static char buf[] = "operator "; | |
2071 | ||
2072 | if (p == 0) | |
2073 | return "{unknown}"; | |
2074 | ||
2075 | strcpy (buf + 9, assignop_tab [p]); | |
2076 | return buf; | |
2077 | } | |
2078 | ||
8d08fdba MS |
2079 | char * |
2080 | args_as_string (p, v) | |
2081 | tree p; | |
2082 | int v; | |
2083 | { | |
2084 | if (p == NULL_TREE) | |
c73964b2 | 2085 | return ""; |
8d08fdba | 2086 | |
c73964b2 MS |
2087 | if (TREE_CODE_CLASS (TREE_CODE (TREE_VALUE (p))) == 't') |
2088 | return type_as_string (p, v); | |
2089 | ||
2090 | OB_INIT (); | |
2091 | for (; p; p = TREE_CHAIN (p)) | |
2092 | { | |
a6967cc0 JM |
2093 | if (TREE_VALUE (p) == null_node) |
2094 | OB_PUTS ("NULL"); | |
2095 | else | |
2096 | dump_type (error_type (TREE_VALUE (p)), v); | |
c73964b2 MS |
2097 | if (TREE_CHAIN (p)) |
2098 | OB_PUTS (", "); | |
2099 | } | |
2100 | OB_FINISH (); | |
2101 | return (char *)obstack_base (&scratch_obstack); | |
8d08fdba | 2102 | } |
f30432d7 MS |
2103 | |
2104 | char * | |
2105 | cv_as_string (p, v) | |
2106 | tree p; | |
7dee3f36 | 2107 | int v ATTRIBUTE_UNUSED; |
f30432d7 MS |
2108 | { |
2109 | OB_INIT (); | |
2110 | ||
91063b51 | 2111 | dump_qualifiers (p, before); |
f30432d7 MS |
2112 | |
2113 | OB_FINISH (); | |
2114 | ||
2115 | return (char *)obstack_base (&scratch_obstack); | |
2116 | } |