1 /* Call-backs for C++ error reporting.
2 This code is non-reentrant.
3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
4 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
28 #include "diagnostic.h"
30 enum pad { none, before, after };
32 /* These constants can used as bit flags in the process of tree formatting.
34 TFF_PLAIN_IDENTIFER: unqualified part of a name.
35 TFF_NAMESPACE_SCOPE: the complete qualified-id form of a name.
36 TFF_CLASS_SCOPE: if possible, include the class-name part of a
37 qualified-id. This flag may be implied in some circumstances by
39 TFF_SCOPE: the combinaison of the two above.
40 TFF_CHASE_TYPDEF: print the original type-id instead of the typedef-name.
41 TFF_DECL_SPECIFIERS: print decl-specifiers.
42 TFF_CLASS_KEY_OR_ENUM: precede a class-type name (resp. enum name) with
43 a class-key (resp. `enum').
44 TFF_RETURN_TYPE: include function return type.
45 TFF_FUNCTION_DEFAULT_ARGUMENTS: include function default parameter values.
46 TFF_EXCEPTION_SPECIFICATION: show function exception specification.
47 TFF_TEMPLATE_HEADER: show the template<...> hearder in a
49 TFF_TEMPLATE_DEFAULT_ARGUMENTS: show template paramter default values. */
51 #define TFF_PLAIN_IDENTIFIER (0)
52 #define TFF_NAMESPACE_SCOPE (1)
53 #define TFF_CLASS_SCOPE (1 << 1)
54 #define TFF_CHASE_NAMESPACE_ALIAS (1 << 2)
55 #define TFF_CHASE_TYPEDEF (1 << 3)
56 #define TFF_DECL_SPECIFIERS (1 << 4)
57 #define TFF_CLASS_KEY_OR_ENUM (1 << 5)
58 #define TFF_RETURN_TYPE (1 << 6)
59 #define TFF_FUNCTION_DEFAULT_ARGUMENTS (1 << 7)
60 #define TFF_EXCEPTION_SPECIFICATION (1 << 8)
61 #define TFF_TEMPLATE_HEADER (1 << 9)
62 #define TFF_TEMPLATE_DEFAULT_ARGUMENTS (1 << 10)
63 #define TFF_SCOPE (TFF_NAMESPACE_SCOPE | TFF_CLASS_SCOPE)
65 /* This data structure bundles altogether, all the information necessary
66 for pretty-printing a C++ source-level entity represented by a tree. */
72 } tree_formatting_info, *tfi_t;
74 #define tree_being_formatted(TFI) (TFI)->decl
75 #define tree_formatting_flags(TFI) (TFI)->flags
76 #define put_whitespace(TFI) (TFI)->pad
78 #define sorry_for_unsupported_tree(T) \
79 sorry ("`%s' not supported by %s", tree_code_name[(int) TREE_CODE (T)], \
82 #define print_scope_operator(BUFFER) output_add_string (BUFFER, "::")
83 #define print_left_paren(BUFFER) output_add_character (BUFFER, '(')
84 #define print_right_paren(BUFFER) output_add_character (BUFFER, ')')
85 #define print_left_bracket(BUFFER) output_add_character (BUFFER, '[')
86 #define print_right_bracket(BUFFER) output_add_character (BUFFER, ']')
87 #define print_template_argument_list_start(BUFFER) \
88 print_non_consecutive_character (BUFFER, '<')
89 #define print_template_argument_list_end(BUFFER) \
90 print_non_consecutive_character (BUFFER, '>')
91 #define print_whitespace(BUFFER, TFI) \
93 output_add_space (BUFFER); \
94 put_whitespace (TFI) = none; \
96 #define print_tree_identifier(BUFFER, TID) \
97 output_add_string (BUFFER, IDENTIFIER_POINTER (TID))
98 #define print_identifier(BUFFER, ID) output_add_string (BUFFER, ID)
99 #define separate_with_comma(BUFFER) output_add_string (BUFFER, ", ")
101 /* The global buffer where we dump everything. It is there only for
102 transitional purpose. It is expected, in the near future, to be
103 completely removed. */
104 static output_buffer scratch_buffer_rec;
105 static output_buffer *scratch_buffer = &scratch_buffer_rec;
107 # define NEXT_CODE(t) (TREE_CODE (TREE_TYPE (t)))
109 #define reinit_global_formatting_buffer() \
110 output_clear_message_text (scratch_buffer)
112 static const char *args_to_string PARAMS ((tree, int));
113 static const char *assop_to_string PARAMS ((enum tree_code, int));
114 static const char *code_to_string PARAMS ((enum tree_code, int));
115 static const char *cv_to_string PARAMS ((tree, int));
116 static const char *decl_to_string PARAMS ((tree, int));
117 static const char *expr_to_string PARAMS ((tree, int));
118 static const char *fndecl_to_string PARAMS ((tree, int));
119 static const char *op_to_string PARAMS ((enum tree_code, int));
120 static const char *parm_to_string PARAMS ((int, int));
121 static const char *type_to_string PARAMS ((tree, int));
123 static void dump_type PARAMS ((tree, enum tree_string_flags));
124 static void dump_typename PARAMS ((tree, enum tree_string_flags));
125 static void dump_simple_decl PARAMS ((tree, tree, enum tree_string_flags));
126 static void dump_decl PARAMS ((tree, enum tree_string_flags));
127 static void dump_template_decl PARAMS ((tree, enum tree_string_flags));
128 static void dump_function_decl PARAMS ((tree, enum tree_string_flags));
129 static void dump_expr PARAMS ((tree, enum tree_string_flags));
130 static void dump_unary_op PARAMS ((const char *, tree, enum tree_string_flags));
131 static void dump_binary_op PARAMS ((const char *, tree, enum tree_string_flags));
132 static void dump_aggr_type PARAMS ((tree, enum tree_string_flags));
133 static enum pad dump_type_prefix PARAMS ((tree, enum tree_string_flags));
134 static void dump_type_suffix PARAMS ((tree, enum tree_string_flags));
135 static void dump_function_name PARAMS ((tree, enum tree_string_flags));
136 static void dump_expr_list PARAMS ((tree, enum tree_string_flags));
137 static void dump_global_iord PARAMS ((tree));
138 static enum pad dump_qualifiers PARAMS ((tree, enum pad));
139 static void dump_char PARAMS ((int));
140 static void dump_parameters PARAMS ((tree, enum tree_string_flags));
141 static void dump_exception_spec PARAMS ((tree, enum tree_string_flags));
142 static const char *class_key_or_enum PARAMS ((tree));
143 static tree ident_fndecl PARAMS ((tree));
144 static void dump_template_argument PARAMS ((tree, enum tree_string_flags));
145 static void dump_template_argument_list PARAMS ((tree, enum tree_string_flags));
146 static void dump_template_parameter PARAMS ((tree, enum tree_string_flags));
147 static void dump_template_bindings PARAMS ((tree, tree));
148 static void dump_scope PARAMS ((tree, enum tree_string_flags));
149 static void dump_template_parms PARAMS ((tree, int, enum tree_string_flags));
151 static const char *function_category PARAMS ((tree));
152 static void lang_print_error_function PARAMS ((const char *));
153 static void maybe_print_instantiation_context PARAMS ((output_buffer *));
154 static void print_instantiation_full_context PARAMS ((output_buffer *));
155 static void print_instantiation_partial_context PARAMS ((output_buffer *, tree,
157 static void cp_diagnostic_starter PARAMS ((output_buffer *,
158 diagnostic_context *));
159 static void cp_diagnostic_finalizer PARAMS ((output_buffer *,
160 diagnostic_context *));
161 static void cp_print_error_function PARAMS ((output_buffer *,
162 diagnostic_context *));
164 static int cp_tree_printer PARAMS ((output_buffer *));
165 static void print_function_argument_list PARAMS ((output_buffer *, tfi_t));
166 static void print_declaration PARAMS ((output_buffer *, tfi_t));
167 static void print_expression PARAMS ((output_buffer *, tfi_t));
168 static void print_integer PARAMS ((output_buffer *, HOST_WIDE_INT));
169 static void print_function_declaration PARAMS ((output_buffer *, tfi_t));
170 static void print_function_parameter PARAMS ((output_buffer *, int));
171 static void print_type_id PARAMS ((output_buffer *, tfi_t));
172 static void print_cv_qualifier_seq PARAMS ((output_buffer *, tfi_t));
173 static void print_type_specifier_seq PARAMS ((output_buffer *, tfi_t));
174 static void print_simple_type_specifier PARAMS ((output_buffer *, tfi_t));
175 static void print_elaborated_type_specifier PARAMS ((output_buffer *, tfi_t));
176 static void print_rest_of_abstract_declarator PARAMS ((output_buffer *,
178 static void print_parameter_declaration_clause PARAMS ((output_buffer *,
180 static void print_exception_specification PARAMS ((output_buffer *, tfi_t));
181 static void print_nested_name_specifier PARAMS ((output_buffer *, tfi_t));
182 static void print_template_id PARAMS ((output_buffer *, tfi_t));
183 static tree typedef_original_name PARAMS ((tree));
184 static void print_non_consecutive_character PARAMS ((output_buffer *, int));
186 #define A args_to_string
187 #define C code_to_string
188 #define D decl_to_string
189 #define E expr_to_string
190 #define F fndecl_to_string
191 #define L language_to_string
192 #define O op_to_string
193 #define P parm_to_string
194 #define Q assop_to_string
195 #define T type_to_string
196 #define V cv_to_string
198 #define o (cp_printer *) 0
199 cp_printer * cp_printers[256] =
201 /*0 1 2 3 4 5 6 7 8 9 A B C D E F */
202 o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x00 */
203 o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x10 */
204 o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x20 */
205 o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x30 */
206 o, A, o, C, D, E, F, o, o, o, o, o, L, o, o, O, /* 0x40 */
207 P, Q, o, o, T, o, V, o, o, o, o, o, o, o, o, o, /* 0x50 */
208 o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x60 */
209 o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x70 */
226 init_output_buffer (scratch_buffer, /* prefix */NULL, /* line-width */0);
228 print_error_function = lang_print_error_function;
229 lang_diagnostic_starter = cp_diagnostic_starter;
230 lang_diagnostic_finalizer = cp_diagnostic_finalizer;
232 lang_printer = cp_tree_printer;
235 /* Dump a scope, if deemed necessary. */
238 dump_scope (scope, flags)
240 enum tree_string_flags flags;
242 if (scope == NULL_TREE)
245 if (TREE_CODE (scope) == NAMESPACE_DECL)
247 if (scope != global_namespace)
249 dump_decl (scope, (flags & (TS_PEDANTIC_NAME | TS_FUNC_SCOPE | TS_CHASE_TYPEDEFS))
250 | TS_FUNC_NORETURN | TS_DECL_TYPE);
251 print_scope_operator (scratch_buffer);
253 else if (flags & TS_PEDANTIC_NAME)
254 print_scope_operator (scratch_buffer);
256 else if (AGGREGATE_TYPE_P (scope))
258 dump_type (scope, (flags & (TS_PEDANTIC_NAME | TS_FUNC_SCOPE | TS_CHASE_TYPEDEFS))
259 | TS_FUNC_NORETURN | TS_DECL_TYPE);
260 print_scope_operator (scratch_buffer);
262 else if ((flags & (TS_PEDANTIC_NAME | TS_FUNC_SCOPE))
263 && TREE_CODE (scope) == FUNCTION_DECL)
265 dump_function_decl (scope, (flags & (TS_PEDANTIC_NAME | TS_FUNC_SCOPE | TS_CHASE_TYPEDEFS))
266 | TS_FUNC_NORETURN | TS_DECL_TYPE);
267 print_scope_operator (scratch_buffer);
271 /* Dump type qualifiers, providing padding as requested. Return an
272 indication of whether we dumped something. */
275 dump_qualifiers (t, p)
279 static const int masks[] =
280 {TYPE_QUAL_CONST, TYPE_QUAL_VOLATILE, TYPE_QUAL_RESTRICT};
281 static const char *const names[] =
282 {"const", "volatile", "__restrict"};
284 int quals = TYPE_QUALS (t);
285 int do_after = p == after;
289 for (ix = 0; ix != 3; ix++)
290 if (masks[ix] & quals)
293 output_add_space (scratch_buffer);
295 print_identifier (scratch_buffer, names[ix]);
298 output_add_space (scratch_buffer);
305 /* This must be large enough to hold any printed integer or floating-point
307 static char digit_buffer[128];
309 /* Dump the template ARGument under control of FLAGS. */
312 dump_template_argument (arg, flags)
314 enum tree_string_flags flags;
316 if (TYPE_P (arg) || TREE_CODE (arg) == TEMPLATE_DECL)
317 dump_type (arg, flags & ~TS_AGGR_TAGS);
319 dump_expr (arg, (flags | TS_EXPR_PARENS) & ~TS_AGGR_TAGS);
322 /* Dump a template-argument-list ARGS (always a TREE_VEC) under control
326 dump_template_argument_list (args, flags)
328 enum tree_string_flags flags;
330 int n = TREE_VEC_LENGTH (args);
334 for (i = 0; i< n; ++i)
337 separate_with_comma (scratch_buffer);
338 dump_template_argument (TREE_VEC_ELT (args, i), flags);
343 /* Dump a template parameter PARM (a TREE_LIST) under control of FLAGS. */
346 dump_template_parameter (parm, flags)
348 enum tree_string_flags flags;
350 tree p = TREE_VALUE (parm);
351 tree a = TREE_PURPOSE (parm);
353 if (TREE_CODE (p) == TYPE_DECL)
355 if (flags & TS_DECL_TYPE)
357 print_identifier (scratch_buffer, "class");
360 output_add_space (scratch_buffer);
361 print_tree_identifier (scratch_buffer, DECL_NAME (p));
364 else if (DECL_NAME (p))
365 print_tree_identifier (scratch_buffer, DECL_NAME (p));
367 print_identifier (scratch_buffer, "{template default argument error}");
370 dump_decl (p, flags | TS_DECL_TYPE);
372 if ((flags & TS_PARM_DEFAULTS) && a != NULL_TREE)
374 output_add_string (scratch_buffer, " = ");
375 if (TREE_CODE (a) == TYPE_DECL || TREE_CODE (a) == TEMPLATE_DECL)
376 dump_type (a, flags & ~TS_CHASE_TYPEDEFS);
378 dump_expr (a, flags | TS_EXPR_PARENS);
382 /* Dump, under control of FLAGS, a template-parameter-list binding.
383 PARMS is a TREE_LIST of TREE_VEC of TREE_LIST and ARGS is a
387 dump_template_bindings (parms, args)
394 tree p = TREE_VALUE (parms);
395 int lvl = TMPL_PARMS_DEPTH (parms);
399 for (i = 0; i < TREE_VEC_LENGTH (p); ++i)
401 tree arg = NULL_TREE;
403 /* Don't crash if we had an invalid argument list. */
404 if (TMPL_ARGS_DEPTH (args) >= lvl)
406 tree lvl_args = TMPL_ARGS_LEVEL (args, lvl);
407 if (NUM_TMPL_ARGS (lvl_args) > arg_idx)
408 arg = TREE_VEC_ELT (lvl_args, arg_idx);
412 separate_with_comma (scratch_buffer);
413 dump_template_parameter (TREE_VEC_ELT (p, i), TS_PLAIN);
414 output_add_string (scratch_buffer, " = ");
416 dump_template_argument (arg, TS_PLAIN);
418 print_identifier (scratch_buffer, "<missing>");
424 parms = TREE_CHAIN (parms);
428 /* Dump into the obstack a human-readable equivalent of TYPE. FLAGS
429 controls the format. */
434 enum tree_string_flags flags;
439 if (TYPE_PTRMEMFUNC_P (t))
442 switch (TREE_CODE (t))
445 print_identifier (scratch_buffer, "<unknown type>");
449 /* A list of function parms. */
450 dump_parameters (t, flags);
453 case IDENTIFIER_NODE:
454 print_tree_identifier (scratch_buffer, t);
458 dump_type (BINFO_TYPE (t), flags);
464 dump_aggr_type (t, flags);
468 if (flags & TS_CHASE_TYPEDEFS)
470 dump_type (DECL_ORIGINAL_TYPE (t)
471 ? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t), flags);
474 /* else fallthrough */
478 dump_decl (t, flags & ~TS_DECL_TYPE);
482 output_add_string (scratch_buffer, "__complex__ ");
483 dump_type (TREE_TYPE (t), flags);
487 if (!TREE_UNSIGNED (TYPE_MAIN_VARIANT (t)) && TREE_UNSIGNED (t))
488 output_add_string (scratch_buffer, "unsigned ");
489 else if (TREE_UNSIGNED (TYPE_MAIN_VARIANT (t)) && !TREE_UNSIGNED (t))
490 output_add_string (scratch_buffer, "signed ");
498 dump_qualifiers (t, after);
499 type = flags & TS_CHASE_TYPEDEFS ? TYPE_MAIN_VARIANT (t) : t;
500 if (TYPE_NAME (type) && TYPE_IDENTIFIER (type))
501 print_tree_identifier (scratch_buffer, TYPE_IDENTIFIER (type));
503 /* Types like intQI_type_node and friends have no names.
504 These don't come up in user error messages, but it's nice
505 to be able to print them from the debugger. */
506 print_identifier (scratch_buffer, "<anonymous>");
510 case TEMPLATE_TEMPLATE_PARM:
511 /* For parameters inside template signature. */
512 if (TYPE_IDENTIFIER (t))
513 print_tree_identifier (scratch_buffer, TYPE_IDENTIFIER (t));
516 (scratch_buffer, "<anonymous template template parameter>");
519 case BOUND_TEMPLATE_TEMPLATE_PARM:
521 tree args = TYPE_TI_ARGS (t);
522 print_tree_identifier (scratch_buffer, TYPE_IDENTIFIER (t));
523 print_template_argument_list_start (scratch_buffer);
524 dump_template_argument_list (args, flags);
525 print_template_argument_list_end (scratch_buffer);
529 case TEMPLATE_TYPE_PARM:
530 dump_qualifiers (t, after);
531 if (TYPE_IDENTIFIER (t))
532 print_tree_identifier (scratch_buffer, TYPE_IDENTIFIER (t));
535 (scratch_buffer, "<anonymous template type parameter>");
538 /* This is not always necessary for pointers and such, but doing this
539 reduces code size. */
549 dump_type_prefix (t, flags);
550 dump_type_suffix (t, flags);
554 output_add_string (scratch_buffer, "typename ");
555 dump_typename (t, flags);
559 output_add_string (scratch_buffer, "__typeof (");
560 dump_expr (TYPE_FIELDS (t), flags & ~TS_EXPR_PARENS);
561 print_left_paren (scratch_buffer);
565 sorry_for_unsupported_tree (t);
566 /* Fall through to error. */
569 print_identifier (scratch_buffer, "<type error>");
574 /* Dump a TYPENAME_TYPE. We need to notice when the context is itself
578 dump_typename (t, flags)
580 enum tree_string_flags flags;
582 tree ctx = TYPE_CONTEXT (t);
584 if (TREE_CODE (ctx) == TYPENAME_TYPE)
585 dump_typename (ctx, flags);
587 dump_type (ctx, flags & ~TS_AGGR_TAGS);
588 print_scope_operator (scratch_buffer);
589 dump_decl (TYPENAME_TYPE_FULLNAME (t), flags);
592 /* Return the name of the supplied aggregate, or enumeral type. */
595 class_key_or_enum (t)
598 if (TREE_CODE (t) == ENUMERAL_TYPE)
600 else if (TREE_CODE (t) == UNION_TYPE)
602 else if (TYPE_LANG_SPECIFIC (t) && CLASSTYPE_DECLARED_CLASS (t))
608 /* Print out a class declaration T under the control of FLAGS,
609 in the form `class foo'. */
612 dump_aggr_type (t, flags)
614 enum tree_string_flags flags;
617 const char *variety = class_key_or_enum (t);
621 dump_qualifiers (t, after);
623 if (flags & TS_AGGR_TAGS)
625 print_identifier (scratch_buffer, variety);
626 output_add_space (scratch_buffer);
629 if (flags & TS_CHASE_TYPEDEFS)
630 t = TYPE_MAIN_VARIANT (t);
632 name = TYPE_NAME (t);
636 typdef = !DECL_ARTIFICIAL (name);
637 tmplate = !typdef && TREE_CODE (t) != ENUMERAL_TYPE
638 && TYPE_LANG_SPECIFIC (t) && CLASSTYPE_TEMPLATE_INFO (t)
639 && (CLASSTYPE_TEMPLATE_SPECIALIZATION (t)
640 || TREE_CODE (CLASSTYPE_TI_TEMPLATE (t)) != TEMPLATE_DECL
641 || DECL_TEMPLATE_SPECIALIZATION (CLASSTYPE_TI_TEMPLATE (t))
642 || PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t)));
643 dump_scope (CP_DECL_CONTEXT (name), flags | TS_FUNC_SCOPE);
646 /* Because the template names are mangled, we have to locate
647 the most general template, and use that name. */
648 tree tpl = CLASSTYPE_TI_TEMPLATE (t);
650 while (DECL_TEMPLATE_INFO (tpl))
651 tpl = DECL_TI_TEMPLATE (tpl);
654 name = DECL_NAME (name);
657 if (name == 0 || ANON_AGGRNAME_P (name))
659 if (flags & TS_AGGR_TAGS)
660 print_identifier (scratch_buffer, "<anonymous>");
662 output_printf (scratch_buffer, "<anonymous %s>", variety);
665 print_tree_identifier (scratch_buffer, name);
667 dump_template_parms (TYPE_TEMPLATE_INFO (t),
668 !CLASSTYPE_USE_TEMPLATE (t),
669 flags & ~TS_TEMPLATE_PREFIX);
672 /* Dump into the obstack the initial part of the output for a given type.
673 This is necessary when dealing with things like functions returning
676 return type of `int (* fee ())()': pointer -> function -> int. Both
677 pointer (and reference and offset) and function (and member) types must
678 deal with prefix and suffix.
680 Arrays must also do this for DECL nodes, like int a[], and for things like
683 Return indicates how you should pad an object name after this. I.e. you
684 want to pad non-*, non-& cores, but not pad * or & types. */
687 dump_type_prefix (t, flags)
689 enum tree_string_flags flags;
691 enum pad padding = before;
693 if (TYPE_PTRMEMFUNC_P (t))
695 t = TYPE_PTRMEMFUNC_FN_TYPE (t);
699 switch (TREE_CODE (t))
702 padding = dump_type_prefix (TREE_TYPE (t), flags);
704 output_add_space (scratch_buffer);
705 output_add_string (scratch_buffer, "vector");
706 dump_qualifiers (t, before);
713 tree sub = TREE_TYPE (t);
715 padding = dump_type_prefix (sub, flags);
716 /* A tree for a member pointer looks like pointer to offset,
717 so let the OFFSET_TYPE case handle it. */
718 if (!TYPE_PTRMEM_P (t))
721 output_add_space (scratch_buffer);
722 if (TREE_CODE (sub) == ARRAY_TYPE)
723 print_left_paren (scratch_buffer);
725 (scratch_buffer, "&*"[TREE_CODE (t) == POINTER_TYPE]);
726 padding = dump_qualifiers (t, none);
733 padding = dump_type_prefix (TREE_TYPE (t), flags);
734 if (TREE_CODE (t) == OFFSET_TYPE) /* pmfs deal with this in d_t_p */
737 output_add_space (scratch_buffer);
738 dump_type (TYPE_OFFSET_BASETYPE (t), flags);
739 print_scope_operator (scratch_buffer);
741 output_add_character (scratch_buffer, '*');
742 padding = dump_qualifiers (t, none);
745 /* Can only be reached through function pointer -- this would not be
746 correct if FUNCTION_DECLs used it. */
748 padding = dump_type_prefix (TREE_TYPE (t), flags);
750 output_add_space (scratch_buffer);
751 print_left_paren (scratch_buffer);
756 padding = dump_type_prefix (TREE_TYPE (t), flags);
758 output_add_space (scratch_buffer);
759 print_left_paren (scratch_buffer);
761 dump_aggr_type (TYPE_METHOD_BASETYPE (t), flags);
762 print_scope_operator (scratch_buffer);
766 padding = dump_type_prefix (TREE_TYPE (t), flags);
770 case IDENTIFIER_NODE:
775 case TEMPLATE_TYPE_PARM:
776 case TEMPLATE_TEMPLATE_PARM:
777 case BOUND_TEMPLATE_TEMPLATE_PARM:
786 dump_type (t, flags);
791 sorry_for_unsupported_tree (t);
794 print_identifier (scratch_buffer, "<typeprefixerror>");
800 /* Dump the suffix of type T, under control of FLAGS. This is the part
801 which appears after the identifier (or function parms). */
804 dump_type_suffix (t, flags)
806 enum tree_string_flags flags;
808 if (TYPE_PTRMEMFUNC_P (t))
809 t = TYPE_PTRMEMFUNC_FN_TYPE (t);
811 switch (TREE_CODE (t))
817 if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
818 print_right_paren (scratch_buffer);
819 dump_type_suffix (TREE_TYPE (t), flags);
822 /* Can only be reached through function pointer */
827 print_right_paren (scratch_buffer);
828 arg = TYPE_ARG_TYPES (t);
829 if (TREE_CODE (t) == METHOD_TYPE)
830 arg = TREE_CHAIN (arg);
832 /* Function pointers don't have default args. Not in standard C++,
833 anyway; they may in g++, but we'll just pretend otherwise. */
834 dump_parameters (arg, flags & ~TS_PARM_DEFAULTS);
836 if (TREE_CODE (t) == METHOD_TYPE)
838 (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t))), before);
839 dump_type_suffix (TREE_TYPE (t), flags);
840 dump_exception_spec (TYPE_RAISES_EXCEPTIONS (t), flags);
845 print_left_bracket (scratch_buffer);
848 if (host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0))
851 tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0) + 1);
852 else if (TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (t))) == MINUS_EXPR)
853 dump_expr (TREE_OPERAND (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0),
854 flags & ~TS_EXPR_PARENS);
856 dump_expr (fold (cp_build_binary_op
857 (PLUS_EXPR, TYPE_MAX_VALUE (TYPE_DOMAIN (t)),
859 flags & ~TS_EXPR_PARENS);
861 print_right_bracket (scratch_buffer);
862 dump_type_suffix (TREE_TYPE (t), flags);
866 case IDENTIFIER_NODE:
871 case TEMPLATE_TYPE_PARM:
872 case TEMPLATE_TEMPLATE_PARM:
873 case BOUND_TEMPLATE_TEMPLATE_PARM:
885 sorry_for_unsupported_tree (t);
887 /* Don't mark it here, we should have already done in
893 /* Return a function declaration which corresponds to the IDENTIFIER_NODE
900 tree n = lookup_name (t, 0);
905 if (TREE_CODE (n) == FUNCTION_DECL)
907 else if (TREE_CODE (n) == TREE_LIST
908 && TREE_CODE (TREE_VALUE (n)) == FUNCTION_DECL)
909 return TREE_VALUE (n);
911 my_friendly_abort (66);
915 #ifndef NO_DOLLAR_IN_LABEL
916 # define GLOBAL_THING "_GLOBAL_$"
918 # ifndef NO_DOT_IN_LABEL
919 # define GLOBAL_THING "_GLOBAL_."
921 # define GLOBAL_THING "_GLOBAL__"
925 #define GLOBAL_IORD_P(NODE) \
926 ! strncmp (IDENTIFIER_POINTER(NODE), GLOBAL_THING, sizeof (GLOBAL_THING) - 1)
932 const char *name = IDENTIFIER_POINTER (t);
933 const char *p = NULL;
935 if (name [sizeof (GLOBAL_THING) - 1] == 'I')
937 else if (name [sizeof (GLOBAL_THING) - 1] == 'D')
940 my_friendly_abort (352);
942 output_printf (scratch_buffer, "(static %s for %s)", p, input_filename);
946 dump_simple_decl (t, type, flags)
949 enum tree_string_flags flags;
951 if (flags & TS_DECL_TYPE)
953 if (dump_type_prefix (type, flags) != none)
954 output_add_space (scratch_buffer);
956 if (!DECL_INITIAL (t) || TREE_CODE (DECL_INITIAL (t)) != TEMPLATE_PARM_INDEX)
957 dump_scope (CP_DECL_CONTEXT (t), flags);
959 dump_decl (DECL_NAME (t), flags);
961 print_identifier (scratch_buffer, "<anonymous>");
962 if (flags & TS_DECL_TYPE)
963 dump_type_suffix (type, flags);
966 /* Dump a human readable string for the decl T under control of FLAGS. */
971 enum tree_string_flags flags;
976 switch (TREE_CODE (t))
980 /* Don't say 'typedef class A' */
981 if (DECL_ARTIFICIAL (t))
983 if ((flags & TS_DECL_TYPE)
984 && TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TYPE_PARM)
985 /* Say `class T' not just `T'. */
986 output_add_string (scratch_buffer, "class ");
988 dump_type (TREE_TYPE (t), flags);
992 if (flags & TS_DECORATE)
993 output_add_string (scratch_buffer, "typedef ");
994 dump_simple_decl (t, DECL_ORIGINAL_TYPE (t)
995 ? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t),
1000 if (DECL_NAME (t) && VTABLE_NAME_P (DECL_NAME (t)))
1002 output_add_string (scratch_buffer, "vtable for ");
1003 if (TYPE_P (DECL_CONTEXT (t)))
1004 dump_type (DECL_CONTEXT (t), flags);
1006 /* This case can arise with -fno-vtable-thunks. See
1007 expand_upcast_fixups. It's not clear what to print
1009 print_identifier (scratch_buffer, "<unknown type>");
1012 /* else fall through */
1015 dump_simple_decl (t, TREE_TYPE (t), flags);
1019 output_add_string (scratch_buffer, "<return value> ");
1020 dump_simple_decl (t, TREE_TYPE (t), flags);
1023 case NAMESPACE_DECL:
1024 dump_scope (CP_DECL_CONTEXT (t), flags);
1025 if (DECL_NAME (t) == anonymous_namespace_name)
1026 print_identifier (scratch_buffer, "<unnamed>");
1028 print_tree_identifier (scratch_buffer, DECL_NAME (t));
1032 dump_decl (TREE_OPERAND (t, 0), flags & ~TS_DECL_TYPE);
1033 print_scope_operator (scratch_buffer);
1034 dump_decl (TREE_OPERAND (t, 1), flags);
1038 dump_decl (TREE_OPERAND (t, 0), flags);
1039 print_left_bracket (scratch_buffer);
1040 dump_decl (TREE_OPERAND (t, 1), flags);
1041 print_right_bracket (scratch_buffer);
1044 /* So that we can do dump_decl on an aggr type. */
1048 dump_type (t, flags);
1052 my_friendly_abort (69);
1055 /* These special cases are duplicated here so that other functions
1056 can feed identifiers to cp_error and get them demangled properly. */
1057 case IDENTIFIER_NODE:
1059 if (DESTRUCTOR_NAME_P (t)
1060 && (f = ident_fndecl (t))
1061 && DECL_LANGUAGE (f) == lang_cplusplus)
1063 output_add_character (scratch_buffer, '~');
1064 dump_decl (DECL_NAME (f), flags);
1066 else if (IDENTIFIER_TYPENAME_P (t))
1068 output_add_string (scratch_buffer, "operator ");
1069 /* Not exactly IDENTIFIER_TYPE_VALUE. */
1070 dump_type (TREE_TYPE (t), flags);
1074 print_tree_identifier (scratch_buffer, t);
1079 t = OVL_CURRENT (t);
1083 if (GLOBAL_IORD_P (DECL_ASSEMBLER_NAME (t)))
1084 dump_global_iord (DECL_ASSEMBLER_NAME (t));
1085 else if (! DECL_LANG_SPECIFIC (t))
1086 print_identifier (scratch_buffer, "<internal>");
1087 else if (flags & TS_PEDANTIC_NAME)
1088 dump_function_decl (t, flags | TS_FUNC_NORETURN | TS_DECL_TYPE);
1090 dump_function_decl (t, flags);
1094 if (flags & TS_PEDANTIC_NAME)
1095 dump_template_decl (t, flags | TS_FUNC_NORETURN | TS_DECL_TYPE);
1097 dump_template_decl (t, flags);
1100 case TEMPLATE_ID_EXPR:
1103 tree name = TREE_OPERAND (t, 0);
1104 if (is_overloaded_fn (name))
1105 name = DECL_NAME (get_first_fn (name));
1106 dump_decl (name, flags);
1107 print_template_argument_list_start (scratch_buffer);
1108 for (args = TREE_OPERAND (t, 1); args; args = TREE_CHAIN (args))
1110 dump_template_argument (TREE_VALUE (args), flags);
1111 if (TREE_CHAIN (args))
1112 separate_with_comma (scratch_buffer);
1114 print_template_argument_list_end (scratch_buffer);
1119 dump_decl (TREE_OPERAND (t, 0), flags);
1123 print_tree_identifier (scratch_buffer, DECL_NAME (t));
1127 if ((TREE_TYPE (t) != NULL_TREE && NEXT_CODE (t) == ENUMERAL_TYPE)
1128 || (DECL_INITIAL (t) &&
1129 TREE_CODE (DECL_INITIAL (t)) == TEMPLATE_PARM_INDEX))
1130 dump_simple_decl (t, TREE_TYPE (t), flags);
1131 else if (DECL_NAME (t))
1132 dump_decl (DECL_NAME (t), flags);
1133 else if (DECL_INITIAL (t))
1134 dump_expr (DECL_INITIAL (t), flags | TS_EXPR_PARENS);
1136 print_identifier (scratch_buffer, "enumerator");
1140 output_add_string (scratch_buffer, "using ");
1141 dump_type (DECL_INITIAL (t), flags);
1142 print_scope_operator (scratch_buffer);
1143 print_tree_identifier (scratch_buffer, DECL_NAME (t));
1147 sorry_for_unsupported_tree (t);
1148 /* Fallthrough to error. */
1151 print_identifier (scratch_buffer, "<declaration error>");
1156 /* Dump a template declaration T under control of FLAGS. This means the
1157 'template <...> leaders plus the 'class X' or 'void fn(...)' part. */
1160 dump_template_decl (t, flags)
1162 enum tree_string_flags flags;
1164 tree orig_parms = DECL_TEMPLATE_PARMS (t);
1168 if (flags & TS_TEMPLATE_PREFIX)
1170 for (parms = orig_parms = nreverse (orig_parms);
1172 parms = TREE_CHAIN (parms))
1174 tree inner_parms = INNERMOST_TEMPLATE_PARMS (parms);
1175 int len = TREE_VEC_LENGTH (inner_parms);
1177 output_add_string (scratch_buffer, "template<");
1178 for (i = 0; i < len; i++)
1181 separate_with_comma (scratch_buffer);
1182 dump_template_parameter (TREE_VEC_ELT (inner_parms, i), flags);
1184 print_template_argument_list_end (scratch_buffer);
1185 separate_with_comma (scratch_buffer);
1187 nreverse(orig_parms);
1188 /* If we've shown the template<args> prefix, we'd better show the
1190 flags |= TS_DECL_TYPE;
1192 if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == TYPE_DECL)
1193 dump_type (TREE_TYPE (t),
1194 ((flags & ~TS_AGGR_TAGS) | TS_TEMPLATE_PLAIN
1195 | (flags & TS_DECL_TYPE ? TS_AGGR_TAGS : 0)));
1196 else if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == VAR_DECL)
1197 dump_decl (DECL_TEMPLATE_RESULT (t), flags | TS_TEMPLATE_PLAIN);
1198 else if (TREE_TYPE (t) == NULL_TREE)
1199 my_friendly_abort (353);
1201 switch (NEXT_CODE (t))
1205 dump_function_decl (t, flags | TS_TEMPLATE_PLAIN);
1208 /* This case can occur with some illegal code. */
1209 dump_type (TREE_TYPE (t),
1210 (flags & ~TS_AGGR_TAGS) | TS_TEMPLATE_PLAIN
1211 | (flags & TS_DECL_TYPE ? TS_AGGR_TAGS : 0));
1215 /* Pretty print a function decl. There are several ways we want to print a
1216 function declaration. The TS_FUNC bits in FLAGS tells us how to behave.
1217 As cp_error can only apply the '#' flag once to give 0 and 1 for V, there
1218 is %D which doesn't print the throw specs, and %F which does. */
1221 dump_function_decl (t, flags)
1223 enum tree_string_flags flags;
1227 tree cname = NULL_TREE;
1228 tree template_args = NULL_TREE;
1229 tree template_parms = NULL_TREE;
1230 int show_return = !(flags & TS_FUNC_NORETURN) && (flags & TS_DECL_TYPE);
1232 if (TREE_CODE (t) == TEMPLATE_DECL)
1233 t = DECL_TEMPLATE_RESULT (t);
1235 /* Pretty print template instantiations only. */
1236 if (DECL_USE_TEMPLATE (t) && DECL_TEMPLATE_INFO (t))
1240 template_args = DECL_TI_ARGS (t);
1241 tmpl = most_general_template (t);
1242 if (tmpl && TREE_CODE (tmpl) == TEMPLATE_DECL)
1244 template_parms = DECL_TEMPLATE_PARMS (tmpl);
1249 fntype = TREE_TYPE (t);
1250 parmtypes = TYPE_ARG_TYPES (fntype);
1252 if (DECL_CLASS_SCOPE_P (t))
1253 cname = DECL_CONTEXT (t);
1254 /* this is for partially instantiated template methods */
1255 else if (TREE_CODE (fntype) == METHOD_TYPE)
1256 cname = TREE_TYPE (TREE_VALUE (parmtypes));
1258 if (!(flags & TS_DECORATE))
1260 else if (DECL_STATIC_FUNCTION_P (t))
1261 print_identifier (scratch_buffer, "static ");
1262 else if (TYPE_POLYMORPHIC_P (t))
1263 print_identifier (scratch_buffer, "virtual ");
1265 /* Print the return type? */
1267 show_return = !DECL_CONV_FN_P (t) && !DECL_CONSTRUCTOR_P (t)
1268 && !DECL_DESTRUCTOR_P (t);
1271 if (dump_type_prefix (TREE_TYPE (fntype), flags) != none)
1272 output_add_space (scratch_buffer);
1275 /* Print the function name. */
1278 dump_type (cname, flags);
1279 print_scope_operator (scratch_buffer);
1282 dump_scope (CP_DECL_CONTEXT (t), flags);
1284 dump_function_name (t, flags);
1286 if (!(flags & TS_DECL_TYPE))
1288 if (TREE_CODE (fntype) == METHOD_TYPE && parmtypes)
1289 /* Skip "this" parameter. */
1290 parmtypes = TREE_CHAIN (parmtypes);
1292 /* Skip past the "in_charge" parameter. */
1293 if (DECL_HAS_IN_CHARGE_PARM_P (t))
1294 parmtypes = TREE_CHAIN (parmtypes);
1296 dump_parameters (parmtypes, flags);
1299 dump_type_suffix (TREE_TYPE (fntype), flags);
1301 if (TREE_CODE (fntype) == METHOD_TYPE)
1302 dump_qualifiers (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype))),
1305 if (flags & TS_FUNC_THROW)
1306 dump_exception_spec (TYPE_RAISES_EXCEPTIONS (fntype), flags);
1308 /* If T is a template instantiation, dump the parameter binding. */
1309 if (template_parms != NULL_TREE && template_args != NULL_TREE)
1311 output_add_string (scratch_buffer, " [with ");
1312 dump_template_bindings (template_parms, template_args);
1313 print_right_bracket (scratch_buffer);
1317 /* Print a parameter list. If this is for a member function, the
1318 member object ptr (and any other hidden args) should have
1319 already been removed. */
1322 dump_parameters (parmtypes, flags)
1324 enum tree_string_flags flags;
1328 print_left_paren (scratch_buffer);
1330 for (first = 1; parmtypes != void_list_node;
1331 parmtypes = TREE_CHAIN (parmtypes))
1334 separate_with_comma (scratch_buffer);
1338 print_identifier (scratch_buffer, "...");
1341 dump_type (TREE_VALUE (parmtypes), flags);
1343 if ((flags & TS_PARM_DEFAULTS) && TREE_PURPOSE (parmtypes))
1345 output_add_string (scratch_buffer, " = ");
1346 dump_expr (TREE_PURPOSE (parmtypes), flags | TS_EXPR_PARENS);
1350 print_right_paren (scratch_buffer);
1353 /* Print an exception specification. T is the exception specification. */
1356 dump_exception_spec (t, flags)
1358 enum tree_string_flags flags;
1362 output_add_string (scratch_buffer, " throw (");
1363 if (TREE_VALUE (t) != NULL_TREE)
1366 dump_type (TREE_VALUE (t), flags);
1370 separate_with_comma (scratch_buffer);
1372 print_right_paren (scratch_buffer);
1376 /* Handle the function name for a FUNCTION_DECL node, grokking operators
1377 and destructors properly. */
1380 dump_function_name (t, flags)
1382 enum tree_string_flags flags;
1384 tree name = DECL_NAME (t);
1386 if (DECL_DESTRUCTOR_P (t))
1388 output_add_character (scratch_buffer, '~');
1389 dump_decl (name, TS_PLAIN);
1391 else if (DECL_CONV_FN_P (t))
1393 /* This cannot use the hack that the operator's return
1394 type is stashed off of its name because it may be
1395 used for error reporting. In the case of conflicting
1396 declarations, both will have the same name, yet
1397 the types will be different, hence the TREE_TYPE field
1398 of the first name will be clobbered by the second. */
1399 output_add_string (scratch_buffer, "operator ");
1400 dump_type (TREE_TYPE (TREE_TYPE (t)), flags);
1402 else if (IDENTIFIER_OPNAME_P (name))
1403 print_tree_identifier (scratch_buffer, name);
1405 dump_decl (name, flags);
1407 if (DECL_LANG_SPECIFIC (t) && DECL_TEMPLATE_INFO (t)
1408 && !DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t)
1409 && (DECL_TEMPLATE_SPECIALIZATION (t)
1410 || TREE_CODE (DECL_TI_TEMPLATE (t)) != TEMPLATE_DECL
1411 || DECL_TEMPLATE_SPECIALIZATION (DECL_TI_TEMPLATE (t))
1412 || PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t))))
1413 dump_template_parms (DECL_TEMPLATE_INFO (t), !DECL_USE_TEMPLATE (t), flags);
1416 /* Dump the template parameters from the template info INFO under control of
1417 FLAGS. PRIMARY indicates whether this is a primary template decl, or
1418 specialization (partial or complete). For partial specializations we show
1419 the specialized parameter values. For a primary template we show no
1423 dump_template_parms (info, primary, flags)
1426 enum tree_string_flags flags;
1428 tree args = info ? TI_ARGS (info) : NULL_TREE;
1430 if (primary && flags & TS_TEMPLATE_PLAIN)
1432 flags &= ~(TS_AGGR_TAGS | TS_TEMPLATE_PLAIN);
1433 print_template_argument_list_start (scratch_buffer);
1435 /* Be careful only to print things when we have them, so as not
1436 to crash producing error messages. */
1437 if (args && !primary)
1443 if (TREE_CODE (args) == TREE_VEC)
1445 if (TREE_VEC_LENGTH (args) > 0
1446 && TREE_CODE (TREE_VEC_ELT (args, 0)) == TREE_VEC)
1447 args = TREE_VEC_ELT (args, TREE_VEC_LENGTH (args) - 1);
1449 len = TREE_VEC_LENGTH (args);
1451 else if (TREE_CODE (args) == TREE_LIST)
1453 while (ix != len && args)
1458 arg = TREE_VEC_ELT (args, ix);
1463 arg = TREE_VALUE (args);
1464 args = TREE_CHAIN (args);
1467 separate_with_comma (scratch_buffer);
1470 print_identifier (scratch_buffer, "<template parameter error>");
1472 dump_template_argument (arg, flags);
1478 tree tpl = TI_TEMPLATE (info);
1479 tree parms = DECL_TEMPLATE_PARMS (tpl);
1482 parms = TREE_CODE (parms) == TREE_LIST ? TREE_VALUE (parms) : NULL_TREE;
1483 len = parms ? TREE_VEC_LENGTH (parms) : 0;
1485 for (ix = 0; ix != len; ix++)
1487 tree parm = TREE_VALUE (TREE_VEC_ELT (parms, ix));
1490 separate_with_comma (scratch_buffer);
1492 dump_decl (parm, flags & ~TS_DECL_TYPE);
1495 print_template_argument_list_end (scratch_buffer);
1504 case TARGET_NEWLINE:
1505 output_add_string (scratch_buffer, "\\n");
1508 output_add_string (scratch_buffer, "\\t");
1511 output_add_string (scratch_buffer, "\\v");
1514 output_add_string (scratch_buffer, "\\b");
1517 output_add_string (scratch_buffer, "\\r");
1520 output_add_string (scratch_buffer, "\\f");
1523 output_add_string (scratch_buffer, "\\a");
1526 output_add_string (scratch_buffer, "\\\\");
1529 output_add_string (scratch_buffer, "\\'");
1532 output_add_string (scratch_buffer, "\\\"");
1536 output_add_character (scratch_buffer, c);
1539 sprintf (digit_buffer, "\\%03o", (int) c);
1540 output_add_string (scratch_buffer, digit_buffer);
1545 /* Print out a list of initializers (subr of dump_expr) */
1548 dump_expr_list (l, flags)
1550 enum tree_string_flags flags;
1554 dump_expr (TREE_VALUE (l), flags | TS_EXPR_PARENS);
1557 separate_with_comma (scratch_buffer);
1561 /* Print out an expression E under control of FLAGS. */
1564 dump_expr (t, flags)
1566 enum tree_string_flags flags;
1568 switch (TREE_CODE (t))
1576 case NAMESPACE_DECL:
1578 dump_decl (t, flags & ~TS_DECL_TYPE);
1583 tree type = TREE_TYPE (t);
1584 my_friendly_assert (type != 0, 81);
1586 /* If it's an enum, output its tag, rather than its value. */
1587 if (TREE_CODE (type) == ENUMERAL_TYPE)
1589 tree values = TYPE_VALUES (type);
1592 values = TREE_CHAIN (values))
1593 if (tree_int_cst_equal (TREE_VALUE (values), t))
1597 print_tree_identifier (scratch_buffer, TREE_PURPOSE (values));
1600 /* Value must have been cast. */
1601 print_left_paren (scratch_buffer);
1602 dump_type (type, flags);
1603 print_right_paren (scratch_buffer);
1607 else if (type == boolean_type_node)
1609 if (t == boolean_false_node || integer_zerop (t))
1610 print_identifier (scratch_buffer, "false");
1611 else if (t == boolean_true_node)
1612 print_identifier (scratch_buffer, "true");
1614 else if (type == char_type_node)
1616 output_add_character (scratch_buffer, '\'');
1617 dump_char (tree_low_cst (t, 0));
1618 output_add_character (scratch_buffer, '\'');
1623 if (! host_integerp (t, 0))
1627 if (tree_int_cst_sgn (val) < 0)
1629 output_add_character (scratch_buffer, '-');
1630 val = build_int_2 (-TREE_INT_CST_LOW (val),
1631 ~TREE_INT_CST_HIGH (val)
1632 + !TREE_INT_CST_LOW (val));
1634 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
1637 static char format[10]; /* "%x%09999x\0" */
1639 sprintf (format, "%%x%%0%dx", HOST_BITS_PER_INT / 4);
1640 sprintf (digit_buffer, format, TREE_INT_CST_HIGH (val),
1641 TREE_INT_CST_LOW (val));
1642 output_add_string (scratch_buffer, digit_buffer);
1646 print_integer (scratch_buffer, TREE_INT_CST_LOW (t));
1652 #ifndef REAL_IS_NOT_DOUBLE
1653 sprintf (digit_buffer, "%g", TREE_REAL_CST (t));
1656 const unsigned char *p = (const unsigned char *) &TREE_REAL_CST (t);
1658 strcpy (digit_buffer, "0x");
1659 for (i = 0; i < sizeof TREE_REAL_CST (t); i++)
1660 sprintf (digit_buffer + 2 + 2*i, "%02x", *p++);
1663 output_add_string (scratch_buffer, digit_buffer);
1667 output_add_character (scratch_buffer, '&');
1668 dump_type (PTRMEM_CST_CLASS (t), flags);
1669 print_scope_operator (scratch_buffer);
1670 print_tree_identifier
1671 (scratch_buffer, DECL_NAME (PTRMEM_CST_MEMBER (t)));
1676 const char *p = TREE_STRING_POINTER (t);
1677 int len = TREE_STRING_LENGTH (t) - 1;
1680 output_add_character (scratch_buffer, '\"');
1681 for (i = 0; i < len; i++)
1683 output_add_character (scratch_buffer, '\"');
1688 print_left_paren (scratch_buffer);
1689 dump_expr (TREE_OPERAND (t, 0), flags | TS_EXPR_PARENS);
1690 separate_with_comma (scratch_buffer);
1691 dump_expr (TREE_OPERAND (t, 1), flags | TS_EXPR_PARENS);
1692 print_right_paren (scratch_buffer);
1696 print_left_paren (scratch_buffer);
1697 dump_expr (TREE_OPERAND (t, 0), flags | TS_EXPR_PARENS);
1698 output_add_string (scratch_buffer, " ? ");
1699 dump_expr (TREE_OPERAND (t, 1), flags | TS_EXPR_PARENS);
1700 output_add_string (scratch_buffer, " : ");
1701 dump_expr (TREE_OPERAND (t, 2), flags | TS_EXPR_PARENS);
1702 print_right_paren (scratch_buffer);
1706 if (TREE_HAS_CONSTRUCTOR (t))
1708 output_add_string (scratch_buffer, "new ");
1709 dump_type (TREE_TYPE (TREE_TYPE (t)), flags);
1713 dump_expr (TREE_OPERAND (t, 0), flags | TS_EXPR_PARENS);
1717 case AGGR_INIT_EXPR:
1719 tree fn = NULL_TREE;
1721 if (TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR)
1722 fn = TREE_OPERAND (TREE_OPERAND (t, 0), 0);
1724 if (fn && TREE_CODE (fn) == FUNCTION_DECL)
1726 if (DECL_CONSTRUCTOR_P (fn))
1727 print_tree_identifier
1728 (scratch_buffer, TYPE_IDENTIFIER (TREE_TYPE (t)));
1733 dump_expr (TREE_OPERAND (t, 0), 0);
1735 print_left_paren (scratch_buffer);
1736 if (TREE_OPERAND (t, 1))
1737 dump_expr_list (TREE_CHAIN (TREE_OPERAND (t, 1)), flags);
1738 print_right_paren (scratch_buffer);
1743 tree fn = TREE_OPERAND (t, 0);
1744 tree args = TREE_OPERAND (t, 1);
1746 if (TREE_CODE (fn) == ADDR_EXPR)
1747 fn = TREE_OPERAND (fn, 0);
1749 if (TREE_TYPE (fn) != NULL_TREE && NEXT_CODE (fn) == METHOD_TYPE)
1751 tree ob = TREE_VALUE (args);
1752 if (TREE_CODE (ob) == ADDR_EXPR)
1754 dump_expr (TREE_OPERAND (ob, 0), flags | TS_EXPR_PARENS);
1755 output_add_character (scratch_buffer, '.');
1757 else if (TREE_CODE (ob) != PARM_DECL
1758 || strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this"))
1760 dump_expr (ob, flags | TS_EXPR_PARENS);
1761 output_add_string (scratch_buffer, "->");
1763 args = TREE_CHAIN (args);
1765 dump_expr (fn, flags | TS_EXPR_PARENS);
1766 print_left_paren (scratch_buffer);
1767 dump_expr_list (args, flags);
1768 print_right_paren (scratch_buffer);
1774 tree type = TREE_OPERAND (t, 1);
1775 if (NEW_EXPR_USE_GLOBAL (t))
1776 print_scope_operator (scratch_buffer);
1777 output_add_string (scratch_buffer, "new ");
1778 if (TREE_OPERAND (t, 0))
1780 print_left_paren (scratch_buffer);
1781 dump_expr_list (TREE_OPERAND (t, 0), flags);
1782 output_add_string (scratch_buffer, ") ");
1784 if (TREE_CODE (type) == ARRAY_REF)
1785 type = build_cplus_array_type
1786 (TREE_OPERAND (type, 0),
1787 build_index_type (fold (build (MINUS_EXPR, integer_type_node,
1788 TREE_OPERAND (type, 1),
1789 integer_one_node))));
1790 dump_type (type, flags);
1791 if (TREE_OPERAND (t, 2))
1793 print_left_paren (scratch_buffer);
1794 dump_expr_list (TREE_OPERAND (t, 2), flags);
1795 print_right_paren (scratch_buffer);
1801 /* Note that this only works for G++ target exprs. If somebody
1802 builds a general TARGET_EXPR, there's no way to represent that
1803 it initializes anything other that the parameter slot for the
1804 default argument. Note we may have cleared out the first
1805 operand in expand_expr, so don't go killing ourselves. */
1806 if (TREE_OPERAND (t, 1))
1807 dump_expr (TREE_OPERAND (t, 1), flags | TS_EXPR_PARENS);
1815 case TRUNC_DIV_EXPR:
1816 case TRUNC_MOD_EXPR:
1824 case BIT_ANDTC_EXPR:
1825 case TRUTH_ANDIF_EXPR:
1826 case TRUTH_ORIF_EXPR:
1833 case EXACT_DIV_EXPR:
1834 dump_binary_op (operator_name_info[(int) TREE_CODE (t)].name, t, flags);
1838 case FLOOR_DIV_EXPR:
1839 case ROUND_DIV_EXPR:
1840 dump_binary_op ("/", t, flags);
1844 case FLOOR_MOD_EXPR:
1845 case ROUND_MOD_EXPR:
1846 dump_binary_op ("%", t, flags);
1851 tree ob = TREE_OPERAND (t, 0);
1852 if (TREE_CODE (ob) == INDIRECT_REF)
1854 ob = TREE_OPERAND (ob, 0);
1855 if (TREE_CODE (ob) != PARM_DECL
1856 || strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this"))
1858 dump_expr (ob, flags | TS_EXPR_PARENS);
1859 output_add_string (scratch_buffer, "->");
1864 dump_expr (ob, flags | TS_EXPR_PARENS);
1865 output_add_character (scratch_buffer, '.');
1867 dump_expr (TREE_OPERAND (t, 1), flags & ~TS_EXPR_PARENS);
1872 dump_expr (TREE_OPERAND (t, 0), flags | TS_EXPR_PARENS);
1873 print_left_bracket (scratch_buffer);
1874 dump_expr (TREE_OPERAND (t, 1), flags | TS_EXPR_PARENS);
1875 print_right_bracket (scratch_buffer);
1879 if (VOID_TYPE_P (TREE_TYPE (t)))
1881 print_left_paren (scratch_buffer);
1882 dump_type (TREE_TYPE (t), flags);
1883 print_right_paren (scratch_buffer);
1884 dump_expr (TREE_OPERAND (t, 0), flags);
1887 dump_unary_op ("+", t, flags);
1891 if (TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL
1892 || TREE_CODE (TREE_OPERAND (t, 0)) == STRING_CST
1893 /* An ADDR_EXPR can have reference type. In that case, we
1894 shouldn't print the `&' doing so indicates to the user
1895 that the expression has pointer type. */
1897 && TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE))
1898 dump_expr (TREE_OPERAND (t, 0), flags | TS_EXPR_PARENS);
1900 dump_unary_op ("&", t, flags);
1904 if (TREE_HAS_CONSTRUCTOR (t))
1906 t = TREE_OPERAND (t, 0);
1907 my_friendly_assert (TREE_CODE (t) == CALL_EXPR, 237);
1908 dump_expr (TREE_OPERAND (t, 0), flags | TS_EXPR_PARENS);
1909 print_left_paren (scratch_buffer);
1910 dump_expr_list (TREE_CHAIN (TREE_OPERAND (t, 1)), flags);
1911 print_right_paren (scratch_buffer);
1915 if (TREE_OPERAND (t,0) != NULL_TREE
1916 && TREE_TYPE (TREE_OPERAND (t, 0))
1917 && NEXT_CODE (TREE_OPERAND (t, 0)) == REFERENCE_TYPE)
1918 dump_expr (TREE_OPERAND (t, 0), flags);
1920 dump_unary_op ("*", t, flags);
1926 case TRUTH_NOT_EXPR:
1927 case PREDECREMENT_EXPR:
1928 case PREINCREMENT_EXPR:
1929 dump_unary_op (operator_name_info [(int)TREE_CODE (t)].name, t, flags);
1932 case POSTDECREMENT_EXPR:
1933 case POSTINCREMENT_EXPR:
1934 print_left_paren (scratch_buffer);
1935 dump_expr (TREE_OPERAND (t, 0), flags | TS_EXPR_PARENS);
1937 (scratch_buffer, operator_name_info[(int)TREE_CODE (t)].name);
1938 print_right_paren (scratch_buffer);
1941 case NON_LVALUE_EXPR:
1942 /* FIXME: This is a KLUDGE workaround for a parsing problem. There
1943 should be another level of INDIRECT_REF so that I don't have to do
1945 if (TREE_TYPE (t) != NULL_TREE && NEXT_CODE (t) == POINTER_TYPE)
1947 tree next = TREE_TYPE (TREE_TYPE (t));
1949 while (TREE_CODE (next) == POINTER_TYPE)
1950 next = TREE_TYPE (next);
1952 if (TREE_CODE (next) == FUNCTION_TYPE)
1954 if (flags & TS_EXPR_PARENS)
1955 print_left_paren (scratch_buffer);
1956 output_add_character (scratch_buffer, '*');
1957 dump_expr (TREE_OPERAND (t, 0), flags & ~TS_EXPR_PARENS);
1958 if (flags & TS_EXPR_PARENS)
1959 print_right_paren (scratch_buffer);
1964 dump_expr (TREE_OPERAND (t, 0), flags | TS_EXPR_PARENS);
1968 dump_expr (TREE_OPERAND (t, 0), flags);
1971 case EXPR_WITH_FILE_LOCATION:
1972 dump_expr (EXPR_WFL_NODE (t), flags);
1976 if (TREE_TYPE (t) && TYPE_PTRMEMFUNC_P (TREE_TYPE (t)))
1978 tree idx = build_component_ref (t, index_identifier, NULL_TREE, 0);
1980 if (integer_all_onesp (idx))
1982 tree pfn = PFN_FROM_PTRMEMFUNC (t);
1983 dump_unary_op ("&", pfn, flags | TS_EXPR_PARENS);
1986 else if (TREE_CODE (idx) == INTEGER_CST
1987 && tree_int_cst_equal (idx, integer_zero_node))
1989 /* A NULL pointer-to-member constant. */
1990 output_add_string (scratch_buffer, "((");
1991 dump_type (TREE_TYPE (t), flags);
1992 output_add_string (scratch_buffer, ") 0)");
1995 else if (host_integerp (idx, 0))
1998 unsigned HOST_WIDE_INT n;
2000 t = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (t)));
2001 t = TYPE_METHOD_BASETYPE (t);
2002 virtuals = TYPE_BINFO_VIRTUALS (TYPE_MAIN_VARIANT (t));
2004 n = tree_low_cst (idx, 0) - first_vfun_index (t);
2006 /* Map vtable index back one, to allow for the null pointer to
2010 while (n > 0 && virtuals)
2013 virtuals = TREE_CHAIN (virtuals);
2017 dump_expr (BV_FN (virtuals),
2018 flags | TS_EXPR_PARENS);
2023 output_add_character (scratch_buffer, '{');
2024 dump_expr_list (CONSTRUCTOR_ELTS (t), flags);
2025 output_add_character (scratch_buffer, '}');
2030 tree ob = TREE_OPERAND (t, 0);
2031 if (is_dummy_object (ob))
2033 t = TREE_OPERAND (t, 1);
2034 if (TREE_CODE (t) == FUNCTION_DECL)
2036 dump_expr (t, flags | TS_EXPR_PARENS);
2037 else if (BASELINK_P (t))
2038 dump_expr (OVL_CURRENT (TREE_VALUE (t)), flags | TS_EXPR_PARENS);
2040 dump_decl (t, flags);
2044 if (TREE_CODE (ob) == INDIRECT_REF)
2046 dump_expr (TREE_OPERAND (ob, 0), flags | TS_EXPR_PARENS);
2047 output_add_string (scratch_buffer, "->*");
2051 dump_expr (ob, flags | TS_EXPR_PARENS);
2052 output_add_string (scratch_buffer, ".*");
2054 dump_expr (TREE_OPERAND (t, 1), flags | TS_EXPR_PARENS);
2059 case TEMPLATE_PARM_INDEX:
2060 dump_decl (TEMPLATE_PARM_DECL (t), flags & ~TS_DECL_TYPE);
2063 case IDENTIFIER_NODE:
2064 print_tree_identifier (scratch_buffer, t);
2068 dump_type (TREE_OPERAND (t, 0), flags);
2069 print_scope_operator (scratch_buffer);
2070 dump_expr (TREE_OPERAND (t, 1), flags | TS_EXPR_PARENS);
2074 if (TREE_OPERAND (t, 0) == NULL_TREE
2075 || TREE_CHAIN (TREE_OPERAND (t, 0)))
2077 dump_type (TREE_TYPE (t), flags);
2078 print_left_paren (scratch_buffer);
2079 dump_expr_list (TREE_OPERAND (t, 0), flags);
2080 print_right_paren (scratch_buffer);
2084 print_left_paren (scratch_buffer);
2085 dump_type (TREE_TYPE (t), flags);
2086 output_add_string (scratch_buffer, ")(");
2087 dump_expr_list (TREE_OPERAND (t, 0), flags);
2088 print_right_paren (scratch_buffer);
2093 print_tree_identifier (scratch_buffer, TREE_OPERAND (t, 0));
2097 dump_expr (TREE_OPERAND (t, 0), flags);
2098 output_add_string (scratch_buffer, "->");
2103 if (TREE_CODE (t) == SIZEOF_EXPR)
2104 output_add_string (scratch_buffer, "sizeof (");
2107 my_friendly_assert (TREE_CODE (t) == ALIGNOF_EXPR, 0);
2108 output_add_string (scratch_buffer, "__alignof__ (");
2110 if (TYPE_P (TREE_OPERAND (t, 0)))
2111 dump_type (TREE_OPERAND (t, 0), flags);
2113 dump_unary_op ("*", t, flags | TS_EXPR_PARENS);
2114 print_right_paren (scratch_buffer);
2118 print_identifier (scratch_buffer, "<unparsed>");
2121 case TRY_CATCH_EXPR:
2122 case WITH_CLEANUP_EXPR:
2123 case CLEANUP_POINT_EXPR:
2124 dump_expr (TREE_OPERAND (t, 0), flags);
2127 case PSEUDO_DTOR_EXPR:
2128 dump_expr (TREE_OPERAND (t, 2), flags);
2129 output_add_character (scratch_buffer, '.');
2130 dump_type (TREE_OPERAND (t, 0), flags);
2131 output_add_string (scratch_buffer, "::~");
2132 dump_type (TREE_OPERAND (t, 1), flags);
2135 case TEMPLATE_ID_EXPR:
2136 dump_decl (t, flags);
2140 /* We don't yet have a way of dumping statements in a
2141 human-readable format. */
2142 output_add_string (scratch_buffer, "({...})");
2146 output_add_character (scratch_buffer, '}');
2147 dump_expr (TREE_OPERAND (t, 1), flags & ~TS_EXPR_PARENS);
2148 output_add_character (scratch_buffer, '}');
2152 output_add_string (scratch_buffer, "while (1) { ");
2153 dump_expr (TREE_OPERAND (t, 0), flags & ~TS_EXPR_PARENS);
2154 output_add_character (scratch_buffer, '}');
2158 output_add_string (scratch_buffer, "if (");
2159 dump_expr (TREE_OPERAND (t, 0), flags & ~TS_EXPR_PARENS);
2160 output_add_string (scratch_buffer, ") break; ");
2164 if (TREE_VALUE (t) && TREE_CODE (TREE_VALUE (t)) == FUNCTION_DECL)
2166 print_tree_identifier (scratch_buffer, DECL_NAME (TREE_VALUE (t)));
2169 /* else fall through */
2171 /* This list is incomplete, but should suffice for now.
2172 It is very important that `sorry' does not call
2173 `report_error_function'. That could cause an infinite loop. */
2175 sorry_for_unsupported_tree (t);
2176 /* fall through to ERROR_MARK... */
2178 print_identifier (scratch_buffer, "<expression error>");
2184 dump_binary_op (opstring, t, flags)
2185 const char *opstring;
2187 enum tree_string_flags flags;
2189 print_left_paren (scratch_buffer);
2190 dump_expr (TREE_OPERAND (t, 0), flags | TS_EXPR_PARENS);
2191 output_add_space (scratch_buffer);
2193 print_identifier (scratch_buffer, opstring);
2195 print_identifier (scratch_buffer, "<unknown operator>");
2196 output_add_space (scratch_buffer);
2197 dump_expr (TREE_OPERAND (t, 1), flags | TS_EXPR_PARENS);
2198 print_right_paren (scratch_buffer);
2202 dump_unary_op (opstring, t, flags)
2203 const char *opstring;
2205 enum tree_string_flags flags;
2207 if (flags & TS_EXPR_PARENS)
2208 print_left_paren (scratch_buffer);
2209 print_identifier (scratch_buffer, opstring);
2210 dump_expr (TREE_OPERAND (t, 0), flags & ~TS_EXPR_PARENS);
2211 if (flags & TS_EXPR_PARENS)
2212 print_right_paren (scratch_buffer);
2215 /* Exported interface to stringifying types, exprs and decls under TS_*
2219 type_as_string (typ, flags)
2221 enum tree_string_flags flags;
2223 reinit_global_formatting_buffer ();
2225 dump_type (typ, flags);
2227 return output_finalize_message (scratch_buffer);
2231 expr_as_string (decl, flags)
2233 enum tree_string_flags flags;
2235 reinit_global_formatting_buffer ();
2237 dump_expr (decl, flags);
2239 return output_finalize_message (scratch_buffer);
2243 decl_as_string (decl, flags)
2245 enum tree_string_flags flags;
2247 reinit_global_formatting_buffer ();
2249 dump_decl (decl, flags);
2251 return output_finalize_message (scratch_buffer);
2255 context_as_string (context, flags)
2257 enum tree_string_flags flags;
2259 reinit_global_formatting_buffer ();
2261 dump_scope (context, flags);
2263 return output_finalize_message (scratch_buffer);
2266 /* Generate the three forms of printable names for lang_printable_name. */
2269 lang_decl_name (decl, v)
2274 return decl_as_string (decl, TS_DECL_TYPE);
2276 reinit_global_formatting_buffer ();
2278 if (v == 1 && DECL_CLASS_SCOPE_P (decl))
2280 dump_type (CP_DECL_CONTEXT (decl), TS_PLAIN);
2281 print_scope_operator (scratch_buffer);
2284 if (TREE_CODE (decl) == FUNCTION_DECL)
2285 dump_function_name (decl, TS_PLAIN);
2287 dump_decl (DECL_NAME (decl), TS_PLAIN);
2289 return output_finalize_message (scratch_buffer);
2296 if (TREE_CODE (t) == PARM_DECL && DECL_CONTEXT (t))
2297 return DECL_SOURCE_FILE (DECL_CONTEXT (t));
2298 else if (TYPE_P (t))
2299 return DECL_SOURCE_FILE (TYPE_MAIN_DECL (t));
2300 else if (TREE_CODE (t) == OVERLOAD)
2301 return DECL_SOURCE_FILE (OVL_FUNCTION (t));
2303 return DECL_SOURCE_FILE (t);
2311 if (TREE_CODE (t) == PARM_DECL && DECL_CONTEXT (t))
2312 line = DECL_SOURCE_LINE (DECL_CONTEXT (t));
2313 if (TREE_CODE (t) == TYPE_DECL && DECL_ARTIFICIAL (t)
2314 && TYPE_MAIN_DECL (TREE_TYPE (t)))
2318 line = DECL_SOURCE_LINE (TYPE_MAIN_DECL (t));
2319 else if (TREE_CODE (t) == OVERLOAD)
2320 line = DECL_SOURCE_LINE (OVL_FUNCTION (t));
2322 line = DECL_SOURCE_LINE (t);
2330 /* Now the interfaces from cp_error et al to dump_type et al. Each takes an
2331 on/off VERBOSE flag and supply the appropriate TS_ flags to a dump_
2335 decl_to_string (decl, verbose)
2339 enum tree_string_flags flags = 0;
2341 if (TREE_CODE (decl) == TYPE_DECL || TREE_CODE (decl) == RECORD_TYPE
2342 || TREE_CODE (decl) == UNION_TYPE || TREE_CODE (decl) == ENUMERAL_TYPE)
2343 flags = TS_AGGR_TAGS;
2345 flags |= TS_DECL_TYPE | TS_DECORATE | TS_PARM_DEFAULTS;
2346 else if (TREE_CODE (decl) == FUNCTION_DECL)
2347 flags |= TS_DECL_TYPE | TS_FUNC_NORETURN;
2348 flags |= TS_TEMPLATE_PREFIX;
2350 reinit_global_formatting_buffer ();
2352 dump_decl (decl, flags);
2354 return output_finalize_message (scratch_buffer);
2358 expr_to_string (decl, verbose)
2360 int verbose ATTRIBUTE_UNUSED;
2362 reinit_global_formatting_buffer ();
2364 dump_expr (decl, 0);
2366 return output_finalize_message (scratch_buffer);
2370 fndecl_to_string (fndecl, verbose)
2374 enum tree_string_flags flags;
2376 flags = TS_FUNC_THROW | TS_DECL_TYPE;
2378 flags |= TS_PARM_DEFAULTS;
2379 reinit_global_formatting_buffer ();
2381 dump_decl (fndecl, flags);
2383 return output_finalize_message (scratch_buffer);
2388 code_to_string (c, v)
2390 int v ATTRIBUTE_UNUSED;
2392 return tree_code_name [c];
2396 language_to_string (c, v)
2398 int v ATTRIBUTE_UNUSED;
2405 case lang_cplusplus:
2412 my_friendly_abort (355);
2417 /* Return the proper printed version of a parameter to a C++ function. */
2420 parm_to_string (p, v)
2422 int v ATTRIBUTE_UNUSED;
2427 sprintf (digit_buffer, "%d", p+1);
2428 return digit_buffer;
2434 int v ATTRIBUTE_UNUSED;
2438 id = operator_name_info[(int) p].identifier;
2439 return id ? IDENTIFIER_POINTER (id) : "{unknown}";
2443 type_to_string (typ, verbose)
2447 enum tree_string_flags flags;
2451 flags |= TS_AGGR_TAGS;
2452 flags |= TS_TEMPLATE_PREFIX;
2454 reinit_global_formatting_buffer ();
2456 dump_type (typ, flags);
2458 return output_finalize_message (scratch_buffer);
2462 assop_to_string (p, v)
2464 int v ATTRIBUTE_UNUSED;
2468 id = assignment_operator_name_info[(int) p].identifier;
2469 return id ? IDENTIFIER_POINTER (id) : "{unknown}";
2473 args_to_string (p, verbose)
2477 enum tree_string_flags flags = 0;
2479 flags |= TS_AGGR_TAGS;
2484 if (TYPE_P (TREE_VALUE (p)))
2485 return type_as_string (p, flags);
2487 reinit_global_formatting_buffer ();
2488 for (; p; p = TREE_CHAIN (p))
2490 if (TREE_VALUE (p) == null_node)
2491 print_identifier (scratch_buffer, "NULL");
2493 dump_type (error_type (TREE_VALUE (p)), flags);
2495 separate_with_comma (scratch_buffer);
2497 return output_finalize_message (scratch_buffer);
2503 int v ATTRIBUTE_UNUSED;
2505 reinit_global_formatting_buffer ();
2507 dump_qualifiers (p, before);
2509 return output_finalize_message (scratch_buffer);
2513 lang_print_error_function (file)
2518 default_print_error_function (file);
2519 os = output_buffer_state (diagnostic_buffer);
2520 output_set_prefix (diagnostic_buffer, file);
2521 maybe_print_instantiation_context (diagnostic_buffer);
2522 output_buffer_state (diagnostic_buffer) = os;
2526 cp_diagnostic_starter (buffer, dc)
2527 output_buffer *buffer;
2528 diagnostic_context *dc;
2530 report_problematic_module (buffer);
2531 cp_print_error_function (buffer, dc);
2532 maybe_print_instantiation_context (buffer);
2533 output_set_prefix (buffer,
2534 context_as_prefix (diagnostic_file_location (dc),
2535 diagnostic_line_location (dc),
2536 diagnostic_is_warning (dc)));
2540 cp_diagnostic_finalizer (buffer, dc)
2541 output_buffer *buffer;
2542 diagnostic_context *dc __attribute__ ((__unused__));
2544 output_destroy_prefix (buffer);
2547 /* Print current function onto BUFFER, in the process of reporting
2548 a diagnostic message. Called from cp_diagnostic_starter. */
2550 cp_print_error_function (buffer, dc)
2551 output_buffer *buffer;
2552 diagnostic_context *dc;
2554 if (error_function_changed ())
2556 char *prefix = diagnostic_file_location (dc)
2557 ? file_name_as_prefix (diagnostic_file_location (dc))
2561 os = output_buffer_state (buffer);
2562 output_set_prefix (buffer, prefix);
2564 if (current_function_decl == NULL)
2565 output_add_string (buffer, "At global scope:");
2568 (buffer, "In %s `%s':", function_category (current_function_decl),
2569 (*decl_printable_name) (current_function_decl, 2));
2570 output_add_newline (buffer);
2572 record_last_error_function ();
2573 output_destroy_prefix (buffer);
2574 output_buffer_state (buffer) = os;
2578 /* Returns a description of FUNCTION using standard terminology. */
2580 function_category (fn)
2583 if (DECL_FUNCTION_MEMBER_P (fn))
2585 if (DECL_STATIC_FUNCTION_P (fn))
2586 return "static member function";
2587 else if (DECL_COPY_CONSTRUCTOR_P (fn))
2588 return "copy constructor";
2589 else if (DECL_CONSTRUCTOR_P (fn))
2590 return "constructor";
2591 else if (DECL_DESTRUCTOR_P (fn))
2592 return "destructor";
2594 return "member function";
2600 /* Report the full context of a current template instantiation,
2603 print_instantiation_full_context (buffer)
2604 output_buffer *buffer;
2606 tree p = current_instantiation ();
2608 const char *file = input_filename;
2612 if (current_function_decl != TINST_DECL (p)
2613 && current_function_decl != NULL_TREE)
2614 /* We can get here during the processing of some synthesized
2615 method. Then, TINST_DECL (p) will be the function that's causing
2620 if (current_function_decl == TINST_DECL (p))
2621 /* Avoid redundancy with the the "In function" line. */;
2623 output_verbatim (buffer, "%s: In instantiation of `%s':\n", file,
2624 decl_as_string (TINST_DECL (p),
2625 TS_DECL_TYPE | TS_FUNC_NORETURN));
2627 line = TINST_LINE (p);
2628 file = TINST_FILE (p);
2633 print_instantiation_partial_context (buffer, p, file, line);
2636 /* Same as above but less verbose. */
2638 print_instantiation_partial_context (buffer, t, file, line)
2639 output_buffer *buffer;
2644 for (; t; t = TREE_CHAIN (t))
2647 (buffer, "%s:%d: instantiated from `%s'\n", file, line,
2648 decl_as_string (TINST_DECL (t), TS_DECL_TYPE | TS_FUNC_NORETURN));
2649 line = TINST_LINE (t);
2650 file = TINST_FILE (t);
2652 output_verbatim (buffer, "%s:%d: instantiated from here\n", file, line);
2655 /* Called from cp_thing to print the template context for an error. */
2657 maybe_print_instantiation_context (buffer)
2658 output_buffer *buffer;
2660 if (!problematic_instantiation_changed () || current_instantiation () == 0)
2663 record_last_problematic_instantiation ();
2664 print_instantiation_full_context (buffer);
2667 /* Report the bare minimum context of a template instantiation. */
2669 print_instantiation_context ()
2671 print_instantiation_partial_context
2672 (diagnostic_buffer, current_instantiation (), input_filename, lineno);
2673 flush_diagnostic_buffer ();
2676 /* Called from output_format -- during diagnostic message processing --
2677 to handle C++ specific format specifier with the following meanings:
2678 %A function argument-list.
2681 %F function declaration.
2682 %P function parameter whose position is indicated by an integer.
2686 cp_tree_printer (buffer)
2687 output_buffer *buffer;
2690 tree_formatting_info tfi;
2692 bzero (&tfi, sizeof (tree_formatting_info));
2694 if (*output_buffer_text_cursor (buffer) == '+')
2695 ++output_buffer_text_cursor (buffer);
2696 if (*output_buffer_text_cursor (buffer) == '#')
2699 ++output_buffer_text_cursor (buffer);
2702 switch (*output_buffer_text_cursor (buffer))
2705 tree_being_formatted (&tfi) =
2706 va_arg (output_buffer_format_args (buffer), tree);
2708 tree_formatting_flags (&tfi) = TFF_SCOPE
2709 | TFF_FUNCTION_DEFAULT_ARGUMENTS;
2710 print_function_argument_list (buffer, &tfi);
2714 tree_being_formatted (&tfi) =
2715 va_arg (output_buffer_format_args (buffer), tree);
2717 tree_formatting_flags (&tfi) = TFF_SCOPE | TFF_DECL_SPECIFIERS
2718 | TFF_CLASS_KEY_OR_ENUM | TFF_RETURN_TYPE
2719 | TFF_FUNCTION_DEFAULT_ARGUMENTS | TFF_TEMPLATE_DEFAULT_ARGUMENTS
2720 | TFF_EXCEPTION_SPECIFICATION | TFF_CHASE_NAMESPACE_ALIAS;
2721 print_declaration (buffer, &tfi);
2725 tree_being_formatted (&tfi) =
2726 va_arg (output_buffer_format_args (buffer), tree);
2728 tree_formatting_flags (&tfi) = TFF_SCOPE;
2729 print_expression (buffer, &tfi);
2733 tree_being_formatted (&tfi) =
2734 va_arg (output_buffer_format_args (buffer), tree);
2736 tree_formatting_flags (&tfi) = TFF_SCOPE | TFF_DECL_SPECIFIERS
2737 | TFF_RETURN_TYPE | TFF_FUNCTION_DEFAULT_ARGUMENTS
2738 | TFF_EXCEPTION_SPECIFICATION;
2739 print_function_declaration (buffer, &tfi);
2743 print_function_parameter
2744 (buffer, va_arg (output_buffer_format_args (buffer), int));
2748 tree_being_formatted (&tfi) =
2749 va_arg (output_buffer_format_args (buffer), tree);
2751 tree_formatting_flags (&tfi) = TFF_SCOPE | TFF_CLASS_KEY_OR_ENUM
2752 | TFF_RETURN_TYPE | TFF_EXCEPTION_SPECIFICATION;
2753 print_type_id (buffer, &tfi);
2757 tree_being_formatted (&tfi) =
2758 va_arg (output_buffer_format_args (buffer), tree);
2759 print_cv_qualifier_seq (buffer, &tfi);
2769 /* Print a function argument-list represented by tree_being_formatted (TFI)
2772 print_function_argument_list (buffer, tfi)
2773 output_buffer *buffer __attribute__ ((__unused__));
2774 tfi_t tfi __attribute__ ((__unused__));
2778 /* Print a declaration represented by tree_being_formatted (TFI)
2781 print_declaration (buffer, tfi)
2782 output_buffer *buffer __attribute__ ((__unused__));
2783 tfi_t tfi __attribute__ ((__unused__));
2787 /* Print an expression represented by tree_being_formatted (TFI)
2790 print_expression (buffer, tfi)
2791 output_buffer *buffer __attribute__ ((__unused__));
2792 tfi_t tfi __attribute__ ((__unused__));
2797 print_integer (buffer, i)
2798 output_buffer *buffer;
2801 sprintf (digit_buffer, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT) i);
2802 output_add_string (buffer, digit_buffer);
2805 /* Print a function declaration represented by tree_being_formatted (TFI)
2808 print_function_declaration (buffer, tfi)
2809 output_buffer *buffer __attribute__ ((__unused__));
2810 tfi_t tfi __attribute__ ((__unused__));
2814 /* Print the N'th function parameter onto BUFFER. A negative value of N
2815 means the implicit "this" parameter of a member function. */
2817 print_function_parameter (buffer, n)
2818 output_buffer *buffer;
2822 print_identifier (buffer, "this");
2824 output_decimal (buffer, n + 1);
2827 /* Print a type represented by tree_being_formatted (TFI) onto BUFFER. */
2829 print_type_id (buffer, tfi)
2830 output_buffer *buffer;
2833 tree t = tree_being_formatted (tfi);
2834 int flags = tree_formatting_flags (tfi);
2838 if (flags & TFF_CHASE_TYPEDEF)
2839 tree_being_formatted (tfi) =
2840 typedef_original_name (tree_being_formatted (tfi));
2842 /* A type-id is of the form:
2844 type-specifier-seq abstract-declarator(opt) */
2845 print_type_specifier_seq (buffer, tfi);
2847 if (TYPE_PTRMEMFUNC_P (t))
2850 /* For types with abstract-declarator, print_type_specifier_seq prints
2851 the start of the abstract-declarator. Fiinish the job. */
2852 switch (TREE_CODE (t))
2856 case REFERENCE_TYPE:
2861 print_rest_of_abstract_declarator (buffer, tfi);
2867 tree_being_formatted (tfi) = t;
2870 /* Print the type-specifier-seq part of a type-id. If appropriate, print
2871 also the prefix of the abstract-declarator. */
2873 print_type_specifier_seq (buffer, tfi)
2874 output_buffer *buffer;
2877 int flags = tree_formatting_flags (tfi);
2878 tree t = tree_being_formatted (tfi);
2879 enum tree_code code = TREE_CODE (t);
2881 /* A type-speficier-seq is:
2882 type-specifier type-specifier-seq(opt)
2885 simple-type-specifier
2888 elaborated-type-specifier
2891 We do not, however, pretty-print class-specifier nor enum-specifier. */
2896 case IDENTIFIER_NODE:
2906 case TEMPLATE_TYPE_PARM:
2908 case TEMPLATE_TEMPLATE_PARM:
2911 print_cv_qualifier_seq (buffer, tfi);
2912 if ((flags & TFF_DECL_SPECIFIERS)
2913 && (code == TYPENAME_TYPE || IS_AGGR_TYPE (t)))
2914 print_elaborated_type_specifier (buffer, tfi);
2916 print_simple_type_specifier (buffer, tfi);
2919 /* Because the abstract-declarator can modify the type-specifier-seq
2920 in a highly non linear manner, we pretty-print its prefix here.
2921 The suffix part is handled by print_rest_of_abstract_declarator. */
2923 /* A RECORD_TYPE is also used to represent a pointer to member
2926 if (TYPE_PTRMEMFUNC_P (t))
2928 /* Print the return type. */
2929 tree_being_formatted (tfi) =
2930 TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (t));
2931 print_type_id (buffer, tfi);
2932 print_whitespace (buffer, tfi);
2934 /* Then the beginning of the abstract-declarator part. */
2935 tree_being_formatted (tfi) =
2936 TYPE_METHOD_BASETYPE (TYPE_PTRMEMFUNC_FN_TYPE (t));
2937 print_left_paren (buffer);
2938 print_nested_name_specifier (buffer, tfi);
2945 if (TYPE_PTRMEM_P (t))
2946 goto ptr_data_member;
2948 goto non_ptr_data_member;
2952 case REFERENCE_TYPE:
2955 non_ptr_data_member:
2956 tree_being_formatted (tfi) = TREE_TYPE (t);
2957 print_type_specifier_seq (buffer, tfi);
2958 if (code == POINTER_TYPE || code == REFERENCE_TYPE)
2960 if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
2961 print_left_paren (buffer);
2963 else if (code == FUNCTION_TYPE || code == METHOD_TYPE)
2965 print_whitespace (buffer, tfi);
2966 print_left_paren (buffer);
2967 if (code == METHOD_TYPE)
2969 tree_being_formatted (tfi) = TYPE_METHOD_BASETYPE (t);
2970 print_nested_name_specifier (buffer, tfi);
2971 tree_being_formatted (tfi) = t;
2974 tree_being_formatted (tfi) = t;
2979 /* Firstly, the type of the member. */
2980 tree_being_formatted (tfi) = TREE_TYPE (t);
2981 print_type_id (buffer, tfi);
2982 print_whitespace (buffer, tfi);
2984 /* Then, the containing class. */
2985 tree_being_formatted (tfi) = TYPE_OFFSET_BASETYPE (t);
2986 print_nested_name_specifier (buffer, tfi);
2987 tree_being_formatted (tfi) = t;
2991 sorry_for_unsupported_tree (t);
2995 print_identifier (buffer, "{type-specifier-seq error}");
2999 tree_being_formatted (tfi) = t;
3002 /* Print the simpe-type-specifier component of a type-specifier. */
3004 print_simple_type_specifier (buffer, tfi)
3005 output_buffer *buffer;
3008 int flags = tree_formatting_flags (tfi);
3009 tree t = tree_being_formatted (tfi);
3010 enum tree_code code = TREE_CODE (t);
3015 print_identifier (buffer, "{unknown type}");
3018 case IDENTIFIER_NODE:
3019 print_tree_identifier (buffer, t);
3023 print_identifier (buffer, "__complex__ ");
3024 tree_being_formatted (tfi) = TREE_TYPE (t);
3025 print_type_id (buffer, tfi);
3029 tree_being_formatted (tfi) = TYPE_CONTEXT (t);
3030 print_nested_name_specifier (buffer, tfi);
3031 tree_being_formatted (tfi) = TYPENAME_TYPE_FULLNAME (t);
3032 tree_formatting_flags (tfi) |= ~TFF_CHASE_TYPEDEF;
3033 print_type_id (buffer, tfi);
3037 print_identifier (buffer, "__typeof__");
3038 tree_being_formatted (tfi) = TYPE_FIELDS (t);
3039 print_left_paren (buffer);
3040 print_expression (buffer, tfi);
3041 print_right_paren (buffer);
3045 if (TREE_UNSIGNED (t))
3047 if (TYPE_MAIN_VARIANT (t) == integer_type_node)
3048 /* We don't want pedantry like `unsigned int'. */;
3049 else if (!TREE_UNSIGNED (TYPE_MAIN_VARIANT (t)))
3051 print_identifier (buffer, "unsigned");
3052 print_whitespace (buffer, tfi);
3055 else if (TYPE_MAIN_VARIANT (t) == char_type_node)
3057 print_identifier (buffer, "signed");
3058 print_whitespace (buffer, tfi);
3064 tree s = (flags & TFF_CHASE_TYPEDEF) ? TYPE_MAIN_VARIANT (t) : t;
3066 if (TYPE_NAME (s) && TYPE_IDENTIFIER (s))
3067 print_tree_identifier (buffer, TYPE_IDENTIFIER (s));
3069 /* Types like intQI_type_node and friends have no names.
3070 These don't come up in user error messages, but it's nice
3071 to be able to print them from the debugger. */
3072 print_identifier (buffer, "{anonymous}");
3076 case TEMPLATE_TEMPLATE_PARM:
3077 if (TYPE_IDENTIFIER (t))
3078 print_tree_identifier (buffer, TYPE_IDENTIFIER (t));
3080 print_identifier (buffer, "{anonymous template template parameter}");
3084 if (flags & TFF_CHASE_TYPEDEF)
3085 print_type_id (buffer, tfi);
3087 print_tree_identifier (buffer, DECL_NAME (t));
3090 case BOUND_TEMPLATE_TEMPLATE_PARM:
3092 print_template_id (buffer, tfi);
3095 case TEMPLATE_TYPE_PARM:
3096 if (TYPE_IDENTIFIER (t))
3097 print_tree_identifier (buffer, TYPE_IDENTIFIER (t));
3099 print_identifier (buffer, "{anonymous template type parameter}");
3106 tree_being_formatted (tfi) = t;
3107 tree_formatting_flags (tfi) = flags;
3110 /* Print the elaborated-type-specifier form of a type-specifier. */
3112 print_elaborated_type_specifier (buffer, tfi)
3113 output_buffer *buffer;
3116 int flags = tree_formatting_flags (tfi);
3117 tree t = tree_being_formatted (tfi);
3119 switch (TREE_CODE (t))
3122 print_identifier (buffer, "typename");
3123 print_whitespace (buffer, tfi);
3124 tree_formatting_flags (tfi) |= ~TFF_DECL_SPECIFIERS;
3125 print_simple_type_specifier (buffer, tfi);
3131 tree name = NULL_TREE;
3133 if (flags & TFF_CHASE_TYPEDEF)
3134 tree_being_formatted (tfi) = typedef_original_name (t);
3137 (buffer, class_key_or_enum (tree_being_formatted (tfi)));
3138 print_whitespace (buffer, tfi);
3140 name = TYPE_NAME (tree_being_formatted (tfi));
3143 if (flags & TFF_SCOPE)
3145 tree_being_formatted (tfi) = CP_DECL_CONTEXT (name);
3146 print_nested_name_specifier (buffer, tfi);
3148 print_tree_identifier (buffer, DECL_NAME (name));
3151 print_identifier (buffer, "{anonymous}");
3156 sorry_for_unsupported_tree (t);
3160 tree_being_formatted (tfi) = t;
3161 tree_formatting_flags (tfi) = flags;
3164 /* Finish the job of printing the abstract-declarator part of a
3167 print_rest_of_abstract_declarator (buffer, tfi)
3168 output_buffer *buffer;
3171 tree t = tree_being_formatted (tfi);
3172 enum tree_code code = TREE_CODE (t);
3174 /* An abstract-declarator has the form:
3176 abstract-declarator:
3177 ptr-operator abstract-declarator(opt)
3178 direct-abstract-declarator
3180 direct-abstract-declarator:
3181 direct-abstract-declarator(opt)
3182 ( parameter-declaration-clause ) cv-qualifier-seq(opt)
3183 exception-specification(opt)
3184 direct-abstract-declarator(opt) [ constant-expression(opt) ]
3185 ( direct-abstract-declarator ) */
3190 print_left_bracket (buffer);
3191 if (TYPE_DOMAIN (t))
3193 tree s = TYPE_DOMAIN (t);
3195 if (host_integerp (TYPE_MAX_VALUE (s), 0))
3196 output_decimal (buffer, tree_low_cst (TYPE_MAX_VALUE (s), 0) + 1);
3197 else if (TREE_CODE (TYPE_MAX_VALUE (s)) == MINUS_EXPR)
3199 tree_being_formatted (tfi) =
3200 TREE_OPERAND (TYPE_MAX_VALUE (s), 0);
3201 print_expression (buffer, tfi);
3202 tree_being_formatted (tfi) = t;
3206 tree_being_formatted (tfi) = fold
3207 (cp_build_binary_op (PLUS_EXPR, TYPE_MAX_VALUE (s),
3209 print_expression (buffer, tfi);
3210 tree_being_formatted (tfi) = t;
3213 print_right_bracket (buffer);
3214 put_whitespace (tfi) = none;
3215 tree_being_formatted (tfi) = TREE_TYPE (t);
3216 print_rest_of_abstract_declarator (buffer, tfi);
3217 tree_being_formatted (tfi) = t;
3221 case REFERENCE_TYPE:
3223 if (code == POINTER_TYPE || code == REFERENCE_TYPE)
3225 output_add_character (buffer, "&*"[code == POINTER_TYPE]);
3226 if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3227 print_right_paren (buffer);
3229 put_whitespace (tfi) = before;
3230 print_cv_qualifier_seq (buffer, tfi);
3231 tree_being_formatted (tfi) = TREE_TYPE (t);
3232 print_rest_of_abstract_declarator (buffer, tfi);
3233 tree_being_formatted (tfi) = t;
3238 print_right_paren (buffer);
3239 print_whitespace (buffer, tfi);
3241 /* Skip the `this' implicit parameter if present. */
3242 tree_being_formatted (tfi) = TYPE_ARG_TYPES (t);
3243 if (code == METHOD_TYPE)
3244 tree_being_formatted (tfi) = TREE_CHAIN (tree_being_formatted (tfi));
3246 /* Print the parameter-list. */
3247 print_left_paren (buffer);
3248 print_parameter_declaration_clause (buffer, tfi);
3249 print_right_paren (buffer);
3251 print_whitespace (buffer, tfi);
3253 if (code == METHOD_TYPE)
3255 tree_being_formatted (tfi) =
3256 TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t)));
3257 print_cv_qualifier_seq (buffer, tfi);
3260 /* Finish the abstract-declarator. */
3261 tree_being_formatted (tfi) = TREE_TYPE (t);
3262 print_rest_of_abstract_declarator (buffer, tfi);
3264 /* Print the exception-specification for documentaion purpose. */
3265 tree_being_formatted (tfi) = TYPE_RAISES_EXCEPTIONS (t);
3266 print_exception_specification (buffer, tfi);
3267 tree_being_formatted (tfi) = t;
3270 /* These types don't have abstract-declarator. */
3272 case IDENTIFIER_NODE:
3282 case TEMPLATE_TYPE_PARM:
3284 case TEMPLATE_TEMPLATE_PARM:
3289 sorry_for_unsupported_tree (t);
3290 /* fall throught. */
3296 /* Print the cv-quafilers of tree_being_formatted (TFI) onto BUFFER. */
3298 print_cv_qualifier_seq (buffer, tfi)
3299 output_buffer *buffer;
3300 tree_formatting_info *tfi;
3302 int cv = TYPE_QUALS (tree_being_formatted (tfi));
3303 int pad_after = after == put_whitespace (tfi);
3304 static const int mask[]
3305 = {TYPE_QUAL_CONST, TYPE_QUAL_VOLATILE, TYPE_QUAL_RESTRICT};
3306 static const char *const qualifier[]
3307 = { "const", "volatile", "__restrict__" };
3312 for (i = 0; i != 3; ++i)
3315 if (put_whitespace (tfi) == before)
3316 output_add_space (buffer);
3317 print_identifier (buffer, qualifier[i]);
3318 put_whitespace (tfi) = before;
3323 output_add_space (buffer);
3324 put_whitespace (tfi) = none;
3330 print_parameter_declaration_clause (buffer, tfi)
3331 output_buffer *buffer __attribute__ ((__unused__));
3332 tfi_t tfi __attribute__ ((__unused__));
3337 print_exception_specification (buffer, tfi)
3338 output_buffer *buffer __attribute__ ((__unused__));
3339 tfi_t tfi __attribute__ ((__unused__));
3344 print_nested_name_specifier (buffer, tfi)
3345 output_buffer *buffer;
3348 int flags = tree_formatting_flags (tfi);
3349 tree t = tree_being_formatted (tfi);
3350 /* A nested-name-specifier is:
3351 class-or-namespace-name :: nested-name-specifier(opt)
3352 class-or-namespace-name :: template nested-name-specifier
3354 The latter form being the correct syntax for a name designating
3355 a template member, where the preceding class-or-namespace-name part
3356 is name-dependent. For the time being, we do not do such a
3357 sophisticated pretty-printing.
3359 class-or-namespace-name:
3363 if (t == NULL_TREE || t == global_namespace)
3366 if (CLASS_TYPE_P (t) && !(flags & TFF_CLASS_SCOPE))
3369 if (TREE_CODE (t) == NAMESPACE_DECL && !(flags & TFF_NAMESPACE_SCOPE))
3372 tree_being_formatted (tfi) = DECL_CONTEXT (t);
3373 print_nested_name_specifier (buffer, tfi);
3374 print_scope_operator (buffer);
3375 if (TREE_CODE (t) == NAMESPACE_DECL)
3376 print_tree_identifier (buffer, DECL_NAME (t));
3377 else if (CLASS_TYPE_P (t))
3379 if (!DECL_USE_TEMPLATE (t))
3380 print_tree_identifier (buffer, TYPE_IDENTIFIER (t));
3383 tree_being_formatted (tfi) = t;
3384 print_template_id (buffer, tfi);
3388 tree_being_formatted (tfi) = t;
3392 print_template_id (buffer, tfi)
3393 output_buffer *buffer;
3394 tfi_t tfi __attribute__ ((__unused__));
3396 print_template_argument_list_start (buffer);
3398 print_template_argument_list_end (buffer);
3402 typedef_original_name (t)
3405 return DECL_ORIGINAL_TYPE (t) ? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t);
3409 print_non_consecutive_character (buffer, c)
3410 output_buffer *buffer;
3413 const char *p = output_last_position (buffer);
3415 if (p != NULL && *p == c)
3416 output_add_space (buffer);
3417 output_add_character (buffer, c);