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