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