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 /* This data structure bundles altogether, all the information necessary
33 for pretty-printing a C++ source-level entity represented by a tree. */
39 } tree_formatting_info
, *tfi_t
;
41 #define tree_being_formatted(TFI) (TFI)->decl
42 #define tree_formatting_flags(TFI) (TFI)->flags
43 #define put_whitespace(TFI) (TFI)->pad
45 #define sorry_for_unsupported_tree(T) \
46 sorry ("`%s' not supported by %s", tree_code_name[(int) TREE_CODE (T)], \
49 #define print_scope_operator(BUFFER) output_add_string (BUFFER, "::")
50 #define print_left_paren(BUFFER) output_add_character (BUFFER, '(')
51 #define print_right_paren(BUFFER) output_add_character (BUFFER, ')')
52 #define print_left_bracket(BUFFER) output_add_character (BUFFER, '[')
53 #define print_right_bracket(BUFFER) output_add_character (BUFFER, ']')
54 #define print_template_argument_list_start(BUFFER) \
55 print_non_consecutive_character (BUFFER, '<')
56 #define print_template_argument_list_end(BUFFER) \
57 print_non_consecutive_character (BUFFER, '>')
58 #define print_whitespace(BUFFER, TFI) \
60 output_add_space (BUFFER); \
61 put_whitespace (TFI) = none; \
63 #define print_tree_identifier(BUFFER, TID) \
64 output_add_string (BUFFER, IDENTIFIER_POINTER (TID))
65 #define print_identifier(BUFFER, ID) output_add_string (BUFFER, ID)
66 #define separate_with_comma(BUFFER) output_add_string (BUFFER, ", ")
68 /* The global buffer where we dump everything. It is there only for
69 transitional purpose. It is expected, in the near future, to be
70 completely removed. */
71 static output_buffer scratch_buffer_rec
;
72 static output_buffer
*scratch_buffer
= &scratch_buffer_rec
;
74 # define NEXT_CODE(t) (TREE_CODE (TREE_TYPE (t)))
76 #define reinit_global_formatting_buffer() \
77 output_clear_message_text (scratch_buffer)
79 static const char *args_to_string
PARAMS ((tree
, int));
80 static const char *assop_to_string
PARAMS ((enum tree_code
, int));
81 static const char *code_to_string
PARAMS ((enum tree_code
, int));
82 static const char *cv_to_string
PARAMS ((tree
, int));
83 static const char *decl_to_string
PARAMS ((tree
, int));
84 static const char *expr_to_string
PARAMS ((tree
, int));
85 static const char *fndecl_to_string
PARAMS ((tree
, int));
86 static const char *op_to_string
PARAMS ((enum tree_code
, int));
87 static const char *parm_to_string
PARAMS ((int, int));
88 static const char *type_to_string
PARAMS ((tree
, int));
90 static void dump_type
PARAMS ((tree
, int));
91 static void dump_typename
PARAMS ((tree
, int));
92 static void dump_simple_decl
PARAMS ((tree
, tree
, int));
93 static void dump_decl
PARAMS ((tree
, int));
94 static void dump_template_decl
PARAMS ((tree
, int));
95 static void dump_function_decl
PARAMS ((tree
, int));
96 static void dump_expr
PARAMS ((tree
, int));
97 static void dump_unary_op
PARAMS ((const char *, tree
, int));
98 static void dump_binary_op
PARAMS ((const char *, tree
, int));
99 static void dump_aggr_type
PARAMS ((tree
, int));
100 static enum pad dump_type_prefix
PARAMS ((tree
, int));
101 static void dump_type_suffix
PARAMS ((tree
, int));
102 static void dump_function_name
PARAMS ((tree
, int));
103 static void dump_expr_list
PARAMS ((tree
, int));
104 static void dump_global_iord
PARAMS ((tree
));
105 static enum pad dump_qualifiers
PARAMS ((tree
, enum pad
));
106 static void dump_char
PARAMS ((int));
107 static void dump_parameters
PARAMS ((tree
, int));
108 static void dump_exception_spec
PARAMS ((tree
, int));
109 static const char *class_key_or_enum
PARAMS ((tree
));
110 static tree ident_fndecl
PARAMS ((tree
));
111 static void dump_template_argument
PARAMS ((tree
, int));
112 static void dump_template_argument_list
PARAMS ((tree
, int));
113 static void dump_template_parameter
PARAMS ((tree
, int));
114 static void dump_template_bindings
PARAMS ((tree
, tree
));
115 static void dump_scope
PARAMS ((tree
, int));
116 static void dump_template_parms
PARAMS ((tree
, int, int));
118 static const char *function_category
PARAMS ((tree
));
119 static void lang_print_error_function
PARAMS ((const char *));
120 static void maybe_print_instantiation_context
PARAMS ((output_buffer
*));
121 static void print_instantiation_full_context
PARAMS ((output_buffer
*));
122 static void print_instantiation_partial_context
PARAMS ((output_buffer
*, tree
,
124 static void cp_diagnostic_starter
PARAMS ((output_buffer
*,
125 diagnostic_context
*));
126 static void cp_diagnostic_finalizer
PARAMS ((output_buffer
*,
127 diagnostic_context
*));
128 static void cp_print_error_function
PARAMS ((output_buffer
*,
129 diagnostic_context
*));
131 static int cp_tree_printer
PARAMS ((output_buffer
*));
132 static void print_function_argument_list
PARAMS ((output_buffer
*, tfi_t
));
133 static void print_declaration
PARAMS ((output_buffer
*, tfi_t
));
134 static void print_expression
PARAMS ((output_buffer
*, tfi_t
));
135 static void print_integer
PARAMS ((output_buffer
*, HOST_WIDE_INT
));
136 static void print_function_declaration
PARAMS ((output_buffer
*, tfi_t
));
137 static void print_function_parameter
PARAMS ((output_buffer
*, int));
138 static void print_type_id
PARAMS ((output_buffer
*, tfi_t
));
139 static void print_cv_qualifier_seq
PARAMS ((output_buffer
*, tfi_t
));
140 static void print_type_specifier_seq
PARAMS ((output_buffer
*, tfi_t
));
141 static void print_simple_type_specifier
PARAMS ((output_buffer
*, tfi_t
));
142 static void print_elaborated_type_specifier
PARAMS ((output_buffer
*, tfi_t
));
143 static void print_rest_of_abstract_declarator
PARAMS ((output_buffer
*,
145 static void print_parameter_declaration_clause
PARAMS ((output_buffer
*,
147 static void print_exception_specification
PARAMS ((output_buffer
*, tfi_t
));
148 static void print_nested_name_specifier
PARAMS ((output_buffer
*, tfi_t
));
149 static void print_template_id
PARAMS ((output_buffer
*, tfi_t
));
150 static tree typedef_original_name
PARAMS ((tree
));
151 static void print_non_consecutive_character
PARAMS ((output_buffer
*, int));
153 #define A args_to_string
154 #define C code_to_string
155 #define D decl_to_string
156 #define E expr_to_string
157 #define F fndecl_to_string
158 #define L language_to_string
159 #define O op_to_string
160 #define P parm_to_string
161 #define Q assop_to_string
162 #define T type_to_string
163 #define V cv_to_string
165 #define o (cp_printer *) 0
166 cp_printer
* cp_printers
[256] =
168 /*0 1 2 3 4 5 6 7 8 9 A B C D E F */
169 o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, /* 0x00 */
170 o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, /* 0x10 */
171 o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, /* 0x20 */
172 o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, /* 0x30 */
173 o
, A
, o
, C
, D
, E
, F
, o
, o
, o
, o
, o
, L
, o
, o
, O
, /* 0x40 */
174 P
, Q
, o
, o
, T
, o
, V
, o
, o
, o
, o
, o
, o
, o
, o
, o
, /* 0x50 */
175 o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, /* 0x60 */
176 o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, o
, /* 0x70 */
193 init_output_buffer (scratch_buffer
, /* prefix */NULL
, /* line-width */0);
195 print_error_function
= lang_print_error_function
;
196 lang_diagnostic_starter
= cp_diagnostic_starter
;
197 lang_diagnostic_finalizer
= cp_diagnostic_finalizer
;
199 lang_printer
= cp_tree_printer
;
202 /* Dump a scope, if deemed necessary. */
205 dump_scope (scope
, flags
)
209 int f
= ~TFF_RETURN_TYPE
& (TFF_DECL_SPECIFIERS
210 | (flags
& (TFF_SCOPE
| TFF_CHASE_TYPEDEF
)));
212 if (scope
== NULL_TREE
)
215 if (TREE_CODE (scope
) == NAMESPACE_DECL
)
217 if (scope
!= global_namespace
)
219 dump_decl (scope
, f
);
220 print_scope_operator (scratch_buffer
);
223 else if (AGGREGATE_TYPE_P (scope
))
225 dump_type (scope
, f
);
226 print_scope_operator (scratch_buffer
);
228 else if ((flags
& TFF_SCOPE
) && TREE_CODE (scope
) == FUNCTION_DECL
)
230 dump_function_decl (scope
, f
);
231 print_scope_operator (scratch_buffer
);
235 /* Dump type qualifiers, providing padding as requested. Return an
236 indication of whether we dumped something. */
239 dump_qualifiers (t
, p
)
243 static const int masks
[] =
244 {TYPE_QUAL_CONST
, TYPE_QUAL_VOLATILE
, TYPE_QUAL_RESTRICT
};
245 static const char *const names
[] =
246 {"const", "volatile", "__restrict"};
248 int quals
= TYPE_QUALS (t
);
249 int do_after
= p
== after
;
253 for (ix
= 0; ix
!= 3; ix
++)
254 if (masks
[ix
] & quals
)
257 output_add_space (scratch_buffer
);
259 print_identifier (scratch_buffer
, names
[ix
]);
262 output_add_space (scratch_buffer
);
269 /* This must be large enough to hold any printed integer or floating-point
271 static char digit_buffer
[128];
273 /* Dump the template ARGument under control of FLAGS. */
276 dump_template_argument (arg
, flags
)
280 if (TYPE_P (arg
) || TREE_CODE (arg
) == TEMPLATE_DECL
)
281 dump_type (arg
, flags
& ~TFF_CLASS_KEY_OR_ENUM
);
283 dump_expr (arg
, (flags
| TFF_EXPR_IN_PARENS
) & ~TFF_CLASS_KEY_OR_ENUM
);
286 /* Dump a template-argument-list ARGS (always a TREE_VEC) under control
290 dump_template_argument_list (args
, flags
)
294 int n
= TREE_VEC_LENGTH (args
);
298 for (i
= 0; i
< n
; ++i
)
301 separate_with_comma (scratch_buffer
);
302 dump_template_argument (TREE_VEC_ELT (args
, i
), flags
);
307 /* Dump a template parameter PARM (a TREE_LIST) under control of FLAGS. */
310 dump_template_parameter (parm
, flags
)
314 tree p
= TREE_VALUE (parm
);
315 tree a
= TREE_PURPOSE (parm
);
317 if (TREE_CODE (p
) == TYPE_DECL
)
319 if (flags
& TFF_DECL_SPECIFIERS
)
321 print_identifier (scratch_buffer
, "class");
324 output_add_space (scratch_buffer
);
325 print_tree_identifier (scratch_buffer
, DECL_NAME (p
));
328 else if (DECL_NAME (p
))
329 print_tree_identifier (scratch_buffer
, DECL_NAME (p
));
331 print_identifier (scratch_buffer
, "{template default argument error}");
334 dump_decl (p
, flags
| TFF_DECL_SPECIFIERS
);
336 if ((flags
& TFF_FUNCTION_DEFAULT_ARGUMENTS
) && a
!= NULL_TREE
)
338 output_add_string (scratch_buffer
, " = ");
339 if (TREE_CODE (p
) == TYPE_DECL
|| TREE_CODE (p
) == TEMPLATE_DECL
)
340 dump_type (a
, flags
& ~TFF_CHASE_TYPEDEF
);
342 dump_expr (a
, flags
| TFF_EXPR_IN_PARENS
);
346 /* Dump, under control of FLAGS, a template-parameter-list binding.
347 PARMS is a TREE_LIST of TREE_VEC of TREE_LIST and ARGS is a
351 dump_template_bindings (parms
, args
)
358 tree p
= TREE_VALUE (parms
);
359 int lvl
= TMPL_PARMS_DEPTH (parms
);
363 for (i
= 0; i
< TREE_VEC_LENGTH (p
); ++i
)
365 tree arg
= NULL_TREE
;
367 /* Don't crash if we had an invalid argument list. */
368 if (TMPL_ARGS_DEPTH (args
) >= lvl
)
370 tree lvl_args
= TMPL_ARGS_LEVEL (args
, lvl
);
371 if (NUM_TMPL_ARGS (lvl_args
) > arg_idx
)
372 arg
= TREE_VEC_ELT (lvl_args
, arg_idx
);
376 separate_with_comma (scratch_buffer
);
377 dump_template_parameter (TREE_VEC_ELT (p
, i
), TFF_PLAIN_IDENTIFIER
);
378 output_add_string (scratch_buffer
, " = ");
380 dump_template_argument (arg
, TFF_PLAIN_IDENTIFIER
);
382 print_identifier (scratch_buffer
, "<missing>");
388 parms
= TREE_CHAIN (parms
);
392 /* Dump into the obstack a human-readable equivalent of TYPE. FLAGS
393 controls the format. */
403 if (TYPE_PTRMEMFUNC_P (t
))
406 switch (TREE_CODE (t
))
409 print_identifier (scratch_buffer
, "<unknown type>");
413 /* A list of function parms. */
414 dump_parameters (t
, flags
);
417 case IDENTIFIER_NODE
:
418 print_tree_identifier (scratch_buffer
, t
);
422 dump_type (BINFO_TYPE (t
), flags
);
428 dump_aggr_type (t
, flags
);
432 if (flags
& TFF_CHASE_TYPEDEF
)
434 dump_type (DECL_ORIGINAL_TYPE (t
)
435 ? DECL_ORIGINAL_TYPE (t
) : TREE_TYPE (t
), flags
);
438 /* else fallthrough */
442 dump_decl (t
, flags
& ~TFF_DECL_SPECIFIERS
);
446 output_add_string (scratch_buffer
, "__complex__ ");
447 dump_type (TREE_TYPE (t
), flags
);
451 output_add_string (scratch_buffer
, "vector ");
452 dump_type (TREE_TYPE (t
), flags
);
456 if (!TREE_UNSIGNED (TYPE_MAIN_VARIANT (t
)) && TREE_UNSIGNED (t
))
457 output_add_string (scratch_buffer
, "unsigned ");
458 else if (TREE_UNSIGNED (TYPE_MAIN_VARIANT (t
)) && !TREE_UNSIGNED (t
))
459 output_add_string (scratch_buffer
, "signed ");
467 dump_qualifiers (t
, after
);
468 type
= flags
& TFF_CHASE_TYPEDEF
? TYPE_MAIN_VARIANT (t
) : t
;
469 if (TYPE_NAME (type
) && TYPE_IDENTIFIER (type
))
470 print_tree_identifier (scratch_buffer
, TYPE_IDENTIFIER (type
));
472 /* Types like intQI_type_node and friends have no names.
473 These don't come up in user error messages, but it's nice
474 to be able to print them from the debugger. */
475 print_identifier (scratch_buffer
, "<anonymous>");
479 case TEMPLATE_TEMPLATE_PARM
:
480 /* For parameters inside template signature. */
481 if (TYPE_IDENTIFIER (t
))
482 print_tree_identifier (scratch_buffer
, TYPE_IDENTIFIER (t
));
485 (scratch_buffer
, "<anonymous template template parameter>");
488 case BOUND_TEMPLATE_TEMPLATE_PARM
:
490 tree args
= TYPE_TI_ARGS (t
);
491 print_tree_identifier (scratch_buffer
, TYPE_IDENTIFIER (t
));
492 print_template_argument_list_start (scratch_buffer
);
493 dump_template_argument_list (args
, flags
);
494 print_template_argument_list_end (scratch_buffer
);
498 case TEMPLATE_TYPE_PARM
:
499 dump_qualifiers (t
, after
);
500 if (TYPE_IDENTIFIER (t
))
501 print_tree_identifier (scratch_buffer
, TYPE_IDENTIFIER (t
));
504 (scratch_buffer
, "<anonymous template type parameter>");
507 /* This is not always necessary for pointers and such, but doing this
508 reduces code size. */
517 dump_type_prefix (t
, flags
);
518 dump_type_suffix (t
, flags
);
522 output_add_string (scratch_buffer
, "typename ");
523 dump_typename (t
, flags
);
527 output_add_string (scratch_buffer
, "__typeof (");
528 dump_expr (TYPE_FIELDS (t
), flags
& ~TFF_EXPR_IN_PARENS
);
529 print_left_paren (scratch_buffer
);
533 sorry_for_unsupported_tree (t
);
534 /* Fall through to error. */
537 print_identifier (scratch_buffer
, "<type error>");
542 /* Dump a TYPENAME_TYPE. We need to notice when the context is itself
546 dump_typename (t
, flags
)
550 tree ctx
= TYPE_CONTEXT (t
);
552 if (TREE_CODE (ctx
) == TYPENAME_TYPE
)
553 dump_typename (ctx
, flags
);
555 dump_type (ctx
, flags
& ~TFF_CLASS_KEY_OR_ENUM
);
556 print_scope_operator (scratch_buffer
);
557 dump_decl (TYPENAME_TYPE_FULLNAME (t
), flags
);
560 /* Return the name of the supplied aggregate, or enumeral type. */
563 class_key_or_enum (t
)
566 if (TREE_CODE (t
) == ENUMERAL_TYPE
)
568 else if (TREE_CODE (t
) == UNION_TYPE
)
570 else if (TYPE_LANG_SPECIFIC (t
) && CLASSTYPE_DECLARED_CLASS (t
))
576 /* Print out a class declaration T under the control of FLAGS,
577 in the form `class foo'. */
580 dump_aggr_type (t
, flags
)
585 const char *variety
= class_key_or_enum (t
);
589 dump_qualifiers (t
, after
);
591 if (flags
& TFF_CLASS_KEY_OR_ENUM
)
593 print_identifier (scratch_buffer
, variety
);
594 output_add_space (scratch_buffer
);
597 if (flags
& TFF_CHASE_TYPEDEF
)
598 t
= TYPE_MAIN_VARIANT (t
);
600 name
= TYPE_NAME (t
);
604 typdef
= !DECL_ARTIFICIAL (name
);
605 tmplate
= !typdef
&& TREE_CODE (t
) != ENUMERAL_TYPE
606 && TYPE_LANG_SPECIFIC (t
) && CLASSTYPE_TEMPLATE_INFO (t
)
607 && (CLASSTYPE_TEMPLATE_SPECIALIZATION (t
)
608 || TREE_CODE (CLASSTYPE_TI_TEMPLATE (t
)) != TEMPLATE_DECL
609 || DECL_TEMPLATE_SPECIALIZATION (CLASSTYPE_TI_TEMPLATE (t
))
610 || PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t
)));
611 dump_scope (CP_DECL_CONTEXT (name
), flags
| TFF_SCOPE
);
614 /* Because the template names are mangled, we have to locate
615 the most general template, and use that name. */
616 tree tpl
= CLASSTYPE_TI_TEMPLATE (t
);
618 while (DECL_TEMPLATE_INFO (tpl
))
619 tpl
= DECL_TI_TEMPLATE (tpl
);
622 name
= DECL_NAME (name
);
625 if (name
== 0 || ANON_AGGRNAME_P (name
))
627 if (flags
& TFF_CLASS_KEY_OR_ENUM
)
628 print_identifier (scratch_buffer
, "<anonymous>");
630 output_printf (scratch_buffer
, "<anonymous %s>", variety
);
633 print_tree_identifier (scratch_buffer
, name
);
635 dump_template_parms (TYPE_TEMPLATE_INFO (t
),
636 !CLASSTYPE_USE_TEMPLATE (t
),
637 flags
& ~TFF_TEMPLATE_HEADER
);
640 /* Dump into the obstack the initial part of the output for a given type.
641 This is necessary when dealing with things like functions returning
644 return type of `int (* fee ())()': pointer -> function -> int. Both
645 pointer (and reference and offset) and function (and member) types must
646 deal with prefix and suffix.
648 Arrays must also do this for DECL nodes, like int a[], and for things like
651 Return indicates how you should pad an object name after this. I.e. you
652 want to pad non-*, non-& cores, but not pad * or & types. */
655 dump_type_prefix (t
, flags
)
659 enum pad padding
= before
;
661 if (TYPE_PTRMEMFUNC_P (t
))
663 t
= TYPE_PTRMEMFUNC_FN_TYPE (t
);
667 switch (TREE_CODE (t
))
672 tree sub
= TREE_TYPE (t
);
674 padding
= dump_type_prefix (sub
, flags
);
675 /* A tree for a member pointer looks like pointer to offset,
676 so let the OFFSET_TYPE case handle it. */
677 if (!TYPE_PTRMEM_P (t
))
679 if (TREE_CODE (sub
) == ARRAY_TYPE
)
681 output_add_space (scratch_buffer
);
682 print_left_paren (scratch_buffer
);
685 (scratch_buffer
, "&*"[TREE_CODE (t
) == POINTER_TYPE
]);
686 padding
= dump_qualifiers (t
, before
);
693 padding
= dump_type_prefix (TREE_TYPE (t
), flags
);
694 if (TREE_CODE (t
) == OFFSET_TYPE
) /* pmfs deal with this in d_t_p */
697 output_add_space (scratch_buffer
);
698 dump_type (TYPE_OFFSET_BASETYPE (t
), flags
);
699 print_scope_operator (scratch_buffer
);
701 output_add_character (scratch_buffer
, '*');
702 padding
= dump_qualifiers (t
, none
);
705 /* Can only be reached through function pointer -- this would not be
706 correct if FUNCTION_DECLs used it. */
708 padding
= dump_type_prefix (TREE_TYPE (t
), flags
);
710 output_add_space (scratch_buffer
);
711 print_left_paren (scratch_buffer
);
716 padding
= dump_type_prefix (TREE_TYPE (t
), flags
);
718 output_add_space (scratch_buffer
);
719 print_left_paren (scratch_buffer
);
721 dump_aggr_type (TYPE_METHOD_BASETYPE (t
), flags
);
722 print_scope_operator (scratch_buffer
);
726 padding
= dump_type_prefix (TREE_TYPE (t
), flags
);
730 case IDENTIFIER_NODE
:
735 case TEMPLATE_TYPE_PARM
:
736 case TEMPLATE_TEMPLATE_PARM
:
737 case BOUND_TEMPLATE_TEMPLATE_PARM
:
747 dump_type (t
, flags
);
752 sorry_for_unsupported_tree (t
);
755 print_identifier (scratch_buffer
, "<typeprefixerror>");
761 /* Dump the suffix of type T, under control of FLAGS. This is the part
762 which appears after the identifier (or function parms). */
765 dump_type_suffix (t
, flags
)
769 if (TYPE_PTRMEMFUNC_P (t
))
770 t
= TYPE_PTRMEMFUNC_FN_TYPE (t
);
772 switch (TREE_CODE (t
))
777 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
778 print_right_paren (scratch_buffer
);
779 dump_type_suffix (TREE_TYPE (t
), flags
);
782 /* Can only be reached through function pointer */
787 print_right_paren (scratch_buffer
);
788 arg
= TYPE_ARG_TYPES (t
);
789 if (TREE_CODE (t
) == METHOD_TYPE
)
790 arg
= TREE_CHAIN (arg
);
792 /* Function pointers don't have default args. Not in standard C++,
793 anyway; they may in g++, but we'll just pretend otherwise. */
794 dump_parameters (arg
, flags
& ~TFF_FUNCTION_DEFAULT_ARGUMENTS
);
796 if (TREE_CODE (t
) == METHOD_TYPE
)
798 (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t
))), before
);
799 dump_type_suffix (TREE_TYPE (t
), flags
);
800 dump_exception_spec (TYPE_RAISES_EXCEPTIONS (t
), flags
);
805 print_left_bracket (scratch_buffer
);
808 if (host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (t
)), 0))
811 tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (t
)), 0) + 1);
812 else if (TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (t
))) == MINUS_EXPR
)
813 dump_expr (TREE_OPERAND (TYPE_MAX_VALUE (TYPE_DOMAIN (t
)), 0),
814 flags
& ~TFF_EXPR_IN_PARENS
);
816 dump_expr (fold (cp_build_binary_op
817 (PLUS_EXPR
, TYPE_MAX_VALUE (TYPE_DOMAIN (t
)),
819 flags
& ~TFF_EXPR_IN_PARENS
);
821 print_right_bracket (scratch_buffer
);
822 dump_type_suffix (TREE_TYPE (t
), flags
);
826 case IDENTIFIER_NODE
:
831 case TEMPLATE_TYPE_PARM
:
832 case TEMPLATE_TEMPLATE_PARM
:
833 case BOUND_TEMPLATE_TEMPLATE_PARM
:
846 sorry_for_unsupported_tree (t
);
848 /* Don't mark it here, we should have already done in
854 /* Return a function declaration which corresponds to the IDENTIFIER_NODE
861 tree n
= lookup_name (t
, 0);
866 if (TREE_CODE (n
) == FUNCTION_DECL
)
868 else if (TREE_CODE (n
) == TREE_LIST
869 && TREE_CODE (TREE_VALUE (n
)) == FUNCTION_DECL
)
870 return TREE_VALUE (n
);
872 my_friendly_abort (66);
876 #define GLOBAL_THING "_GLOBAL__"
882 const char *p
= NULL
;
884 if (DECL_GLOBAL_CTOR_P (t
))
886 else if (DECL_GLOBAL_DTOR_P (t
))
889 my_friendly_abort (352);
891 output_printf (scratch_buffer
, "(static %s for %s)", p
, input_filename
);
895 dump_simple_decl (t
, type
, flags
)
900 if (flags
& TFF_DECL_SPECIFIERS
)
902 if (dump_type_prefix (type
, flags
) != none
)
903 output_add_space (scratch_buffer
);
905 if (!DECL_INITIAL (t
) || TREE_CODE (DECL_INITIAL (t
)) != TEMPLATE_PARM_INDEX
)
906 dump_scope (CP_DECL_CONTEXT (t
), flags
);
908 dump_decl (DECL_NAME (t
), flags
);
910 print_identifier (scratch_buffer
, "<anonymous>");
911 if (flags
& TFF_DECL_SPECIFIERS
)
912 dump_type_suffix (type
, flags
);
915 /* Dump a human readable string for the decl T under control of FLAGS. */
925 switch (TREE_CODE (t
))
929 /* Don't say 'typedef class A' */
930 if (DECL_ARTIFICIAL (t
))
932 if ((flags
& TFF_DECL_SPECIFIERS
)
933 && TREE_CODE (TREE_TYPE (t
)) == TEMPLATE_TYPE_PARM
)
934 /* Say `class T' not just `T'. */
935 output_add_string (scratch_buffer
, "class ");
937 dump_type (TREE_TYPE (t
), flags
);
941 if (flags
& TFF_DECL_SPECIFIERS
)
942 output_add_string (scratch_buffer
, "typedef ");
943 dump_simple_decl (t
, DECL_ORIGINAL_TYPE (t
)
944 ? DECL_ORIGINAL_TYPE (t
) : TREE_TYPE (t
),
949 if (DECL_NAME (t
) && VTABLE_NAME_P (DECL_NAME (t
)))
951 output_add_string (scratch_buffer
, "vtable for ");
952 if (TYPE_P (DECL_CONTEXT (t
)))
953 dump_type (DECL_CONTEXT (t
), flags
);
955 /* This case can arise with -fno-vtable-thunks. See
956 expand_upcast_fixups. It's not clear what to print
958 print_identifier (scratch_buffer
, "<unknown type>");
961 /* else fall through */
964 dump_simple_decl (t
, TREE_TYPE (t
), flags
);
968 output_add_string (scratch_buffer
, "<return value> ");
969 dump_simple_decl (t
, TREE_TYPE (t
), flags
);
973 dump_scope (CP_DECL_CONTEXT (t
), flags
);
974 if (DECL_NAME (t
) == anonymous_namespace_name
)
975 print_identifier (scratch_buffer
, "<unnamed>");
977 print_tree_identifier (scratch_buffer
, DECL_NAME (t
));
981 dump_decl (TREE_OPERAND (t
, 0), flags
& ~TFF_DECL_SPECIFIERS
);
982 print_scope_operator (scratch_buffer
);
983 dump_decl (TREE_OPERAND (t
, 1), flags
);
987 dump_decl (TREE_OPERAND (t
, 0), flags
);
988 print_left_bracket (scratch_buffer
);
989 dump_decl (TREE_OPERAND (t
, 1), flags
);
990 print_right_bracket (scratch_buffer
);
993 /* So that we can do dump_decl on an aggr type. */
997 dump_type (t
, flags
);
1001 my_friendly_abort (69);
1004 /* These special cases are duplicated here so that other functions
1005 can feed identifiers to cp_error and get them demangled properly. */
1006 case IDENTIFIER_NODE
:
1008 if (DESTRUCTOR_NAME_P (t
)
1009 && (f
= ident_fndecl (t
))
1010 && DECL_LANGUAGE (f
) == lang_cplusplus
)
1012 output_add_character (scratch_buffer
, '~');
1013 dump_decl (DECL_NAME (f
), flags
);
1015 else if (IDENTIFIER_TYPENAME_P (t
))
1017 output_add_string (scratch_buffer
, "operator ");
1018 /* Not exactly IDENTIFIER_TYPE_VALUE. */
1019 dump_type (TREE_TYPE (t
), flags
);
1023 print_tree_identifier (scratch_buffer
, t
);
1028 t
= OVL_CURRENT (t
);
1032 if (DECL_GLOBAL_CTOR_P (t
) || DECL_GLOBAL_DTOR_P (t
))
1033 dump_global_iord (t
);
1034 else if (! DECL_LANG_SPECIFIC (t
))
1035 print_identifier (scratch_buffer
, "<internal>");
1037 dump_function_decl (t
, flags
);
1041 dump_template_decl (t
, flags
);
1044 case TEMPLATE_ID_EXPR
:
1047 tree name
= TREE_OPERAND (t
, 0);
1048 if (is_overloaded_fn (name
))
1049 name
= DECL_NAME (get_first_fn (name
));
1050 dump_decl (name
, flags
);
1051 print_template_argument_list_start (scratch_buffer
);
1052 for (args
= TREE_OPERAND (t
, 1); args
; args
= TREE_CHAIN (args
))
1054 dump_template_argument (TREE_VALUE (args
), flags
);
1055 if (TREE_CHAIN (args
))
1056 separate_with_comma (scratch_buffer
);
1058 print_template_argument_list_end (scratch_buffer
);
1063 dump_decl (TREE_OPERAND (t
, 0), flags
);
1067 print_tree_identifier (scratch_buffer
, DECL_NAME (t
));
1071 if ((TREE_TYPE (t
) != NULL_TREE
&& NEXT_CODE (t
) == ENUMERAL_TYPE
)
1072 || (DECL_INITIAL (t
) &&
1073 TREE_CODE (DECL_INITIAL (t
)) == TEMPLATE_PARM_INDEX
))
1074 dump_simple_decl (t
, TREE_TYPE (t
), flags
);
1075 else if (DECL_NAME (t
))
1076 dump_decl (DECL_NAME (t
), flags
);
1077 else if (DECL_INITIAL (t
))
1078 dump_expr (DECL_INITIAL (t
), flags
| TFF_EXPR_IN_PARENS
);
1080 print_identifier (scratch_buffer
, "enumerator");
1084 output_add_string (scratch_buffer
, "using ");
1085 dump_type (DECL_INITIAL (t
), flags
);
1086 print_scope_operator (scratch_buffer
);
1087 print_tree_identifier (scratch_buffer
, DECL_NAME (t
));
1091 sorry_for_unsupported_tree (t
);
1092 /* Fallthrough to error. */
1095 print_identifier (scratch_buffer
, "<declaration error>");
1100 /* Dump a template declaration T under control of FLAGS. This means the
1101 'template <...> leaders plus the 'class X' or 'void fn(...)' part. */
1104 dump_template_decl (t
, flags
)
1108 tree orig_parms
= DECL_TEMPLATE_PARMS (t
);
1112 if (flags
& TFF_TEMPLATE_HEADER
)
1114 for (parms
= orig_parms
= nreverse (orig_parms
);
1116 parms
= TREE_CHAIN (parms
))
1118 tree inner_parms
= INNERMOST_TEMPLATE_PARMS (parms
);
1119 int len
= TREE_VEC_LENGTH (inner_parms
);
1121 output_add_string (scratch_buffer
, "template<");
1122 for (i
= 0; i
< len
; i
++)
1125 separate_with_comma (scratch_buffer
);
1126 dump_template_parameter (TREE_VEC_ELT (inner_parms
, i
), flags
);
1128 print_template_argument_list_end (scratch_buffer
);
1129 output_add_space (scratch_buffer
);
1131 nreverse(orig_parms
);
1132 /* If we've shown the template<args> prefix, we'd better show the
1134 flags
|= TFF_DECL_SPECIFIERS
;
1136 if (TREE_CODE (DECL_TEMPLATE_RESULT (t
)) == TYPE_DECL
)
1137 dump_type (TREE_TYPE (t
),
1138 ((flags
& ~TFF_CLASS_KEY_OR_ENUM
) | TFF_TEMPLATE_NAME
1139 | (flags
& TFF_DECL_SPECIFIERS
? TFF_CLASS_KEY_OR_ENUM
: 0)));
1140 else if (TREE_CODE (DECL_TEMPLATE_RESULT (t
)) == VAR_DECL
)
1141 dump_decl (DECL_TEMPLATE_RESULT (t
), flags
| TFF_TEMPLATE_NAME
);
1142 else if (TREE_TYPE (t
) == NULL_TREE
)
1143 my_friendly_abort (353);
1145 switch (NEXT_CODE (t
))
1149 dump_function_decl (t
, flags
| TFF_TEMPLATE_NAME
);
1152 /* This case can occur with some illegal code. */
1153 dump_type (TREE_TYPE (t
),
1154 (flags
& ~TFF_CLASS_KEY_OR_ENUM
) | TFF_TEMPLATE_NAME
1155 | (flags
& TFF_DECL_SPECIFIERS
? TFF_CLASS_KEY_OR_ENUM
: 0));
1159 /* Pretty print a function decl. There are several ways we want to print a
1160 function declaration. The TFF_ bits in FLAGS tells us how to behave.
1161 As cp_error can only apply the '#' flag once to give 0 and 1 for V, there
1162 is %D which doesn't print the throw specs, and %F which does. */
1165 dump_function_decl (t
, flags
)
1171 tree cname
= NULL_TREE
;
1172 tree template_args
= NULL_TREE
;
1173 tree template_parms
= NULL_TREE
;
1174 int show_return
= flags
& TFF_RETURN_TYPE
|| flags
& TFF_DECL_SPECIFIERS
;
1176 if (TREE_CODE (t
) == TEMPLATE_DECL
)
1177 t
= DECL_TEMPLATE_RESULT (t
);
1179 /* Pretty print template instantiations only. */
1180 if (DECL_USE_TEMPLATE (t
) && DECL_TEMPLATE_INFO (t
))
1184 template_args
= DECL_TI_ARGS (t
);
1185 tmpl
= most_general_template (t
);
1186 if (tmpl
&& TREE_CODE (tmpl
) == TEMPLATE_DECL
)
1188 template_parms
= DECL_TEMPLATE_PARMS (tmpl
);
1193 fntype
= TREE_TYPE (t
);
1194 parmtypes
= FUNCTION_FIRST_USER_PARMTYPE (t
);
1196 if (DECL_CLASS_SCOPE_P (t
))
1197 cname
= DECL_CONTEXT (t
);
1198 /* this is for partially instantiated template methods */
1199 else if (TREE_CODE (fntype
) == METHOD_TYPE
)
1200 cname
= TREE_TYPE (TREE_VALUE (parmtypes
));
1202 if (!(flags
& TFF_DECL_SPECIFIERS
))
1204 else if (DECL_STATIC_FUNCTION_P (t
))
1205 print_identifier (scratch_buffer
, "static ");
1206 else if (DECL_VIRTUAL_P (t
))
1207 print_identifier (scratch_buffer
, "virtual ");
1209 /* Print the return type? */
1211 show_return
= !DECL_CONV_FN_P (t
) && !DECL_CONSTRUCTOR_P (t
)
1212 && !DECL_DESTRUCTOR_P (t
);
1215 dump_type_prefix (TREE_TYPE (fntype
), flags
);
1216 output_add_space (scratch_buffer
);
1219 /* Print the function name. */
1222 dump_type (cname
, flags
);
1223 print_scope_operator (scratch_buffer
);
1226 dump_scope (CP_DECL_CONTEXT (t
), flags
);
1228 dump_function_name (t
, flags
);
1230 if (flags
& TFF_DECL_SPECIFIERS
)
1232 dump_parameters (parmtypes
, flags
);
1235 dump_type_suffix (TREE_TYPE (fntype
), flags
);
1237 if (TREE_CODE (fntype
) == METHOD_TYPE
)
1238 dump_qualifiers (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype
))),
1241 if (flags
& TFF_EXCEPTION_SPECIFICATION
)
1242 dump_exception_spec (TYPE_RAISES_EXCEPTIONS (fntype
), flags
);
1245 /* If T is a template instantiation, dump the parameter binding. */
1246 if (template_parms
!= NULL_TREE
&& template_args
!= NULL_TREE
)
1248 output_add_string (scratch_buffer
, " [with ");
1249 dump_template_bindings (template_parms
, template_args
);
1250 print_right_bracket (scratch_buffer
);
1254 /* Print a parameter list. If this is for a member function, the
1255 member object ptr (and any other hidden args) should have
1256 already been removed. */
1259 dump_parameters (parmtypes
, flags
)
1265 print_left_paren (scratch_buffer
);
1267 for (first
= 1; parmtypes
!= void_list_node
;
1268 parmtypes
= TREE_CHAIN (parmtypes
))
1271 separate_with_comma (scratch_buffer
);
1275 print_identifier (scratch_buffer
, "...");
1278 dump_type (TREE_VALUE (parmtypes
), flags
);
1280 if ((flags
& TFF_FUNCTION_DEFAULT_ARGUMENTS
) && TREE_PURPOSE (parmtypes
))
1282 output_add_string (scratch_buffer
, " = ");
1283 dump_expr (TREE_PURPOSE (parmtypes
), flags
| TFF_EXPR_IN_PARENS
);
1287 print_right_paren (scratch_buffer
);
1290 /* Print an exception specification. T is the exception specification. */
1293 dump_exception_spec (t
, flags
)
1299 output_add_string (scratch_buffer
, " throw (");
1300 if (TREE_VALUE (t
) != NULL_TREE
)
1303 dump_type (TREE_VALUE (t
), flags
);
1307 separate_with_comma (scratch_buffer
);
1309 print_right_paren (scratch_buffer
);
1313 /* Handle the function name for a FUNCTION_DECL node, grokking operators
1314 and destructors properly. */
1317 dump_function_name (t
, flags
)
1321 tree name
= DECL_NAME (t
);
1323 /* Don't let the user see __comp_ctor et al. */
1324 if (DECL_CONSTRUCTOR_P (t
)
1325 || DECL_DESTRUCTOR_P (t
))
1326 name
= constructor_name (DECL_CONTEXT (t
));
1328 if (DECL_DESTRUCTOR_P (t
))
1330 output_add_character (scratch_buffer
, '~');
1331 dump_decl (name
, TFF_PLAIN_IDENTIFIER
);
1333 else if (DECL_CONV_FN_P (t
))
1335 /* This cannot use the hack that the operator's return
1336 type is stashed off of its name because it may be
1337 used for error reporting. In the case of conflicting
1338 declarations, both will have the same name, yet
1339 the types will be different, hence the TREE_TYPE field
1340 of the first name will be clobbered by the second. */
1341 output_add_string (scratch_buffer
, "operator ");
1342 dump_type (TREE_TYPE (TREE_TYPE (t
)), flags
);
1344 else if (IDENTIFIER_OPNAME_P (name
))
1345 print_tree_identifier (scratch_buffer
, name
);
1347 dump_decl (name
, flags
);
1349 if (DECL_LANG_SPECIFIC (t
) && DECL_TEMPLATE_INFO (t
)
1350 && !DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t
)
1351 && (DECL_TEMPLATE_SPECIALIZATION (t
)
1352 || TREE_CODE (DECL_TI_TEMPLATE (t
)) != TEMPLATE_DECL
1353 || DECL_TEMPLATE_SPECIALIZATION (DECL_TI_TEMPLATE (t
))
1354 || PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t
))))
1355 dump_template_parms (DECL_TEMPLATE_INFO (t
), !DECL_USE_TEMPLATE (t
), flags
);
1358 /* Dump the template parameters from the template info INFO under control of
1359 FLAGS. PRIMARY indicates whether this is a primary template decl, or
1360 specialization (partial or complete). For partial specializations we show
1361 the specialized parameter values. For a primary template we show no
1365 dump_template_parms (info
, primary
, flags
)
1370 tree args
= info
? TI_ARGS (info
) : NULL_TREE
;
1372 if (primary
&& flags
& TFF_TEMPLATE_NAME
)
1374 flags
&= ~(TFF_CLASS_KEY_OR_ENUM
| TFF_TEMPLATE_NAME
);
1375 print_template_argument_list_start (scratch_buffer
);
1377 /* Be careful only to print things when we have them, so as not
1378 to crash producing error messages. */
1379 if (args
&& !primary
)
1385 if (TREE_CODE (args
) == TREE_VEC
)
1387 if (TREE_VEC_LENGTH (args
) > 0
1388 && TREE_CODE (TREE_VEC_ELT (args
, 0)) == TREE_VEC
)
1389 args
= TREE_VEC_ELT (args
, TREE_VEC_LENGTH (args
) - 1);
1391 len
= TREE_VEC_LENGTH (args
);
1393 else if (TREE_CODE (args
) == TREE_LIST
)
1395 while (ix
!= len
&& args
)
1400 arg
= TREE_VEC_ELT (args
, ix
);
1405 arg
= TREE_VALUE (args
);
1406 args
= TREE_CHAIN (args
);
1409 separate_with_comma (scratch_buffer
);
1412 print_identifier (scratch_buffer
, "<template parameter error>");
1414 dump_template_argument (arg
, flags
);
1420 tree tpl
= TI_TEMPLATE (info
);
1421 tree parms
= DECL_TEMPLATE_PARMS (tpl
);
1424 parms
= TREE_CODE (parms
) == TREE_LIST
? TREE_VALUE (parms
) : NULL_TREE
;
1425 len
= parms
? TREE_VEC_LENGTH (parms
) : 0;
1427 for (ix
= 0; ix
!= len
; ix
++)
1429 tree parm
= TREE_VALUE (TREE_VEC_ELT (parms
, ix
));
1432 separate_with_comma (scratch_buffer
);
1434 dump_decl (parm
, flags
& ~TFF_DECL_SPECIFIERS
);
1437 print_template_argument_list_end (scratch_buffer
);
1446 case TARGET_NEWLINE
:
1447 output_add_string (scratch_buffer
, "\\n");
1450 output_add_string (scratch_buffer
, "\\t");
1453 output_add_string (scratch_buffer
, "\\v");
1456 output_add_string (scratch_buffer
, "\\b");
1459 output_add_string (scratch_buffer
, "\\r");
1462 output_add_string (scratch_buffer
, "\\f");
1465 output_add_string (scratch_buffer
, "\\a");
1468 output_add_string (scratch_buffer
, "\\\\");
1471 output_add_string (scratch_buffer
, "\\'");
1474 output_add_string (scratch_buffer
, "\\\"");
1478 output_add_character (scratch_buffer
, c
);
1481 sprintf (digit_buffer
, "\\%03o", (int) c
);
1482 output_add_string (scratch_buffer
, digit_buffer
);
1487 /* Print out a list of initializers (subr of dump_expr) */
1490 dump_expr_list (l
, flags
)
1496 dump_expr (TREE_VALUE (l
), flags
| TFF_EXPR_IN_PARENS
);
1499 separate_with_comma (scratch_buffer
);
1503 /* Print out an expression E under control of FLAGS. */
1506 dump_expr (t
, flags
)
1510 switch (TREE_CODE (t
))
1518 case NAMESPACE_DECL
:
1520 dump_decl (t
, flags
& ~TFF_DECL_SPECIFIERS
);
1525 tree type
= TREE_TYPE (t
);
1526 my_friendly_assert (type
!= 0, 81);
1528 /* If it's an enum, output its tag, rather than its value. */
1529 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
1531 tree values
= TYPE_VALUES (type
);
1534 values
= TREE_CHAIN (values
))
1535 if (tree_int_cst_equal (TREE_VALUE (values
), t
))
1539 print_tree_identifier (scratch_buffer
, TREE_PURPOSE (values
));
1542 /* Value must have been cast. */
1543 print_left_paren (scratch_buffer
);
1544 dump_type (type
, flags
);
1545 print_right_paren (scratch_buffer
);
1549 else if (type
== boolean_type_node
)
1551 if (t
== boolean_false_node
|| integer_zerop (t
))
1552 print_identifier (scratch_buffer
, "false");
1553 else if (t
== boolean_true_node
)
1554 print_identifier (scratch_buffer
, "true");
1556 else if (type
== char_type_node
)
1558 output_add_character (scratch_buffer
, '\'');
1559 dump_char (tree_low_cst (t
, 0));
1560 output_add_character (scratch_buffer
, '\'');
1565 if (! host_integerp (t
, 0))
1569 if (tree_int_cst_sgn (val
) < 0)
1571 output_add_character (scratch_buffer
, '-');
1572 val
= build_int_2 (-TREE_INT_CST_LOW (val
),
1573 ~TREE_INT_CST_HIGH (val
)
1574 + !TREE_INT_CST_LOW (val
));
1576 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
1579 static char format
[10]; /* "%x%09999x\0" */
1581 sprintf (format
, "%%x%%0%dx", HOST_BITS_PER_INT
/ 4);
1582 sprintf (digit_buffer
, format
, TREE_INT_CST_HIGH (val
),
1583 TREE_INT_CST_LOW (val
));
1584 output_add_string (scratch_buffer
, digit_buffer
);
1588 print_integer (scratch_buffer
, TREE_INT_CST_LOW (t
));
1594 #ifndef REAL_IS_NOT_DOUBLE
1595 sprintf (digit_buffer
, "%g", TREE_REAL_CST (t
));
1598 const unsigned char *p
= (const unsigned char *) &TREE_REAL_CST (t
);
1600 strcpy (digit_buffer
, "0x");
1601 for (i
= 0; i
< sizeof TREE_REAL_CST (t
); i
++)
1602 sprintf (digit_buffer
+ 2 + 2*i
, "%02x", *p
++);
1605 output_add_string (scratch_buffer
, digit_buffer
);
1609 output_add_character (scratch_buffer
, '&');
1610 dump_type (PTRMEM_CST_CLASS (t
), flags
);
1611 print_scope_operator (scratch_buffer
);
1612 print_tree_identifier
1613 (scratch_buffer
, DECL_NAME (PTRMEM_CST_MEMBER (t
)));
1618 const char *p
= TREE_STRING_POINTER (t
);
1619 int len
= TREE_STRING_LENGTH (t
) - 1;
1622 output_add_character (scratch_buffer
, '\"');
1623 for (i
= 0; i
< len
; i
++)
1625 output_add_character (scratch_buffer
, '\"');
1630 print_left_paren (scratch_buffer
);
1631 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1632 separate_with_comma (scratch_buffer
);
1633 dump_expr (TREE_OPERAND (t
, 1), flags
| TFF_EXPR_IN_PARENS
);
1634 print_right_paren (scratch_buffer
);
1638 print_left_paren (scratch_buffer
);
1639 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1640 output_add_string (scratch_buffer
, " ? ");
1641 dump_expr (TREE_OPERAND (t
, 1), flags
| TFF_EXPR_IN_PARENS
);
1642 output_add_string (scratch_buffer
, " : ");
1643 dump_expr (TREE_OPERAND (t
, 2), flags
| TFF_EXPR_IN_PARENS
);
1644 print_right_paren (scratch_buffer
);
1648 if (TREE_HAS_CONSTRUCTOR (t
))
1650 output_add_string (scratch_buffer
, "new ");
1651 dump_type (TREE_TYPE (TREE_TYPE (t
)), flags
);
1655 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1659 case AGGR_INIT_EXPR
:
1661 tree fn
= NULL_TREE
;
1663 if (TREE_CODE (TREE_OPERAND (t
, 0)) == ADDR_EXPR
)
1664 fn
= TREE_OPERAND (TREE_OPERAND (t
, 0), 0);
1666 if (fn
&& TREE_CODE (fn
) == FUNCTION_DECL
)
1668 if (DECL_CONSTRUCTOR_P (fn
))
1669 print_tree_identifier
1670 (scratch_buffer
, TYPE_IDENTIFIER (TREE_TYPE (t
)));
1675 dump_expr (TREE_OPERAND (t
, 0), 0);
1677 print_left_paren (scratch_buffer
);
1678 if (TREE_OPERAND (t
, 1))
1679 dump_expr_list (TREE_CHAIN (TREE_OPERAND (t
, 1)), flags
);
1680 print_right_paren (scratch_buffer
);
1685 tree fn
= TREE_OPERAND (t
, 0);
1686 tree args
= TREE_OPERAND (t
, 1);
1688 if (TREE_CODE (fn
) == ADDR_EXPR
)
1689 fn
= TREE_OPERAND (fn
, 0);
1691 if (TREE_TYPE (fn
) != NULL_TREE
&& NEXT_CODE (fn
) == METHOD_TYPE
)
1693 tree ob
= TREE_VALUE (args
);
1694 if (TREE_CODE (ob
) == ADDR_EXPR
)
1696 dump_expr (TREE_OPERAND (ob
, 0), flags
| TFF_EXPR_IN_PARENS
);
1697 output_add_character (scratch_buffer
, '.');
1699 else if (TREE_CODE (ob
) != PARM_DECL
1700 || strcmp (IDENTIFIER_POINTER (DECL_NAME (ob
)), "this"))
1702 dump_expr (ob
, flags
| TFF_EXPR_IN_PARENS
);
1703 output_add_string (scratch_buffer
, "->");
1705 args
= TREE_CHAIN (args
);
1707 dump_expr (fn
, flags
| TFF_EXPR_IN_PARENS
);
1708 print_left_paren (scratch_buffer
);
1709 dump_expr_list (args
, flags
);
1710 print_right_paren (scratch_buffer
);
1716 tree type
= TREE_OPERAND (t
, 1);
1717 if (NEW_EXPR_USE_GLOBAL (t
))
1718 print_scope_operator (scratch_buffer
);
1719 output_add_string (scratch_buffer
, "new ");
1720 if (TREE_OPERAND (t
, 0))
1722 print_left_paren (scratch_buffer
);
1723 dump_expr_list (TREE_OPERAND (t
, 0), flags
);
1724 output_add_string (scratch_buffer
, ") ");
1726 if (TREE_CODE (type
) == ARRAY_REF
)
1727 type
= build_cplus_array_type
1728 (TREE_OPERAND (type
, 0),
1729 build_index_type (fold (build (MINUS_EXPR
, integer_type_node
,
1730 TREE_OPERAND (type
, 1),
1731 integer_one_node
))));
1732 dump_type (type
, flags
);
1733 if (TREE_OPERAND (t
, 2))
1735 print_left_paren (scratch_buffer
);
1736 dump_expr_list (TREE_OPERAND (t
, 2), flags
);
1737 print_right_paren (scratch_buffer
);
1743 /* Note that this only works for G++ target exprs. If somebody
1744 builds a general TARGET_EXPR, there's no way to represent that
1745 it initializes anything other that the parameter slot for the
1746 default argument. Note we may have cleared out the first
1747 operand in expand_expr, so don't go killing ourselves. */
1748 if (TREE_OPERAND (t
, 1))
1749 dump_expr (TREE_OPERAND (t
, 1), flags
| TFF_EXPR_IN_PARENS
);
1757 case TRUNC_DIV_EXPR
:
1758 case TRUNC_MOD_EXPR
:
1766 case BIT_ANDTC_EXPR
:
1767 case TRUTH_ANDIF_EXPR
:
1768 case TRUTH_ORIF_EXPR
:
1775 case EXACT_DIV_EXPR
:
1776 dump_binary_op (operator_name_info
[(int) TREE_CODE (t
)].name
, t
, flags
);
1780 case FLOOR_DIV_EXPR
:
1781 case ROUND_DIV_EXPR
:
1782 dump_binary_op ("/", t
, flags
);
1786 case FLOOR_MOD_EXPR
:
1787 case ROUND_MOD_EXPR
:
1788 dump_binary_op ("%", t
, flags
);
1793 tree ob
= TREE_OPERAND (t
, 0);
1794 if (TREE_CODE (ob
) == INDIRECT_REF
)
1796 ob
= TREE_OPERAND (ob
, 0);
1797 if (TREE_CODE (ob
) != PARM_DECL
1798 || strcmp (IDENTIFIER_POINTER (DECL_NAME (ob
)), "this"))
1800 dump_expr (ob
, flags
| TFF_EXPR_IN_PARENS
);
1801 output_add_string (scratch_buffer
, "->");
1806 dump_expr (ob
, flags
| TFF_EXPR_IN_PARENS
);
1807 output_add_character (scratch_buffer
, '.');
1809 dump_expr (TREE_OPERAND (t
, 1), flags
& ~TFF_EXPR_IN_PARENS
);
1814 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1815 print_left_bracket (scratch_buffer
);
1816 dump_expr (TREE_OPERAND (t
, 1), flags
| TFF_EXPR_IN_PARENS
);
1817 print_right_bracket (scratch_buffer
);
1821 if (VOID_TYPE_P (TREE_TYPE (t
)))
1823 print_left_paren (scratch_buffer
);
1824 dump_type (TREE_TYPE (t
), flags
);
1825 print_right_paren (scratch_buffer
);
1826 dump_expr (TREE_OPERAND (t
, 0), flags
);
1829 dump_unary_op ("+", t
, flags
);
1833 if (TREE_CODE (TREE_OPERAND (t
, 0)) == FUNCTION_DECL
1834 || TREE_CODE (TREE_OPERAND (t
, 0)) == STRING_CST
1835 /* An ADDR_EXPR can have reference type. In that case, we
1836 shouldn't print the `&' doing so indicates to the user
1837 that the expression has pointer type. */
1839 && TREE_CODE (TREE_TYPE (t
)) == REFERENCE_TYPE
))
1840 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1842 dump_unary_op ("&", t
, flags
);
1846 if (TREE_HAS_CONSTRUCTOR (t
))
1848 t
= TREE_OPERAND (t
, 0);
1849 my_friendly_assert (TREE_CODE (t
) == CALL_EXPR
, 237);
1850 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1851 print_left_paren (scratch_buffer
);
1852 dump_expr_list (TREE_CHAIN (TREE_OPERAND (t
, 1)), flags
);
1853 print_right_paren (scratch_buffer
);
1857 if (TREE_OPERAND (t
,0) != NULL_TREE
1858 && TREE_TYPE (TREE_OPERAND (t
, 0))
1859 && NEXT_CODE (TREE_OPERAND (t
, 0)) == REFERENCE_TYPE
)
1860 dump_expr (TREE_OPERAND (t
, 0), flags
);
1862 dump_unary_op ("*", t
, flags
);
1868 case TRUTH_NOT_EXPR
:
1869 case PREDECREMENT_EXPR
:
1870 case PREINCREMENT_EXPR
:
1871 dump_unary_op (operator_name_info
[(int)TREE_CODE (t
)].name
, t
, flags
);
1874 case POSTDECREMENT_EXPR
:
1875 case POSTINCREMENT_EXPR
:
1876 print_left_paren (scratch_buffer
);
1877 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1879 (scratch_buffer
, operator_name_info
[(int)TREE_CODE (t
)].name
);
1880 print_right_paren (scratch_buffer
);
1883 case NON_LVALUE_EXPR
:
1884 /* FIXME: This is a KLUDGE workaround for a parsing problem. There
1885 should be another level of INDIRECT_REF so that I don't have to do
1887 if (TREE_TYPE (t
) != NULL_TREE
&& NEXT_CODE (t
) == POINTER_TYPE
)
1889 tree next
= TREE_TYPE (TREE_TYPE (t
));
1891 while (TREE_CODE (next
) == POINTER_TYPE
)
1892 next
= TREE_TYPE (next
);
1894 if (TREE_CODE (next
) == FUNCTION_TYPE
)
1896 if (flags
& TFF_EXPR_IN_PARENS
)
1897 print_left_paren (scratch_buffer
);
1898 output_add_character (scratch_buffer
, '*');
1899 dump_expr (TREE_OPERAND (t
, 0), flags
& ~TFF_EXPR_IN_PARENS
);
1900 if (flags
& TFF_EXPR_IN_PARENS
)
1901 print_right_paren (scratch_buffer
);
1906 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1910 dump_expr (TREE_OPERAND (t
, 0), flags
);
1913 case EXPR_WITH_FILE_LOCATION
:
1914 dump_expr (EXPR_WFL_NODE (t
), flags
);
1918 if (TREE_TYPE (t
) && TYPE_PTRMEMFUNC_P (TREE_TYPE (t
)))
1920 tree idx
= build_component_ref (t
, index_identifier
, NULL_TREE
, 0);
1922 if (integer_all_onesp (idx
))
1924 tree pfn
= PFN_FROM_PTRMEMFUNC (t
);
1925 dump_unary_op ("&", pfn
, flags
| TFF_EXPR_IN_PARENS
);
1928 else if (TREE_CODE (idx
) == INTEGER_CST
1929 && tree_int_cst_equal (idx
, integer_zero_node
))
1931 /* A NULL pointer-to-member constant. */
1932 output_add_string (scratch_buffer
, "((");
1933 dump_type (TREE_TYPE (t
), flags
);
1934 output_add_string (scratch_buffer
, ") 0)");
1937 else if (host_integerp (idx
, 0))
1940 unsigned HOST_WIDE_INT n
;
1942 t
= TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (t
)));
1943 t
= TYPE_METHOD_BASETYPE (t
);
1944 virtuals
= TYPE_BINFO_VIRTUALS (TYPE_MAIN_VARIANT (t
));
1946 n
= tree_low_cst (idx
, 0);
1948 /* Map vtable index back one, to allow for the null pointer to
1952 while (n
> 0 && virtuals
)
1955 virtuals
= TREE_CHAIN (virtuals
);
1959 dump_expr (BV_FN (virtuals
),
1960 flags
| TFF_EXPR_IN_PARENS
);
1965 output_add_character (scratch_buffer
, '{');
1966 dump_expr_list (CONSTRUCTOR_ELTS (t
), flags
);
1967 output_add_character (scratch_buffer
, '}');
1972 tree ob
= TREE_OPERAND (t
, 0);
1973 if (is_dummy_object (ob
))
1975 t
= TREE_OPERAND (t
, 1);
1976 if (TREE_CODE (t
) == FUNCTION_DECL
)
1978 dump_expr (t
, flags
| TFF_EXPR_IN_PARENS
);
1979 else if (BASELINK_P (t
))
1980 dump_expr (OVL_CURRENT (TREE_VALUE (t
)), flags
| TFF_EXPR_IN_PARENS
);
1982 dump_decl (t
, flags
);
1986 if (TREE_CODE (ob
) == INDIRECT_REF
)
1988 dump_expr (TREE_OPERAND (ob
, 0), flags
| TFF_EXPR_IN_PARENS
);
1989 output_add_string (scratch_buffer
, "->*");
1993 dump_expr (ob
, flags
| TFF_EXPR_IN_PARENS
);
1994 output_add_string (scratch_buffer
, ".*");
1996 dump_expr (TREE_OPERAND (t
, 1), flags
| TFF_EXPR_IN_PARENS
);
2001 case TEMPLATE_PARM_INDEX
:
2002 dump_decl (TEMPLATE_PARM_DECL (t
), flags
& ~TFF_DECL_SPECIFIERS
);
2005 case IDENTIFIER_NODE
:
2006 print_tree_identifier (scratch_buffer
, t
);
2010 dump_type (TREE_OPERAND (t
, 0), flags
);
2011 print_scope_operator (scratch_buffer
);
2012 dump_expr (TREE_OPERAND (t
, 1), flags
| TFF_EXPR_IN_PARENS
);
2016 if (TREE_OPERAND (t
, 0) == NULL_TREE
2017 || TREE_CHAIN (TREE_OPERAND (t
, 0)))
2019 dump_type (TREE_TYPE (t
), flags
);
2020 print_left_paren (scratch_buffer
);
2021 dump_expr_list (TREE_OPERAND (t
, 0), flags
);
2022 print_right_paren (scratch_buffer
);
2026 print_left_paren (scratch_buffer
);
2027 dump_type (TREE_TYPE (t
), flags
);
2028 output_add_string (scratch_buffer
, ")(");
2029 dump_expr_list (TREE_OPERAND (t
, 0), flags
);
2030 print_right_paren (scratch_buffer
);
2034 case STATIC_CAST_EXPR
:
2035 output_add_string (scratch_buffer
, "static_cast<");
2037 case REINTERPRET_CAST_EXPR
:
2038 output_add_string (scratch_buffer
, "reinterpret_cast<");
2040 case CONST_CAST_EXPR
:
2041 output_add_string (scratch_buffer
, "const_cast<");
2043 case DYNAMIC_CAST_EXPR
:
2044 output_add_string (scratch_buffer
, "dynamic_cast<");
2046 dump_type (TREE_TYPE (t
), flags
);
2047 output_add_string (scratch_buffer
, ">(");
2048 dump_expr (TREE_OPERAND (t
, 0), flags
);
2049 print_right_paren (scratch_buffer
);
2053 print_tree_identifier (scratch_buffer
, TREE_OPERAND (t
, 0));
2057 dump_expr (TREE_OPERAND (t
, 0), flags
);
2058 output_add_string (scratch_buffer
, "->");
2063 if (TREE_CODE (t
) == SIZEOF_EXPR
)
2064 output_add_string (scratch_buffer
, "sizeof (");
2067 my_friendly_assert (TREE_CODE (t
) == ALIGNOF_EXPR
, 0);
2068 output_add_string (scratch_buffer
, "__alignof__ (");
2070 if (TYPE_P (TREE_OPERAND (t
, 0)))
2071 dump_type (TREE_OPERAND (t
, 0), flags
);
2073 dump_unary_op ("*", t
, flags
| TFF_EXPR_IN_PARENS
);
2074 print_right_paren (scratch_buffer
);
2078 print_identifier (scratch_buffer
, "<unparsed>");
2081 case TRY_CATCH_EXPR
:
2082 case WITH_CLEANUP_EXPR
:
2083 case CLEANUP_POINT_EXPR
:
2084 dump_expr (TREE_OPERAND (t
, 0), flags
);
2087 case PSEUDO_DTOR_EXPR
:
2088 dump_expr (TREE_OPERAND (t
, 2), flags
);
2089 output_add_character (scratch_buffer
, '.');
2090 dump_type (TREE_OPERAND (t
, 0), flags
);
2091 output_add_string (scratch_buffer
, "::~");
2092 dump_type (TREE_OPERAND (t
, 1), flags
);
2095 case TEMPLATE_ID_EXPR
:
2096 dump_decl (t
, flags
);
2100 /* We don't yet have a way of dumping statements in a
2101 human-readable format. */
2102 output_add_string (scratch_buffer
, "({...})");
2106 output_add_character (scratch_buffer
, '{');
2107 dump_expr (TREE_OPERAND (t
, 1), flags
& ~TFF_EXPR_IN_PARENS
);
2108 output_add_character (scratch_buffer
, '}');
2112 output_add_string (scratch_buffer
, "while (1) { ");
2113 dump_expr (TREE_OPERAND (t
, 0), flags
& ~TFF_EXPR_IN_PARENS
);
2114 output_add_character (scratch_buffer
, '}');
2118 output_add_string (scratch_buffer
, "if (");
2119 dump_expr (TREE_OPERAND (t
, 0), flags
& ~TFF_EXPR_IN_PARENS
);
2120 output_add_string (scratch_buffer
, ") break; ");
2124 if (TREE_VALUE (t
) && TREE_CODE (TREE_VALUE (t
)) == FUNCTION_DECL
)
2126 print_tree_identifier (scratch_buffer
, DECL_NAME (TREE_VALUE (t
)));
2129 /* else fall through */
2131 /* This list is incomplete, but should suffice for now.
2132 It is very important that `sorry' does not call
2133 `report_error_function'. That could cause an infinite loop. */
2135 sorry_for_unsupported_tree (t
);
2136 /* fall through to ERROR_MARK... */
2138 print_identifier (scratch_buffer
, "<expression error>");
2144 dump_binary_op (opstring
, t
, flags
)
2145 const char *opstring
;
2149 print_left_paren (scratch_buffer
);
2150 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
2151 output_add_space (scratch_buffer
);
2153 print_identifier (scratch_buffer
, opstring
);
2155 print_identifier (scratch_buffer
, "<unknown operator>");
2156 output_add_space (scratch_buffer
);
2157 dump_expr (TREE_OPERAND (t
, 1), flags
| TFF_EXPR_IN_PARENS
);
2158 print_right_paren (scratch_buffer
);
2162 dump_unary_op (opstring
, t
, flags
)
2163 const char *opstring
;
2167 if (flags
& TFF_EXPR_IN_PARENS
)
2168 print_left_paren (scratch_buffer
);
2169 print_identifier (scratch_buffer
, opstring
);
2170 dump_expr (TREE_OPERAND (t
, 0), flags
& ~TFF_EXPR_IN_PARENS
);
2171 if (flags
& TFF_EXPR_IN_PARENS
)
2172 print_right_paren (scratch_buffer
);
2175 /* Exported interface to stringifying types, exprs and decls under TFF_*
2179 type_as_string (typ
, flags
)
2183 reinit_global_formatting_buffer ();
2185 dump_type (typ
, flags
);
2187 return output_finalize_message (scratch_buffer
);
2191 expr_as_string (decl
, flags
)
2195 reinit_global_formatting_buffer ();
2197 dump_expr (decl
, flags
);
2199 return output_finalize_message (scratch_buffer
);
2203 decl_as_string (decl
, flags
)
2207 reinit_global_formatting_buffer ();
2209 dump_decl (decl
, flags
);
2211 return output_finalize_message (scratch_buffer
);
2215 context_as_string (context
, flags
)
2219 reinit_global_formatting_buffer ();
2221 dump_scope (context
, flags
);
2223 return output_finalize_message (scratch_buffer
);
2226 /* Generate the three forms of printable names for lang_printable_name. */
2229 lang_decl_name (decl
, v
)
2234 return decl_as_string (decl
, TFF_DECL_SPECIFIERS
);
2236 reinit_global_formatting_buffer ();
2238 if (v
== 1 && DECL_CLASS_SCOPE_P (decl
))
2240 dump_type (CP_DECL_CONTEXT (decl
), TFF_PLAIN_IDENTIFIER
);
2241 print_scope_operator (scratch_buffer
);
2244 if (TREE_CODE (decl
) == FUNCTION_DECL
)
2245 dump_function_name (decl
, TFF_PLAIN_IDENTIFIER
);
2247 dump_decl (DECL_NAME (decl
), TFF_PLAIN_IDENTIFIER
);
2249 return output_finalize_message (scratch_buffer
);
2256 if (TREE_CODE (t
) == PARM_DECL
&& DECL_CONTEXT (t
))
2257 return DECL_SOURCE_FILE (DECL_CONTEXT (t
));
2258 else if (TYPE_P (t
))
2259 return DECL_SOURCE_FILE (TYPE_MAIN_DECL (t
));
2260 else if (TREE_CODE (t
) == OVERLOAD
)
2261 return DECL_SOURCE_FILE (OVL_FUNCTION (t
));
2263 return DECL_SOURCE_FILE (t
);
2271 if (TREE_CODE (t
) == PARM_DECL
&& DECL_CONTEXT (t
))
2272 line
= DECL_SOURCE_LINE (DECL_CONTEXT (t
));
2273 if (TREE_CODE (t
) == TYPE_DECL
&& DECL_ARTIFICIAL (t
)
2274 && TYPE_MAIN_DECL (TREE_TYPE (t
)))
2278 line
= DECL_SOURCE_LINE (TYPE_MAIN_DECL (t
));
2279 else if (TREE_CODE (t
) == OVERLOAD
)
2280 line
= DECL_SOURCE_LINE (OVL_FUNCTION (t
));
2282 line
= DECL_SOURCE_LINE (t
);
2290 /* Now the interfaces from cp_error et al to dump_type et al. Each takes an
2291 on/off VERBOSE flag and supply the appropriate TFF_ flags to a dump_
2295 decl_to_string (decl
, verbose
)
2301 if (TREE_CODE (decl
) == TYPE_DECL
|| TREE_CODE (decl
) == RECORD_TYPE
2302 || TREE_CODE (decl
) == UNION_TYPE
|| TREE_CODE (decl
) == ENUMERAL_TYPE
)
2303 flags
= TFF_CLASS_KEY_OR_ENUM
;
2305 flags
|= TFF_DECL_SPECIFIERS
| TFF_FUNCTION_DEFAULT_ARGUMENTS
;
2306 else if (TREE_CODE (decl
) == FUNCTION_DECL
)
2307 flags
|= TFF_DECL_SPECIFIERS
| TFF_RETURN_TYPE
;
2308 flags
|= TFF_TEMPLATE_HEADER
;
2310 reinit_global_formatting_buffer ();
2312 dump_decl (decl
, flags
);
2314 return output_finalize_message (scratch_buffer
);
2318 expr_to_string (decl
, verbose
)
2320 int verbose ATTRIBUTE_UNUSED
;
2322 reinit_global_formatting_buffer ();
2324 dump_expr (decl
, 0);
2326 return output_finalize_message (scratch_buffer
);
2330 fndecl_to_string (fndecl
, verbose
)
2336 flags
= TFF_EXCEPTION_SPECIFICATION
| TFF_DECL_SPECIFIERS
;
2338 flags
|= TFF_FUNCTION_DEFAULT_ARGUMENTS
;
2339 reinit_global_formatting_buffer ();
2341 dump_decl (fndecl
, flags
);
2343 return output_finalize_message (scratch_buffer
);
2348 code_to_string (c
, v
)
2350 int v ATTRIBUTE_UNUSED
;
2352 return tree_code_name
[c
];
2356 language_to_string (c
, v
)
2358 int v ATTRIBUTE_UNUSED
;
2365 case lang_cplusplus
:
2372 my_friendly_abort (355);
2377 /* Return the proper printed version of a parameter to a C++ function. */
2380 parm_to_string (p
, v
)
2382 int v ATTRIBUTE_UNUSED
;
2387 sprintf (digit_buffer
, "%d", p
+1);
2388 return digit_buffer
;
2394 int v ATTRIBUTE_UNUSED
;
2398 id
= operator_name_info
[(int) p
].identifier
;
2399 return id
? IDENTIFIER_POINTER (id
) : "{unknown}";
2403 type_to_string (typ
, verbose
)
2411 flags
|= TFF_CLASS_KEY_OR_ENUM
;
2412 flags
|= TFF_TEMPLATE_HEADER
;
2414 reinit_global_formatting_buffer ();
2416 dump_type (typ
, flags
);
2418 return output_finalize_message (scratch_buffer
);
2422 assop_to_string (p
, v
)
2424 int v ATTRIBUTE_UNUSED
;
2428 id
= assignment_operator_name_info
[(int) p
].identifier
;
2429 return id
? IDENTIFIER_POINTER (id
) : "{unknown}";
2433 args_to_string (p
, verbose
)
2439 flags
|= TFF_CLASS_KEY_OR_ENUM
;
2444 if (TYPE_P (TREE_VALUE (p
)))
2445 return type_as_string (p
, flags
);
2447 reinit_global_formatting_buffer ();
2448 for (; p
; p
= TREE_CHAIN (p
))
2450 if (TREE_VALUE (p
) == null_node
)
2451 print_identifier (scratch_buffer
, "NULL");
2453 dump_type (error_type (TREE_VALUE (p
)), flags
);
2455 separate_with_comma (scratch_buffer
);
2457 return output_finalize_message (scratch_buffer
);
2463 int v ATTRIBUTE_UNUSED
;
2465 reinit_global_formatting_buffer ();
2467 dump_qualifiers (p
, before
);
2469 return output_finalize_message (scratch_buffer
);
2473 lang_print_error_function (file
)
2478 default_print_error_function (file
);
2479 os
= output_buffer_state (diagnostic_buffer
);
2480 output_set_prefix (diagnostic_buffer
, file
);
2481 maybe_print_instantiation_context (diagnostic_buffer
);
2482 output_buffer_state (diagnostic_buffer
) = os
;
2486 cp_diagnostic_starter (buffer
, dc
)
2487 output_buffer
*buffer
;
2488 diagnostic_context
*dc
;
2490 report_problematic_module (buffer
);
2491 cp_print_error_function (buffer
, dc
);
2492 maybe_print_instantiation_context (buffer
);
2493 output_set_prefix (buffer
,
2494 context_as_prefix (diagnostic_file_location (dc
),
2495 diagnostic_line_location (dc
),
2496 diagnostic_is_warning (dc
)));
2500 cp_diagnostic_finalizer (buffer
, dc
)
2501 output_buffer
*buffer
;
2502 diagnostic_context
*dc
__attribute__ ((__unused__
));
2504 output_destroy_prefix (buffer
);
2507 /* Print current function onto BUFFER, in the process of reporting
2508 a diagnostic message. Called from cp_diagnostic_starter. */
2510 cp_print_error_function (buffer
, dc
)
2511 output_buffer
*buffer
;
2512 diagnostic_context
*dc
;
2514 if (error_function_changed ())
2516 char *prefix
= diagnostic_file_location (dc
)
2517 ? file_name_as_prefix (diagnostic_file_location (dc
))
2521 os
= output_buffer_state (buffer
);
2522 output_set_prefix (buffer
, prefix
);
2524 if (current_function_decl
== NULL
)
2525 output_add_string (buffer
, "At global scope:");
2528 (buffer
, "In %s `%s':", function_category (current_function_decl
),
2529 (*decl_printable_name
) (current_function_decl
, 2));
2530 output_add_newline (buffer
);
2532 record_last_error_function ();
2533 output_destroy_prefix (buffer
);
2534 output_buffer_state (buffer
) = os
;
2538 /* Returns a description of FUNCTION using standard terminology. */
2540 function_category (fn
)
2543 if (DECL_FUNCTION_MEMBER_P (fn
))
2545 if (DECL_STATIC_FUNCTION_P (fn
))
2546 return "static member function";
2547 else if (DECL_COPY_CONSTRUCTOR_P (fn
))
2548 return "copy constructor";
2549 else if (DECL_CONSTRUCTOR_P (fn
))
2550 return "constructor";
2551 else if (DECL_DESTRUCTOR_P (fn
))
2552 return "destructor";
2554 return "member function";
2560 /* Report the full context of a current template instantiation,
2563 print_instantiation_full_context (buffer
)
2564 output_buffer
*buffer
;
2566 tree p
= current_instantiation ();
2568 const char *file
= input_filename
;
2572 if (current_function_decl
!= TINST_DECL (p
)
2573 && current_function_decl
!= NULL_TREE
)
2574 /* We can get here during the processing of some synthesized
2575 method. Then, TINST_DECL (p) will be the function that's causing
2580 if (current_function_decl
== TINST_DECL (p
))
2581 /* Avoid redundancy with the the "In function" line. */;
2583 output_verbatim (buffer
, "%s: In instantiation of `%s':\n", file
,
2584 decl_as_string (TINST_DECL (p
),
2585 TFF_DECL_SPECIFIERS
| TFF_RETURN_TYPE
));
2587 line
= TINST_LINE (p
);
2588 file
= TINST_FILE (p
);
2593 print_instantiation_partial_context (buffer
, p
, file
, line
);
2596 /* Same as above but less verbose. */
2598 print_instantiation_partial_context (buffer
, t
, file
, line
)
2599 output_buffer
*buffer
;
2604 for (; t
; t
= TREE_CHAIN (t
))
2607 (buffer
, "%s:%d: instantiated from `%s'\n", file
, line
,
2608 decl_as_string (TINST_DECL (t
), TFF_DECL_SPECIFIERS
| TFF_RETURN_TYPE
));
2609 line
= TINST_LINE (t
);
2610 file
= TINST_FILE (t
);
2612 output_verbatim (buffer
, "%s:%d: instantiated from here\n", file
, line
);
2615 /* Called from cp_thing to print the template context for an error. */
2617 maybe_print_instantiation_context (buffer
)
2618 output_buffer
*buffer
;
2620 if (!problematic_instantiation_changed () || current_instantiation () == 0)
2623 record_last_problematic_instantiation ();
2624 print_instantiation_full_context (buffer
);
2627 /* Report the bare minimum context of a template instantiation. */
2629 print_instantiation_context ()
2631 print_instantiation_partial_context
2632 (diagnostic_buffer
, current_instantiation (), input_filename
, lineno
);
2633 flush_diagnostic_buffer ();
2636 /* Called from output_format -- during diagnostic message processing --
2637 to handle C++ specific format specifier with the following meanings:
2638 %A function argument-list.
2641 %F function declaration.
2642 %P function parameter whose position is indicated by an integer.
2646 cp_tree_printer (buffer
)
2647 output_buffer
*buffer
;
2650 tree_formatting_info tfi
;
2652 memset (&tfi
, 0, sizeof (tree_formatting_info
));
2654 if (*output_buffer_text_cursor (buffer
) == '+')
2655 ++output_buffer_text_cursor (buffer
);
2656 if (*output_buffer_text_cursor (buffer
) == '#')
2659 ++output_buffer_text_cursor (buffer
);
2662 switch (*output_buffer_text_cursor (buffer
))
2665 tree_being_formatted (&tfi
) =
2666 va_arg (output_buffer_format_args (buffer
), tree
);
2668 tree_formatting_flags (&tfi
) = TFF_SCOPE
2669 | TFF_FUNCTION_DEFAULT_ARGUMENTS
;
2670 print_function_argument_list (buffer
, &tfi
);
2674 tree_being_formatted (&tfi
) =
2675 va_arg (output_buffer_format_args (buffer
), tree
);
2677 tree_formatting_flags (&tfi
) = TFF_SCOPE
| TFF_DECL_SPECIFIERS
2678 | TFF_CLASS_KEY_OR_ENUM
| TFF_RETURN_TYPE
2679 | TFF_FUNCTION_DEFAULT_ARGUMENTS
| TFF_TEMPLATE_DEFAULT_ARGUMENTS
2680 | TFF_EXCEPTION_SPECIFICATION
| TFF_CHASE_NAMESPACE_ALIAS
;
2681 print_declaration (buffer
, &tfi
);
2685 tree_being_formatted (&tfi
) =
2686 va_arg (output_buffer_format_args (buffer
), tree
);
2688 tree_formatting_flags (&tfi
) = TFF_SCOPE
;
2689 print_expression (buffer
, &tfi
);
2693 tree_being_formatted (&tfi
) =
2694 va_arg (output_buffer_format_args (buffer
), tree
);
2696 tree_formatting_flags (&tfi
) = TFF_SCOPE
| TFF_DECL_SPECIFIERS
2697 | TFF_RETURN_TYPE
| TFF_FUNCTION_DEFAULT_ARGUMENTS
2698 | TFF_EXCEPTION_SPECIFICATION
;
2699 print_function_declaration (buffer
, &tfi
);
2703 print_function_parameter
2704 (buffer
, va_arg (output_buffer_format_args (buffer
), int));
2708 tree_being_formatted (&tfi
) =
2709 va_arg (output_buffer_format_args (buffer
), tree
);
2711 tree_formatting_flags (&tfi
) = TFF_SCOPE
| TFF_CLASS_KEY_OR_ENUM
2712 | TFF_RETURN_TYPE
| TFF_EXCEPTION_SPECIFICATION
;
2713 print_type_id (buffer
, &tfi
);
2717 tree_being_formatted (&tfi
) =
2718 va_arg (output_buffer_format_args (buffer
), tree
);
2719 print_cv_qualifier_seq (buffer
, &tfi
);
2729 /* Print a function argument-list represented by tree_being_formatted (TFI)
2732 print_function_argument_list (buffer
, tfi
)
2733 output_buffer
*buffer
__attribute__ ((__unused__
));
2734 tfi_t tfi
__attribute__ ((__unused__
));
2738 /* Print a declaration represented by tree_being_formatted (TFI)
2741 print_declaration (buffer
, tfi
)
2742 output_buffer
*buffer
__attribute__ ((__unused__
));
2743 tfi_t tfi
__attribute__ ((__unused__
));
2747 /* Print an expression represented by tree_being_formatted (TFI)
2750 print_expression (buffer
, tfi
)
2751 output_buffer
*buffer
__attribute__ ((__unused__
));
2752 tfi_t tfi
__attribute__ ((__unused__
));
2757 print_integer (buffer
, i
)
2758 output_buffer
*buffer
;
2761 sprintf (digit_buffer
, HOST_WIDE_INT_PRINT_DEC
, (HOST_WIDE_INT
) i
);
2762 output_add_string (buffer
, digit_buffer
);
2765 /* Print a function declaration represented by tree_being_formatted (TFI)
2768 print_function_declaration (buffer
, tfi
)
2769 output_buffer
*buffer
__attribute__ ((__unused__
));
2770 tfi_t tfi
__attribute__ ((__unused__
));
2774 /* Print the N'th function parameter onto BUFFER. A negative value of N
2775 means the implicit "this" parameter of a member function. */
2777 print_function_parameter (buffer
, n
)
2778 output_buffer
*buffer
;
2782 print_identifier (buffer
, "this");
2784 output_decimal (buffer
, n
+ 1);
2787 /* Print a type represented by tree_being_formatted (TFI) onto BUFFER. */
2789 print_type_id (buffer
, tfi
)
2790 output_buffer
*buffer
;
2793 tree t
= tree_being_formatted (tfi
);
2794 int flags
= tree_formatting_flags (tfi
);
2798 if (flags
& TFF_CHASE_TYPEDEF
)
2799 tree_being_formatted (tfi
) =
2800 typedef_original_name (tree_being_formatted (tfi
));
2802 /* A type-id is of the form:
2804 type-specifier-seq abstract-declarator(opt) */
2805 print_type_specifier_seq (buffer
, tfi
);
2807 if (TYPE_PTRMEMFUNC_P (t
))
2810 /* For types with abstract-declarator, print_type_specifier_seq prints
2811 the start of the abstract-declarator. Fiinish the job. */
2812 switch (TREE_CODE (t
))
2816 case REFERENCE_TYPE
:
2821 print_rest_of_abstract_declarator (buffer
, tfi
);
2827 tree_being_formatted (tfi
) = t
;
2830 /* Print the type-specifier-seq part of a type-id. If appropriate, print
2831 also the prefix of the abstract-declarator. */
2833 print_type_specifier_seq (buffer
, tfi
)
2834 output_buffer
*buffer
;
2837 int flags
= tree_formatting_flags (tfi
);
2838 tree t
= tree_being_formatted (tfi
);
2839 enum tree_code code
= TREE_CODE (t
);
2841 /* A type-speficier-seq is:
2842 type-specifier type-specifier-seq(opt)
2845 simple-type-specifier
2848 elaborated-type-specifier
2851 We do not, however, pretty-print class-specifier nor enum-specifier. */
2856 case IDENTIFIER_NODE
:
2866 case TEMPLATE_TYPE_PARM
:
2868 case TEMPLATE_TEMPLATE_PARM
:
2871 print_cv_qualifier_seq (buffer
, tfi
);
2872 if ((flags
& TFF_DECL_SPECIFIERS
)
2873 && (code
== TYPENAME_TYPE
|| IS_AGGR_TYPE (t
)))
2874 print_elaborated_type_specifier (buffer
, tfi
);
2876 print_simple_type_specifier (buffer
, tfi
);
2879 /* Because the abstract-declarator can modify the type-specifier-seq
2880 in a highly non linear manner, we pretty-print its prefix here.
2881 The suffix part is handled by print_rest_of_abstract_declarator. */
2883 /* A RECORD_TYPE is also used to represent a pointer to member
2886 if (TYPE_PTRMEMFUNC_P (t
))
2888 /* Print the return type. */
2889 tree_being_formatted (tfi
) =
2890 TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (t
));
2891 print_type_id (buffer
, tfi
);
2892 print_whitespace (buffer
, tfi
);
2894 /* Then the beginning of the abstract-declarator part. */
2895 tree_being_formatted (tfi
) =
2896 TYPE_METHOD_BASETYPE (TYPE_PTRMEMFUNC_FN_TYPE (t
));
2897 print_left_paren (buffer
);
2898 print_nested_name_specifier (buffer
, tfi
);
2905 if (TYPE_PTRMEM_P (t
))
2906 goto ptr_data_member
;
2908 goto non_ptr_data_member
;
2912 case REFERENCE_TYPE
:
2915 non_ptr_data_member
:
2916 tree_being_formatted (tfi
) = TREE_TYPE (t
);
2917 print_type_specifier_seq (buffer
, tfi
);
2918 if (code
== POINTER_TYPE
|| code
== REFERENCE_TYPE
)
2920 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
2921 print_left_paren (buffer
);
2923 else if (code
== FUNCTION_TYPE
|| code
== METHOD_TYPE
)
2925 print_whitespace (buffer
, tfi
);
2926 print_left_paren (buffer
);
2927 if (code
== METHOD_TYPE
)
2929 tree_being_formatted (tfi
) = TYPE_METHOD_BASETYPE (t
);
2930 print_nested_name_specifier (buffer
, tfi
);
2931 tree_being_formatted (tfi
) = t
;
2934 tree_being_formatted (tfi
) = t
;
2939 /* Firstly, the type of the member. */
2940 tree_being_formatted (tfi
) = TREE_TYPE (t
);
2941 print_type_id (buffer
, tfi
);
2942 print_whitespace (buffer
, tfi
);
2944 /* Then, the containing class. */
2945 tree_being_formatted (tfi
) = TYPE_OFFSET_BASETYPE (t
);
2946 print_nested_name_specifier (buffer
, tfi
);
2947 tree_being_formatted (tfi
) = t
;
2951 sorry_for_unsupported_tree (t
);
2955 print_identifier (buffer
, "{type-specifier-seq error}");
2959 tree_being_formatted (tfi
) = t
;
2962 /* Print the simpe-type-specifier component of a type-specifier. */
2964 print_simple_type_specifier (buffer
, tfi
)
2965 output_buffer
*buffer
;
2968 int flags
= tree_formatting_flags (tfi
);
2969 tree t
= tree_being_formatted (tfi
);
2970 enum tree_code code
= TREE_CODE (t
);
2975 print_identifier (buffer
, "{unknown type}");
2978 case IDENTIFIER_NODE
:
2979 print_tree_identifier (buffer
, t
);
2983 print_identifier (buffer
, "__complex__ ");
2984 tree_being_formatted (tfi
) = TREE_TYPE (t
);
2985 print_type_id (buffer
, tfi
);
2989 tree_being_formatted (tfi
) = TYPE_CONTEXT (t
);
2990 print_nested_name_specifier (buffer
, tfi
);
2991 tree_being_formatted (tfi
) = TYPENAME_TYPE_FULLNAME (t
);
2992 tree_formatting_flags (tfi
) |= ~TFF_CHASE_TYPEDEF
;
2993 print_type_id (buffer
, tfi
);
2997 print_identifier (buffer
, "__typeof__");
2998 tree_being_formatted (tfi
) = TYPE_FIELDS (t
);
2999 print_left_paren (buffer
);
3000 print_expression (buffer
, tfi
);
3001 print_right_paren (buffer
);
3005 if (TREE_UNSIGNED (t
))
3007 if (TYPE_MAIN_VARIANT (t
) == integer_type_node
)
3008 /* We don't want pedantry like `unsigned int'. */;
3009 else if (!TREE_UNSIGNED (TYPE_MAIN_VARIANT (t
)))
3011 print_identifier (buffer
, "unsigned");
3012 print_whitespace (buffer
, tfi
);
3015 else if (TYPE_MAIN_VARIANT (t
) == char_type_node
)
3017 print_identifier (buffer
, "signed");
3018 print_whitespace (buffer
, tfi
);
3024 tree s
= (flags
& TFF_CHASE_TYPEDEF
) ? TYPE_MAIN_VARIANT (t
) : t
;
3026 if (TYPE_NAME (s
) && TYPE_IDENTIFIER (s
))
3027 print_tree_identifier (buffer
, TYPE_IDENTIFIER (s
));
3029 /* Types like intQI_type_node and friends have no names.
3030 These don't come up in user error messages, but it's nice
3031 to be able to print them from the debugger. */
3032 print_identifier (buffer
, "{anonymous}");
3036 case TEMPLATE_TEMPLATE_PARM
:
3037 if (TYPE_IDENTIFIER (t
))
3038 print_tree_identifier (buffer
, TYPE_IDENTIFIER (t
));
3040 print_identifier (buffer
, "{anonymous template template parameter}");
3044 if (flags
& TFF_CHASE_TYPEDEF
)
3045 print_type_id (buffer
, tfi
);
3047 print_tree_identifier (buffer
, DECL_NAME (t
));
3050 case BOUND_TEMPLATE_TEMPLATE_PARM
:
3052 print_template_id (buffer
, tfi
);
3055 case TEMPLATE_TYPE_PARM
:
3056 if (TYPE_IDENTIFIER (t
))
3057 print_tree_identifier (buffer
, TYPE_IDENTIFIER (t
));
3059 print_identifier (buffer
, "{anonymous template type parameter}");
3066 tree_being_formatted (tfi
) = t
;
3067 tree_formatting_flags (tfi
) = flags
;
3070 /* Print the elaborated-type-specifier form of a type-specifier. */
3072 print_elaborated_type_specifier (buffer
, tfi
)
3073 output_buffer
*buffer
;
3076 int flags
= tree_formatting_flags (tfi
);
3077 tree t
= tree_being_formatted (tfi
);
3079 switch (TREE_CODE (t
))
3082 print_identifier (buffer
, "typename");
3083 print_whitespace (buffer
, tfi
);
3084 tree_formatting_flags (tfi
) |= ~TFF_DECL_SPECIFIERS
;
3085 print_simple_type_specifier (buffer
, tfi
);
3091 tree name
= NULL_TREE
;
3093 if (flags
& TFF_CHASE_TYPEDEF
)
3094 tree_being_formatted (tfi
) = typedef_original_name (t
);
3097 (buffer
, class_key_or_enum (tree_being_formatted (tfi
)));
3098 print_whitespace (buffer
, tfi
);
3100 name
= TYPE_NAME (tree_being_formatted (tfi
));
3103 if (flags
& TFF_SCOPE
)
3105 tree_being_formatted (tfi
) = CP_DECL_CONTEXT (name
);
3106 print_nested_name_specifier (buffer
, tfi
);
3108 print_tree_identifier (buffer
, DECL_NAME (name
));
3111 print_identifier (buffer
, "{anonymous}");
3116 sorry_for_unsupported_tree (t
);
3120 tree_being_formatted (tfi
) = t
;
3121 tree_formatting_flags (tfi
) = flags
;
3124 /* Finish the job of printing the abstract-declarator part of a
3127 print_rest_of_abstract_declarator (buffer
, tfi
)
3128 output_buffer
*buffer
;
3131 tree t
= tree_being_formatted (tfi
);
3132 enum tree_code code
= TREE_CODE (t
);
3134 /* An abstract-declarator has the form:
3136 abstract-declarator:
3137 ptr-operator abstract-declarator(opt)
3138 direct-abstract-declarator
3140 direct-abstract-declarator:
3141 direct-abstract-declarator(opt)
3142 ( parameter-declaration-clause ) cv-qualifier-seq(opt)
3143 exception-specification(opt)
3144 direct-abstract-declarator(opt) [ constant-expression(opt) ]
3145 ( direct-abstract-declarator ) */
3150 print_left_bracket (buffer
);
3151 if (TYPE_DOMAIN (t
))
3153 tree s
= TYPE_DOMAIN (t
);
3155 if (host_integerp (TYPE_MAX_VALUE (s
), 0))
3156 output_decimal (buffer
, tree_low_cst (TYPE_MAX_VALUE (s
), 0) + 1);
3157 else if (TREE_CODE (TYPE_MAX_VALUE (s
)) == MINUS_EXPR
)
3159 tree_being_formatted (tfi
) =
3160 TREE_OPERAND (TYPE_MAX_VALUE (s
), 0);
3161 print_expression (buffer
, tfi
);
3162 tree_being_formatted (tfi
) = t
;
3166 tree_being_formatted (tfi
) = fold
3167 (cp_build_binary_op (PLUS_EXPR
, TYPE_MAX_VALUE (s
),
3169 print_expression (buffer
, tfi
);
3170 tree_being_formatted (tfi
) = t
;
3173 print_right_bracket (buffer
);
3174 put_whitespace (tfi
) = none
;
3175 tree_being_formatted (tfi
) = TREE_TYPE (t
);
3176 print_rest_of_abstract_declarator (buffer
, tfi
);
3177 tree_being_formatted (tfi
) = t
;
3181 case REFERENCE_TYPE
:
3183 if (code
== POINTER_TYPE
|| code
== REFERENCE_TYPE
)
3185 output_add_character (buffer
, "&*"[code
== POINTER_TYPE
]);
3186 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
3187 print_right_paren (buffer
);
3189 put_whitespace (tfi
) = before
;
3190 print_cv_qualifier_seq (buffer
, tfi
);
3191 tree_being_formatted (tfi
) = TREE_TYPE (t
);
3192 print_rest_of_abstract_declarator (buffer
, tfi
);
3193 tree_being_formatted (tfi
) = t
;
3198 print_right_paren (buffer
);
3199 print_whitespace (buffer
, tfi
);
3201 /* Skip the `this' implicit parameter if present. */
3202 tree_being_formatted (tfi
) = TYPE_ARG_TYPES (t
);
3203 if (code
== METHOD_TYPE
)
3204 tree_being_formatted (tfi
) = TREE_CHAIN (tree_being_formatted (tfi
));
3206 /* Print the parameter-list. */
3207 print_left_paren (buffer
);
3208 print_parameter_declaration_clause (buffer
, tfi
);
3209 print_right_paren (buffer
);
3211 print_whitespace (buffer
, tfi
);
3213 if (code
== METHOD_TYPE
)
3215 tree_being_formatted (tfi
) =
3216 TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t
)));
3217 print_cv_qualifier_seq (buffer
, tfi
);
3220 /* Finish the abstract-declarator. */
3221 tree_being_formatted (tfi
) = TREE_TYPE (t
);
3222 print_rest_of_abstract_declarator (buffer
, tfi
);
3224 /* Print the exception-specification for documentaion purpose. */
3225 tree_being_formatted (tfi
) = TYPE_RAISES_EXCEPTIONS (t
);
3226 print_exception_specification (buffer
, tfi
);
3227 tree_being_formatted (tfi
) = t
;
3230 /* These types don't have abstract-declarator. */
3232 case IDENTIFIER_NODE
:
3242 case TEMPLATE_TYPE_PARM
:
3244 case TEMPLATE_TEMPLATE_PARM
:
3249 sorry_for_unsupported_tree (t
);
3250 /* fall throught. */
3256 /* Print the cv-quafilers of tree_being_formatted (TFI) onto BUFFER. */
3258 print_cv_qualifier_seq (buffer
, tfi
)
3259 output_buffer
*buffer
;
3260 tree_formatting_info
*tfi
;
3262 int cv
= TYPE_QUALS (tree_being_formatted (tfi
));
3263 int pad_after
= after
== put_whitespace (tfi
);
3264 static const int mask
[]
3265 = {TYPE_QUAL_CONST
, TYPE_QUAL_VOLATILE
, TYPE_QUAL_RESTRICT
};
3266 static const char *const qualifier
[]
3267 = { "const", "volatile", "__restrict__" };
3272 for (i
= 0; i
!= 3; ++i
)
3275 if (put_whitespace (tfi
) == before
)
3276 output_add_space (buffer
);
3277 print_identifier (buffer
, qualifier
[i
]);
3278 put_whitespace (tfi
) = before
;
3283 output_add_space (buffer
);
3284 put_whitespace (tfi
) = none
;
3290 print_parameter_declaration_clause (buffer
, tfi
)
3291 output_buffer
*buffer
__attribute__ ((__unused__
));
3292 tfi_t tfi
__attribute__ ((__unused__
));
3297 print_exception_specification (buffer
, tfi
)
3298 output_buffer
*buffer
__attribute__ ((__unused__
));
3299 tfi_t tfi
__attribute__ ((__unused__
));
3304 print_nested_name_specifier (buffer
, tfi
)
3305 output_buffer
*buffer
;
3308 int flags
= tree_formatting_flags (tfi
);
3309 tree t
= tree_being_formatted (tfi
);
3310 /* A nested-name-specifier is:
3311 class-or-namespace-name :: nested-name-specifier(opt)
3312 class-or-namespace-name :: template nested-name-specifier
3314 The latter form being the correct syntax for a name designating
3315 a template member, where the preceding class-or-namespace-name part
3316 is name-dependent. For the time being, we do not do such a
3317 sophisticated pretty-printing.
3319 class-or-namespace-name:
3323 if (t
== NULL_TREE
|| t
== global_namespace
)
3326 if (CLASS_TYPE_P (t
) && !(flags
& TFF_CLASS_SCOPE
))
3329 if (TREE_CODE (t
) == NAMESPACE_DECL
&& !(flags
& TFF_NAMESPACE_SCOPE
))
3332 tree_being_formatted (tfi
) = DECL_CONTEXT (t
);
3333 print_nested_name_specifier (buffer
, tfi
);
3334 print_scope_operator (buffer
);
3335 if (TREE_CODE (t
) == NAMESPACE_DECL
)
3336 print_tree_identifier (buffer
, DECL_NAME (t
));
3337 else if (CLASS_TYPE_P (t
))
3339 if (!DECL_USE_TEMPLATE (t
))
3340 print_tree_identifier (buffer
, TYPE_IDENTIFIER (t
));
3343 tree_being_formatted (tfi
) = t
;
3344 print_template_id (buffer
, tfi
);
3348 tree_being_formatted (tfi
) = t
;
3352 print_template_id (buffer
, tfi
)
3353 output_buffer
*buffer
;
3354 tfi_t tfi
__attribute__ ((__unused__
));
3356 print_template_argument_list_start (buffer
);
3358 print_template_argument_list_end (buffer
);
3362 typedef_original_name (t
)
3365 return DECL_ORIGINAL_TYPE (t
) ? DECL_ORIGINAL_TYPE (t
) : TREE_TYPE (t
);
3369 print_non_consecutive_character (buffer
, c
)
3370 output_buffer
*buffer
;
3373 const char *p
= output_last_position (buffer
);
3375 if (p
!= NULL
&& *p
== c
)
3376 output_add_space (buffer
);
3377 output_add_character (buffer
, c
);