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