1 /* Call-backs for C++ error reporting.
2 This code is non-reentrant.
3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002,
4 2003, 2004 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC 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 GCC 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 GCC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
24 #include "coretypes.h"
31 #include "diagnostic.h"
32 #include "langhooks-def.h"
33 #include "cxx-pretty-print.h"
35 #define pp_template_argument_list_start(PP) \
36 pp_non_consecutive_character (PP, '<')
37 #define pp_template_argument_list_end(PP) \
38 pp_non_consecutive_character (PP, '>')
39 #define pp_separate_with_comma(PP) pp_string (PP, ", ")
41 /* The global buffer where we dump everything. It is there only for
42 transitional purpose. It is expected, in the near future, to be
43 completely removed. */
44 static cxx_pretty_printer scratch_pretty_printer
;
45 #define cxx_pp (&scratch_pretty_printer)
47 # define NEXT_CODE(T) (TREE_CODE (TREE_TYPE (T)))
49 #define reinit_global_formatting_buffer() \
50 output_clear_message_text (scratch_buffer)
52 static const char *args_to_string (tree
, int);
53 static const char *assop_to_string (enum tree_code
);
54 static const char *code_to_string (enum tree_code
);
55 static const char *cv_to_string (tree
, int);
56 static const char *decl_to_string (tree
, int);
57 static const char *expr_to_string (tree
);
58 static const char *fndecl_to_string (tree
, int);
59 static const char *op_to_string (enum tree_code
);
60 static const char *parm_to_string (int);
61 static const char *type_to_string (tree
, int);
63 static void dump_type (tree
, int);
64 static void dump_typename (tree
, int);
65 static void dump_simple_decl (tree
, tree
, int);
66 static void dump_decl (tree
, int);
67 static void dump_template_decl (tree
, int);
68 static void dump_function_decl (tree
, int);
69 static void dump_expr (tree
, int);
70 static void dump_unary_op (const char *, tree
, int);
71 static void dump_binary_op (const char *, tree
, int);
72 static void dump_aggr_type (tree
, int);
73 static void dump_type_prefix (tree
, int);
74 static void dump_type_suffix (tree
, int);
75 static void dump_function_name (tree
, int);
76 static void dump_expr_list (tree
, int);
77 static void dump_global_iord (tree
);
78 static void dump_parameters (tree
, int);
79 static void dump_exception_spec (tree
, int);
80 static const char *class_key_or_enum (tree
);
81 static void dump_template_argument (tree
, int);
82 static void dump_template_argument_list (tree
, int);
83 static void dump_template_parameter (tree
, int);
84 static void dump_template_bindings (tree
, tree
);
85 static void dump_scope (tree
, int);
86 static void dump_template_parms (tree
, int, int);
88 static const char *function_category (tree
);
89 static void maybe_print_instantiation_context (diagnostic_context
*);
90 static void print_instantiation_full_context (diagnostic_context
*);
91 static void print_instantiation_partial_context (diagnostic_context
*,
93 static void cp_diagnostic_starter (diagnostic_context
*, diagnostic_info
*);
94 static void cp_diagnostic_finalizer (diagnostic_context
*, diagnostic_info
*);
95 static void cp_print_error_function (diagnostic_context
*, diagnostic_info
*);
97 static bool cp_printer (pretty_printer
*, text_info
*);
98 static void pp_non_consecutive_character (cxx_pretty_printer
*, int);
99 static tree
locate_error (const char *, va_list);
100 static location_t
location_of (tree
);
105 diagnostic_starter (global_dc
) = cp_diagnostic_starter
;
106 diagnostic_finalizer (global_dc
) = cp_diagnostic_finalizer
;
107 diagnostic_format_decoder (global_dc
) = cp_printer
;
109 pp_construct (pp_base (cxx_pp
), NULL
, 0);
110 pp_cxx_pretty_printer_init (cxx_pp
);
113 /* Dump a scope, if deemed necessary. */
116 dump_scope (tree scope
, int flags
)
118 int f
= ~TFF_RETURN_TYPE
& (flags
& (TFF_SCOPE
| TFF_CHASE_TYPEDEF
));
120 if (scope
== NULL_TREE
)
123 if (TREE_CODE (scope
) == NAMESPACE_DECL
)
125 if (scope
!= global_namespace
)
127 dump_decl (scope
, f
);
128 pp_colon_colon (cxx_pp
);
131 else if (AGGREGATE_TYPE_P (scope
))
133 dump_type (scope
, f
);
134 pp_colon_colon (cxx_pp
);
136 else if ((flags
& TFF_SCOPE
) && TREE_CODE (scope
) == FUNCTION_DECL
)
138 dump_function_decl (scope
, f
);
139 pp_colon_colon (cxx_pp
);
143 /* Dump the template ARGument under control of FLAGS. */
146 dump_template_argument (tree arg
, int flags
)
148 if (TYPE_P (arg
) || TREE_CODE (arg
) == TEMPLATE_DECL
)
149 dump_type (arg
, flags
& ~TFF_CLASS_KEY_OR_ENUM
);
151 dump_expr (arg
, (flags
| TFF_EXPR_IN_PARENS
) & ~TFF_CLASS_KEY_OR_ENUM
);
154 /* Dump a template-argument-list ARGS (always a TREE_VEC) under control
158 dump_template_argument_list (tree args
, int flags
)
160 int n
= TREE_VEC_LENGTH (args
);
164 for (i
= 0; i
< n
; ++i
)
167 pp_separate_with_comma (cxx_pp
);
168 dump_template_argument (TREE_VEC_ELT (args
, i
), flags
);
173 /* Dump a template parameter PARM (a TREE_LIST) under control of FLAGS. */
176 dump_template_parameter (tree parm
, int flags
)
178 tree p
= TREE_VALUE (parm
);
179 tree a
= TREE_PURPOSE (parm
);
181 if (TREE_CODE (p
) == TYPE_DECL
)
183 if (flags
& TFF_DECL_SPECIFIERS
)
185 pp_identifier (cxx_pp
, "class");
189 pp_tree_identifier (cxx_pp
, DECL_NAME (p
));
192 else if (DECL_NAME (p
))
193 pp_tree_identifier (cxx_pp
, DECL_NAME (p
));
195 pp_cxx_canonical_template_parameter (cxx_pp
, TREE_TYPE (p
));
198 dump_decl (p
, flags
| TFF_DECL_SPECIFIERS
);
200 if ((flags
& TFF_FUNCTION_DEFAULT_ARGUMENTS
) && a
!= NULL_TREE
)
202 pp_string (cxx_pp
, " = ");
203 if (TREE_CODE (p
) == TYPE_DECL
|| TREE_CODE (p
) == TEMPLATE_DECL
)
204 dump_type (a
, flags
& ~TFF_CHASE_TYPEDEF
);
206 dump_expr (a
, flags
| TFF_EXPR_IN_PARENS
);
210 /* Dump, under control of FLAGS, a template-parameter-list binding.
211 PARMS is a TREE_LIST of TREE_VEC of TREE_LIST and ARGS is a
215 dump_template_bindings (tree parms
, tree args
)
221 tree p
= TREE_VALUE (parms
);
222 int lvl
= TMPL_PARMS_DEPTH (parms
);
226 for (i
= 0; i
< TREE_VEC_LENGTH (p
); ++i
)
228 tree arg
= NULL_TREE
;
230 /* Don't crash if we had an invalid argument list. */
231 if (TMPL_ARGS_DEPTH (args
) >= lvl
)
233 tree lvl_args
= TMPL_ARGS_LEVEL (args
, lvl
);
234 if (NUM_TMPL_ARGS (lvl_args
) > arg_idx
)
235 arg
= TREE_VEC_ELT (lvl_args
, arg_idx
);
239 pp_separate_with_comma (cxx_pp
);
240 dump_template_parameter (TREE_VEC_ELT (p
, i
), TFF_PLAIN_IDENTIFIER
);
241 pp_string (cxx_pp
, " = ");
243 dump_template_argument (arg
, TFF_PLAIN_IDENTIFIER
);
245 pp_identifier (cxx_pp
, "<missing>");
251 parms
= TREE_CHAIN (parms
);
255 /* Dump a human-readable equivalent of TYPE. FLAGS controls the
259 dump_type (tree t
, int flags
)
264 if (TYPE_PTRMEMFUNC_P (t
))
267 switch (TREE_CODE (t
))
270 pp_identifier (cxx_pp
, "<unknown type>");
274 /* A list of function parms. */
275 dump_parameters (t
, flags
);
278 case IDENTIFIER_NODE
:
279 pp_tree_identifier (cxx_pp
, t
);
283 dump_type (BINFO_TYPE (t
), flags
);
289 dump_aggr_type (t
, flags
);
293 if (flags
& TFF_CHASE_TYPEDEF
)
295 dump_type (DECL_ORIGINAL_TYPE (t
)
296 ? DECL_ORIGINAL_TYPE (t
) : TREE_TYPE (t
), flags
);
299 /* Else fall through. */
303 dump_decl (t
, flags
& ~TFF_DECL_SPECIFIERS
);
312 pp_base (cxx_pp
)->padding
= pp_none
;
313 pp_type_specifier_seq (cxx_pp
, t
);
316 case TEMPLATE_TEMPLATE_PARM
:
317 /* For parameters inside template signature. */
318 if (TYPE_IDENTIFIER (t
))
319 pp_tree_identifier (cxx_pp
, TYPE_IDENTIFIER (t
));
321 pp_cxx_canonical_template_parameter (cxx_pp
, t
);
324 case BOUND_TEMPLATE_TEMPLATE_PARM
:
326 tree args
= TYPE_TI_ARGS (t
);
327 pp_tree_identifier (cxx_pp
, TYPE_IDENTIFIER (t
));
328 pp_template_argument_list_start (cxx_pp
);
329 dump_template_argument_list (args
, flags
);
330 pp_template_argument_list_end (cxx_pp
);
334 case TEMPLATE_TYPE_PARM
:
335 pp_cxx_cv_qualifier_seq (cxx_pp
, t
);
336 if (TYPE_IDENTIFIER (t
))
337 pp_tree_identifier (cxx_pp
, TYPE_IDENTIFIER (t
));
339 pp_cxx_canonical_template_parameter
340 (cxx_pp
, TEMPLATE_TYPE_PARM_INDEX (t
));
343 /* This is not always necessary for pointers and such, but doing this
344 reduces code size. */
353 dump_type_prefix (t
, flags
);
354 dump_type_suffix (t
, flags
);
358 pp_cxx_cv_qualifier_seq (cxx_pp
, t
);
359 pp_string (cxx_pp
, "typename ");
360 dump_typename (t
, flags
);
363 case UNBOUND_CLASS_TEMPLATE
:
364 dump_type (TYPE_CONTEXT (t
), flags
);
365 pp_colon_colon (cxx_pp
);
366 pp_identifier (cxx_pp
, "template ");
367 dump_type (DECL_NAME (TYPE_NAME (t
)), flags
);
371 pp_string (cxx_pp
, "__typeof (");
372 dump_expr (TYPEOF_TYPE_EXPR (t
), flags
& ~TFF_EXPR_IN_PARENS
);
373 pp_right_paren (cxx_pp
);
377 pp_unsupported_tree (cxx_pp
, t
);
378 /* Fall through to error. */
381 pp_identifier (cxx_pp
, "<type error>");
386 /* Dump a TYPENAME_TYPE. We need to notice when the context is itself
390 dump_typename (tree t
, int flags
)
392 tree ctx
= TYPE_CONTEXT (t
);
394 if (TREE_CODE (ctx
) == TYPENAME_TYPE
)
395 dump_typename (ctx
, flags
);
397 dump_type (ctx
, flags
& ~TFF_CLASS_KEY_OR_ENUM
);
398 pp_colon_colon (cxx_pp
);
399 dump_decl (TYPENAME_TYPE_FULLNAME (t
), flags
);
402 /* Return the name of the supplied aggregate, or enumeral type. */
405 class_key_or_enum (tree t
)
407 if (TREE_CODE (t
) == ENUMERAL_TYPE
)
409 else if (TREE_CODE (t
) == UNION_TYPE
)
411 else if (TYPE_LANG_SPECIFIC (t
) && CLASSTYPE_DECLARED_CLASS (t
))
417 /* Print out a class declaration T under the control of FLAGS,
418 in the form `class foo'. */
421 dump_aggr_type (tree t
, int flags
)
424 const char *variety
= class_key_or_enum (t
);
428 pp_cxx_cv_qualifier_seq (cxx_pp
, t
);
430 if (flags
& TFF_CLASS_KEY_OR_ENUM
)
432 pp_identifier (cxx_pp
, variety
);
436 if (flags
& TFF_CHASE_TYPEDEF
)
437 t
= TYPE_MAIN_VARIANT (t
);
439 name
= TYPE_NAME (t
);
443 typdef
= !DECL_ARTIFICIAL (name
);
444 tmplate
= !typdef
&& TREE_CODE (t
) != ENUMERAL_TYPE
445 && TYPE_LANG_SPECIFIC (t
) && CLASSTYPE_TEMPLATE_INFO (t
)
446 && (CLASSTYPE_TEMPLATE_SPECIALIZATION (t
)
447 || TREE_CODE (CLASSTYPE_TI_TEMPLATE (t
)) != TEMPLATE_DECL
448 || DECL_TEMPLATE_SPECIALIZATION (CLASSTYPE_TI_TEMPLATE (t
))
449 || PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t
)));
450 dump_scope (CP_DECL_CONTEXT (name
), flags
| TFF_SCOPE
);
453 /* Because the template names are mangled, we have to locate
454 the most general template, and use that name. */
455 tree tpl
= CLASSTYPE_TI_TEMPLATE (t
);
457 while (DECL_TEMPLATE_INFO (tpl
))
458 tpl
= DECL_TI_TEMPLATE (tpl
);
461 name
= DECL_NAME (name
);
464 if (name
== 0 || ANON_AGGRNAME_P (name
))
466 if (flags
& TFF_CLASS_KEY_OR_ENUM
)
467 pp_identifier (cxx_pp
, "<anonymous>");
469 pp_printf (pp_base (cxx_pp
), "<anonymous %s>", variety
);
472 pp_tree_identifier (cxx_pp
, name
);
474 dump_template_parms (TYPE_TEMPLATE_INFO (t
),
475 !CLASSTYPE_USE_TEMPLATE (t
),
476 flags
& ~TFF_TEMPLATE_HEADER
);
479 /* Dump into the obstack the initial part of the output for a given type.
480 This is necessary when dealing with things like functions returning
483 return type of `int (* fee ())()': pointer -> function -> int. Both
484 pointer (and reference and offset) and function (and member) types must
485 deal with prefix and suffix.
487 Arrays must also do this for DECL nodes, like int a[], and for things like
491 dump_type_prefix (tree t
, int flags
)
493 pp_base (cxx_pp
)->padding
= pp_none
;
495 if (TYPE_PTRMEMFUNC_P (t
))
497 t
= TYPE_PTRMEMFUNC_FN_TYPE (t
);
501 switch (TREE_CODE (t
))
506 tree sub
= TREE_TYPE (t
);
508 dump_type_prefix (sub
, flags
);
509 if (TREE_CODE (sub
) == ARRAY_TYPE
)
512 pp_left_paren (cxx_pp
);
514 pp_character (cxx_pp
, "&*"[TREE_CODE (t
) == POINTER_TYPE
]);
515 pp_base (cxx_pp
)->padding
= pp_before
;
516 pp_cxx_cv_qualifier_seq (cxx_pp
, t
);
522 dump_type_prefix (TREE_TYPE (t
), flags
);
523 if (TREE_CODE (t
) == OFFSET_TYPE
) /* pmfs deal with this in d_t_p */
525 pp_maybe_space (cxx_pp
);
526 dump_type (TYPE_OFFSET_BASETYPE (t
), flags
);
527 pp_colon_colon (cxx_pp
);
530 pp_cxx_cv_qualifier_seq (cxx_pp
, t
);
533 /* Can only be reached through function pointer -- this would not be
534 correct if FUNCTION_DECLs used it. */
536 dump_type_prefix (TREE_TYPE (t
), flags
);
537 pp_maybe_space (cxx_pp
);
538 pp_left_paren (cxx_pp
);
542 dump_type_prefix (TREE_TYPE (t
), flags
);
543 pp_maybe_space (cxx_pp
);
544 pp_left_paren (cxx_pp
);
545 dump_aggr_type (TYPE_METHOD_BASETYPE (t
), flags
);
546 pp_colon_colon (cxx_pp
);
550 dump_type_prefix (TREE_TYPE (t
), flags
);
554 case IDENTIFIER_NODE
:
559 case TEMPLATE_TYPE_PARM
:
560 case TEMPLATE_TEMPLATE_PARM
:
561 case BOUND_TEMPLATE_TEMPLATE_PARM
:
572 dump_type (t
, flags
);
573 pp_base (cxx_pp
)->padding
= pp_before
;
577 pp_unsupported_tree (cxx_pp
, t
);
580 pp_identifier (cxx_pp
, "<typeprefixerror>");
585 /* Dump the suffix of type T, under control of FLAGS. This is the part
586 which appears after the identifier (or function parms). */
589 dump_type_suffix (tree t
, int flags
)
591 if (TYPE_PTRMEMFUNC_P (t
))
592 t
= TYPE_PTRMEMFUNC_FN_TYPE (t
);
594 switch (TREE_CODE (t
))
599 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
)
600 pp_right_paren (cxx_pp
);
601 dump_type_suffix (TREE_TYPE (t
), flags
);
604 /* Can only be reached through function pointer. */
609 pp_right_paren (cxx_pp
);
610 arg
= TYPE_ARG_TYPES (t
);
611 if (TREE_CODE (t
) == METHOD_TYPE
)
612 arg
= TREE_CHAIN (arg
);
614 /* Function pointers don't have default args. Not in standard C++,
615 anyway; they may in g++, but we'll just pretend otherwise. */
616 dump_parameters (arg
, flags
& ~TFF_FUNCTION_DEFAULT_ARGUMENTS
);
618 if (TREE_CODE (t
) == METHOD_TYPE
)
619 pp_cxx_cv_qualifier_seq
620 (cxx_pp
, TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t
))));
621 dump_exception_spec (TYPE_RAISES_EXCEPTIONS (t
), flags
);
622 dump_type_suffix (TREE_TYPE (t
), flags
);
627 pp_left_bracket (cxx_pp
);
630 if (host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (t
)), 0))
632 (cxx_pp
, tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (t
)), 0) + 1);
633 else if (TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (t
))) == MINUS_EXPR
)
634 dump_expr (TREE_OPERAND (TYPE_MAX_VALUE (TYPE_DOMAIN (t
)), 0),
635 flags
& ~TFF_EXPR_IN_PARENS
);
637 dump_expr (fold (cp_build_binary_op
638 (PLUS_EXPR
, TYPE_MAX_VALUE (TYPE_DOMAIN (t
)),
640 flags
& ~TFF_EXPR_IN_PARENS
);
642 pp_right_bracket (cxx_pp
);
643 dump_type_suffix (TREE_TYPE (t
), flags
);
647 case IDENTIFIER_NODE
:
652 case TEMPLATE_TYPE_PARM
:
653 case TEMPLATE_TEMPLATE_PARM
:
654 case BOUND_TEMPLATE_TEMPLATE_PARM
:
668 pp_unsupported_tree (cxx_pp
, t
);
670 /* Don't mark it here, we should have already done in
677 dump_global_iord (tree t
)
679 const char *p
= NULL
;
681 if (DECL_GLOBAL_CTOR_P (t
))
683 else if (DECL_GLOBAL_DTOR_P (t
))
688 pp_printf (pp_base (cxx_pp
), "(static %s for %s)", p
, input_filename
);
692 dump_simple_decl (tree t
, tree type
, int flags
)
694 if (flags
& TFF_DECL_SPECIFIERS
)
696 dump_type_prefix (type
, flags
);
697 pp_maybe_space (cxx_pp
);
699 if (!DECL_INITIAL (t
) || TREE_CODE (DECL_INITIAL (t
)) != TEMPLATE_PARM_INDEX
)
700 dump_scope (CP_DECL_CONTEXT (t
), flags
);
702 dump_decl (DECL_NAME (t
), flags
);
704 pp_identifier (cxx_pp
, "<anonymous>");
705 if (flags
& TFF_DECL_SPECIFIERS
)
706 dump_type_suffix (type
, flags
);
709 /* Dump a human readable string for the decl T under control of FLAGS. */
712 dump_decl (tree t
, int flags
)
717 switch (TREE_CODE (t
))
721 /* Don't say 'typedef class A' */
722 if (DECL_ARTIFICIAL (t
))
724 if ((flags
& TFF_DECL_SPECIFIERS
)
725 && TREE_CODE (TREE_TYPE (t
)) == TEMPLATE_TYPE_PARM
)
726 /* Say `class T' not just `T'. */
727 pp_string (cxx_pp
, "class ");
729 dump_type (TREE_TYPE (t
), flags
);
733 if (flags
& TFF_DECL_SPECIFIERS
)
734 pp_string (cxx_pp
, "typedef ");
735 dump_simple_decl (t
, DECL_ORIGINAL_TYPE (t
)
736 ? DECL_ORIGINAL_TYPE (t
) : TREE_TYPE (t
),
741 if (DECL_NAME (t
) && VTABLE_NAME_P (DECL_NAME (t
)))
743 pp_string (cxx_pp
, "vtable for ");
744 my_friendly_assert (TYPE_P (DECL_CONTEXT (t
)), 20010720);
745 dump_type (DECL_CONTEXT (t
), flags
);
748 /* Else fall through. */
752 dump_simple_decl (t
, TREE_TYPE (t
), flags
);
756 pp_string (cxx_pp
, "<return value> ");
757 dump_simple_decl (t
, TREE_TYPE (t
), flags
);
761 if (flags
& TFF_DECL_SPECIFIERS
)
762 pp_cxx_declaration (cxx_pp
, t
);
765 dump_scope (CP_DECL_CONTEXT (t
), flags
);
766 if (DECL_NAME (t
) == NULL_TREE
)
767 pp_identifier (cxx_pp
, "<unnamed>");
769 pp_tree_identifier (cxx_pp
, DECL_NAME (t
));
774 dump_decl (TREE_OPERAND (t
, 0), flags
& ~TFF_DECL_SPECIFIERS
);
775 pp_colon_colon (cxx_pp
);
776 dump_decl (TREE_OPERAND (t
, 1), flags
);
780 dump_decl (TREE_OPERAND (t
, 0), flags
);
781 pp_left_bracket (cxx_pp
);
782 dump_decl (TREE_OPERAND (t
, 1), flags
);
783 pp_right_bracket (cxx_pp
);
786 /* So that we can do dump_decl on an aggr type. */
790 dump_type (t
, flags
);
794 /* This is a pseudo destructor call which has not been folded into
795 a PSEUDO_DTOR_EXPR yet. */
796 pp_complement (cxx_pp
);
797 dump_type (TREE_OPERAND (t
, 0), flags
);
804 /* These special cases are duplicated here so that other functions
805 can feed identifiers to error and get them demangled properly. */
806 case IDENTIFIER_NODE
:
807 if (IDENTIFIER_TYPENAME_P (t
))
809 pp_string (cxx_pp
, "operator ");
810 /* Not exactly IDENTIFIER_TYPE_VALUE. */
811 dump_type (TREE_TYPE (t
), flags
);
815 pp_tree_identifier (cxx_pp
, t
);
822 if (DECL_CLASS_SCOPE_P (t
))
824 dump_type (DECL_CONTEXT (t
), flags
);
825 pp_colon_colon (cxx_pp
);
827 else if (DECL_CONTEXT (t
))
829 dump_decl (DECL_CONTEXT (t
), flags
);
830 pp_colon_colon (cxx_pp
);
832 dump_decl (DECL_NAME (t
), flags
);
836 /* If there's only one function, just treat it like an ordinary
842 if (DECL_GLOBAL_CTOR_P (t
) || DECL_GLOBAL_DTOR_P (t
))
843 dump_global_iord (t
);
844 else if (! DECL_LANG_SPECIFIC (t
))
845 pp_identifier (cxx_pp
, "<internal>");
847 dump_function_decl (t
, flags
);
851 dump_template_decl (t
, flags
);
854 case TEMPLATE_ID_EXPR
:
856 tree name
= TREE_OPERAND (t
, 0);
858 if (is_overloaded_fn (name
))
859 name
= DECL_NAME (get_first_fn (name
));
860 dump_decl (name
, flags
);
861 pp_template_argument_list_start (cxx_pp
);
862 if (TREE_OPERAND (t
, 1))
863 dump_template_argument_list (TREE_OPERAND (t
, 1), flags
);
864 pp_template_argument_list_end (cxx_pp
);
869 pp_tree_identifier (cxx_pp
, DECL_NAME (t
));
873 if ((TREE_TYPE (t
) != NULL_TREE
&& NEXT_CODE (t
) == ENUMERAL_TYPE
)
874 || (DECL_INITIAL (t
) &&
875 TREE_CODE (DECL_INITIAL (t
)) == TEMPLATE_PARM_INDEX
))
876 dump_simple_decl (t
, TREE_TYPE (t
), flags
);
877 else if (DECL_NAME (t
))
878 dump_decl (DECL_NAME (t
), flags
);
879 else if (DECL_INITIAL (t
))
880 dump_expr (DECL_INITIAL (t
), flags
| TFF_EXPR_IN_PARENS
);
882 pp_identifier (cxx_pp
, "<enumerator>");
886 pp_string (cxx_pp
, "using ");
887 dump_type (DECL_INITIAL (t
), flags
);
888 pp_colon_colon (cxx_pp
);
889 dump_decl (DECL_NAME (t
), flags
);
893 dump_decl (BASELINK_FUNCTIONS (t
), flags
);
896 case NON_DEPENDENT_EXPR
:
897 dump_expr (t
, flags
);
900 case TEMPLATE_TYPE_PARM
:
901 if (flags
& TFF_DECL_SPECIFIERS
)
902 pp_cxx_declaration (cxx_pp
, t
);
904 pp_type_id (cxx_pp
, t
);
908 pp_unsupported_tree (cxx_pp
, t
);
909 /* Fall through to error. */
912 pp_identifier (cxx_pp
, "<declaration error>");
917 /* Dump a template declaration T under control of FLAGS. This means the
918 'template <...> leaders plus the 'class X' or 'void fn(...)' part. */
921 dump_template_decl (tree t
, int flags
)
923 tree orig_parms
= DECL_TEMPLATE_PARMS (t
);
927 if (flags
& TFF_TEMPLATE_HEADER
)
929 for (parms
= orig_parms
= nreverse (orig_parms
);
931 parms
= TREE_CHAIN (parms
))
933 tree inner_parms
= INNERMOST_TEMPLATE_PARMS (parms
);
934 int len
= TREE_VEC_LENGTH (inner_parms
);
936 pp_string (cxx_pp
, "template<");
938 /* If we've shown the template prefix, we'd better show the
939 parameters' and decl's type too. */
940 flags
|= TFF_DECL_SPECIFIERS
;
942 for (i
= 0; i
< len
; i
++)
945 pp_separate_with_comma (cxx_pp
);
946 dump_template_parameter (TREE_VEC_ELT (inner_parms
, i
), flags
);
948 pp_template_argument_list_end (cxx_pp
);
951 nreverse(orig_parms
);
953 if (DECL_TEMPLATE_TEMPLATE_PARM_P (t
))
954 /* Say `template<arg> class TT' not just `template<arg> TT'. */
955 pp_string (cxx_pp
, "class ");
958 if (TREE_CODE (DECL_TEMPLATE_RESULT (t
)) == TYPE_DECL
)
959 dump_type (TREE_TYPE (t
),
960 ((flags
& ~TFF_CLASS_KEY_OR_ENUM
) | TFF_TEMPLATE_NAME
961 | (flags
& TFF_DECL_SPECIFIERS
? TFF_CLASS_KEY_OR_ENUM
: 0)));
962 else if (TREE_CODE (DECL_TEMPLATE_RESULT (t
)) == VAR_DECL
)
963 dump_decl (DECL_TEMPLATE_RESULT (t
), flags
| TFF_TEMPLATE_NAME
);
964 else if (TREE_TYPE (t
) == NULL_TREE
)
967 switch (NEXT_CODE (t
))
971 dump_function_decl (t
, flags
| TFF_TEMPLATE_NAME
);
974 /* This case can occur with some invalid code. */
975 dump_type (TREE_TYPE (t
),
976 (flags
& ~TFF_CLASS_KEY_OR_ENUM
) | TFF_TEMPLATE_NAME
977 | (flags
& TFF_DECL_SPECIFIERS
? TFF_CLASS_KEY_OR_ENUM
: 0));
981 /* Pretty print a function decl. There are several ways we want to print a
982 function declaration. The TFF_ bits in FLAGS tells us how to behave.
983 As error can only apply the '#' flag once to give 0 and 1 for V, there
984 is %D which doesn't print the throw specs, and %F which does. */
987 dump_function_decl (tree t
, int flags
)
991 tree cname
= NULL_TREE
;
992 tree template_args
= NULL_TREE
;
993 tree template_parms
= NULL_TREE
;
994 int show_return
= flags
& TFF_RETURN_TYPE
|| flags
& TFF_DECL_SPECIFIERS
;
996 if (TREE_CODE (t
) == TEMPLATE_DECL
)
997 t
= DECL_TEMPLATE_RESULT (t
);
999 /* Pretty print template instantiations only. */
1000 if (DECL_USE_TEMPLATE (t
) && DECL_TEMPLATE_INFO (t
))
1004 template_args
= DECL_TI_ARGS (t
);
1005 tmpl
= most_general_template (t
);
1006 if (tmpl
&& TREE_CODE (tmpl
) == TEMPLATE_DECL
)
1008 template_parms
= DECL_TEMPLATE_PARMS (tmpl
);
1013 fntype
= TREE_TYPE (t
);
1014 parmtypes
= FUNCTION_FIRST_USER_PARMTYPE (t
);
1016 if (DECL_CLASS_SCOPE_P (t
))
1017 cname
= DECL_CONTEXT (t
);
1018 /* This is for partially instantiated template methods. */
1019 else if (TREE_CODE (fntype
) == METHOD_TYPE
)
1020 cname
= TREE_TYPE (TREE_VALUE (parmtypes
));
1022 if (!(flags
& TFF_DECL_SPECIFIERS
))
1024 else if (DECL_STATIC_FUNCTION_P (t
))
1025 pp_identifier (cxx_pp
, "static ");
1026 else if (DECL_VIRTUAL_P (t
))
1027 pp_identifier (cxx_pp
, "virtual ");
1029 /* Print the return type? */
1031 show_return
= !DECL_CONV_FN_P (t
) && !DECL_CONSTRUCTOR_P (t
)
1032 && !DECL_DESTRUCTOR_P (t
);
1035 dump_type_prefix (TREE_TYPE (fntype
), flags
);
1039 /* Print the function name. */
1042 dump_type (cname
, flags
);
1043 pp_colon_colon (cxx_pp
);
1046 dump_scope (CP_DECL_CONTEXT (t
), flags
);
1048 dump_function_name (t
, flags
);
1050 if (!(flags
& TFF_NO_FUNCTION_ARGUMENTS
))
1052 dump_parameters (parmtypes
, flags
);
1054 if (TREE_CODE (fntype
) == METHOD_TYPE
)
1055 pp_cxx_cv_qualifier_seq
1056 (cxx_pp
, TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype
))));
1058 if (flags
& TFF_EXCEPTION_SPECIFICATION
)
1059 dump_exception_spec (TYPE_RAISES_EXCEPTIONS (fntype
), flags
);
1062 dump_type_suffix (TREE_TYPE (fntype
), flags
);
1065 /* If T is a template instantiation, dump the parameter binding. */
1066 if (template_parms
!= NULL_TREE
&& template_args
!= NULL_TREE
)
1068 pp_string (cxx_pp
, " [with ");
1069 dump_template_bindings (template_parms
, template_args
);
1070 pp_right_bracket (cxx_pp
);
1074 /* Print a parameter list. If this is for a member function, the
1075 member object ptr (and any other hidden args) should have
1076 already been removed. */
1079 dump_parameters (tree parmtypes
, int flags
)
1083 pp_left_paren (cxx_pp
);
1085 for (first
= 1; parmtypes
!= void_list_node
;
1086 parmtypes
= TREE_CHAIN (parmtypes
))
1089 pp_separate_with_comma (cxx_pp
);
1093 pp_identifier (cxx_pp
, "...");
1096 dump_type (TREE_VALUE (parmtypes
), flags
);
1098 if ((flags
& TFF_FUNCTION_DEFAULT_ARGUMENTS
) && TREE_PURPOSE (parmtypes
))
1100 pp_string (cxx_pp
, " = ");
1101 dump_expr (TREE_PURPOSE (parmtypes
), flags
| TFF_EXPR_IN_PARENS
);
1105 pp_right_paren (cxx_pp
);
1108 /* Print an exception specification. T is the exception specification. */
1111 dump_exception_spec (tree t
, int flags
)
1115 pp_string (cxx_pp
, " throw (");
1116 if (TREE_VALUE (t
) != NULL_TREE
)
1119 dump_type (TREE_VALUE (t
), flags
);
1123 pp_separate_with_comma (cxx_pp
);
1125 pp_right_paren (cxx_pp
);
1129 /* Handle the function name for a FUNCTION_DECL node, grokking operators
1130 and destructors properly. */
1133 dump_function_name (tree t
, int flags
)
1135 tree name
= DECL_NAME (t
);
1137 /* We can get here with a decl that was synthesized by language-
1138 independent machinery (e.g. coverage.c) in which case it won't
1139 have a lang_specific structure attached and DECL_CONSTRUCTOR_P
1140 will crash. In this case it is safe just to print out the
1142 if (!DECL_LANG_SPECIFIC (t
))
1144 pp_tree_identifier (cxx_pp
, name
);
1148 if (TREE_CODE (t
) == TEMPLATE_DECL
)
1149 t
= DECL_TEMPLATE_RESULT (t
);
1151 /* Don't let the user see __comp_ctor et al. */
1152 if (DECL_CONSTRUCTOR_P (t
)
1153 || DECL_DESTRUCTOR_P (t
))
1154 name
= constructor_name (DECL_CONTEXT (t
));
1156 if (DECL_DESTRUCTOR_P (t
))
1158 pp_complement (cxx_pp
);
1159 dump_decl (name
, TFF_PLAIN_IDENTIFIER
);
1161 else if (DECL_CONV_FN_P (t
))
1163 /* This cannot use the hack that the operator's return
1164 type is stashed off of its name because it may be
1165 used for error reporting. In the case of conflicting
1166 declarations, both will have the same name, yet
1167 the types will be different, hence the TREE_TYPE field
1168 of the first name will be clobbered by the second. */
1169 pp_string (cxx_pp
, "operator ");
1170 dump_type (TREE_TYPE (TREE_TYPE (t
)), flags
);
1172 else if (IDENTIFIER_OPNAME_P (name
))
1173 pp_tree_identifier (cxx_pp
, name
);
1175 dump_decl (name
, flags
);
1177 if (DECL_TEMPLATE_INFO (t
)
1178 && !DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t
)
1179 && (DECL_TEMPLATE_SPECIALIZATION (t
)
1180 || TREE_CODE (DECL_TI_TEMPLATE (t
)) != TEMPLATE_DECL
1181 || DECL_TEMPLATE_SPECIALIZATION (DECL_TI_TEMPLATE (t
))
1182 || PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t
))))
1183 dump_template_parms (DECL_TEMPLATE_INFO (t
), !DECL_USE_TEMPLATE (t
), flags
);
1186 /* Dump the template parameters from the template info INFO under control of
1187 FLAGS. PRIMARY indicates whether this is a primary template decl, or
1188 specialization (partial or complete). For partial specializations we show
1189 the specialized parameter values. For a primary template we show no
1193 dump_template_parms (tree info
, int primary
, int flags
)
1195 tree args
= info
? TI_ARGS (info
) : NULL_TREE
;
1197 if (primary
&& flags
& TFF_TEMPLATE_NAME
)
1199 flags
&= ~(TFF_CLASS_KEY_OR_ENUM
| TFF_TEMPLATE_NAME
);
1200 pp_template_argument_list_start (cxx_pp
);
1202 /* Be careful only to print things when we have them, so as not
1203 to crash producing error messages. */
1204 if (args
&& !primary
)
1208 if (TMPL_ARGS_HAVE_MULTIPLE_LEVELS (args
))
1209 args
= TREE_VEC_ELT (args
, TREE_VEC_LENGTH (args
) - 1);
1211 len
= TREE_VEC_LENGTH (args
);
1213 for (ix
= 0; ix
!= len
; ix
++)
1215 tree arg
= TREE_VEC_ELT (args
, ix
);
1218 pp_separate_with_comma (cxx_pp
);
1221 pp_identifier (cxx_pp
, "<template parameter error>");
1223 dump_template_argument (arg
, flags
);
1228 tree tpl
= TI_TEMPLATE (info
);
1229 tree parms
= DECL_TEMPLATE_PARMS (tpl
);
1232 parms
= TREE_CODE (parms
) == TREE_LIST
? TREE_VALUE (parms
) : NULL_TREE
;
1233 len
= parms
? TREE_VEC_LENGTH (parms
) : 0;
1235 for (ix
= 0; ix
!= len
; ix
++)
1237 tree parm
= TREE_VALUE (TREE_VEC_ELT (parms
, ix
));
1240 pp_separate_with_comma (cxx_pp
);
1242 dump_decl (parm
, flags
& ~TFF_DECL_SPECIFIERS
);
1245 pp_template_argument_list_end (cxx_pp
);
1248 /* Print out a list of initializers (subr of dump_expr). */
1251 dump_expr_list (tree l
, int flags
)
1255 dump_expr (TREE_VALUE (l
), flags
| TFF_EXPR_IN_PARENS
);
1258 pp_separate_with_comma (cxx_pp
);
1262 /* Print out an expression E under control of FLAGS. */
1265 dump_expr (tree t
, int flags
)
1270 switch (TREE_CODE (t
))
1278 case NAMESPACE_DECL
:
1280 case IDENTIFIER_NODE
:
1281 dump_decl (t
, (flags
& ~TFF_DECL_SPECIFIERS
) | TFF_NO_FUNCTION_ARGUMENTS
);
1287 pp_c_constant (pp_c_base (cxx_pp
), t
);
1291 pp_identifier (cxx_pp
, "throw");
1292 dump_expr (TREE_OPERAND (t
, 0), flags
);
1296 pp_ampersand (cxx_pp
);
1297 dump_type (PTRMEM_CST_CLASS (t
), flags
);
1298 pp_colon_colon (cxx_pp
);
1299 pp_tree_identifier (cxx_pp
, DECL_NAME (PTRMEM_CST_MEMBER (t
)));
1303 pp_left_paren (cxx_pp
);
1304 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1305 pp_separate_with_comma (cxx_pp
);
1306 dump_expr (TREE_OPERAND (t
, 1), flags
| TFF_EXPR_IN_PARENS
);
1307 pp_right_paren (cxx_pp
);
1311 pp_left_paren (cxx_pp
);
1312 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1313 pp_string (cxx_pp
, " ? ");
1314 dump_expr (TREE_OPERAND (t
, 1), flags
| TFF_EXPR_IN_PARENS
);
1315 pp_string (cxx_pp
, " : ");
1316 dump_expr (TREE_OPERAND (t
, 2), flags
| TFF_EXPR_IN_PARENS
);
1317 pp_right_paren (cxx_pp
);
1321 if (TREE_HAS_CONSTRUCTOR (t
))
1323 pp_string (cxx_pp
, "new ");
1324 dump_type (TREE_TYPE (TREE_TYPE (t
)), flags
);
1327 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1330 case AGGR_INIT_EXPR
:
1332 tree fn
= NULL_TREE
;
1334 if (TREE_CODE (TREE_OPERAND (t
, 0)) == ADDR_EXPR
)
1335 fn
= TREE_OPERAND (TREE_OPERAND (t
, 0), 0);
1337 if (fn
&& TREE_CODE (fn
) == FUNCTION_DECL
)
1339 if (DECL_CONSTRUCTOR_P (fn
))
1340 pp_tree_identifier (cxx_pp
, TYPE_IDENTIFIER (TREE_TYPE (t
)));
1345 dump_expr (TREE_OPERAND (t
, 0), 0);
1347 pp_left_paren (cxx_pp
);
1348 if (TREE_OPERAND (t
, 1))
1349 dump_expr_list (TREE_CHAIN (TREE_OPERAND (t
, 1)), flags
);
1350 pp_right_paren (cxx_pp
);
1355 tree fn
= TREE_OPERAND (t
, 0);
1356 tree args
= TREE_OPERAND (t
, 1);
1358 if (TREE_CODE (fn
) == ADDR_EXPR
)
1359 fn
= TREE_OPERAND (fn
, 0);
1361 if (TREE_TYPE (fn
) != NULL_TREE
&& NEXT_CODE (fn
) == METHOD_TYPE
)
1363 tree ob
= TREE_VALUE (args
);
1364 if (TREE_CODE (ob
) == ADDR_EXPR
)
1366 dump_expr (TREE_OPERAND (ob
, 0), flags
| TFF_EXPR_IN_PARENS
);
1369 else if (TREE_CODE (ob
) != PARM_DECL
1370 || strcmp (IDENTIFIER_POINTER (DECL_NAME (ob
)), "this"))
1372 dump_expr (ob
, flags
| TFF_EXPR_IN_PARENS
);
1375 args
= TREE_CHAIN (args
);
1377 dump_expr (fn
, flags
| TFF_EXPR_IN_PARENS
);
1378 pp_left_paren (cxx_pp
);
1379 dump_expr_list (args
, flags
);
1380 pp_right_paren (cxx_pp
);
1386 tree type
= TREE_OPERAND (t
, 1);
1387 tree init
= TREE_OPERAND (t
, 2);
1388 if (NEW_EXPR_USE_GLOBAL (t
))
1389 pp_colon_colon (cxx_pp
);
1390 pp_string (cxx_pp
, "new ");
1391 if (TREE_OPERAND (t
, 0))
1393 pp_left_paren (cxx_pp
);
1394 dump_expr_list (TREE_OPERAND (t
, 0), flags
);
1395 pp_string (cxx_pp
, ") ");
1397 if (TREE_CODE (type
) == ARRAY_REF
)
1398 type
= build_cplus_array_type
1399 (TREE_OPERAND (type
, 0),
1400 build_index_type (fold (build (MINUS_EXPR
, integer_type_node
,
1401 TREE_OPERAND (type
, 1),
1402 integer_one_node
))));
1403 dump_type (type
, flags
);
1406 pp_left_paren (cxx_pp
);
1407 if (TREE_CODE (init
) == TREE_LIST
)
1408 dump_expr_list (init
, flags
);
1409 else if (init
== void_zero_node
)
1410 /* This representation indicates an empty initializer,
1411 e.g.: "new int()". */
1414 dump_expr (init
, flags
);
1415 pp_right_paren (cxx_pp
);
1421 /* Note that this only works for G++ target exprs. If somebody
1422 builds a general TARGET_EXPR, there's no way to represent that
1423 it initializes anything other that the parameter slot for the
1424 default argument. Note we may have cleared out the first
1425 operand in expand_expr, so don't go killing ourselves. */
1426 if (TREE_OPERAND (t
, 1))
1427 dump_expr (TREE_OPERAND (t
, 1), flags
| TFF_EXPR_IN_PARENS
);
1435 case TRUNC_DIV_EXPR
:
1436 case TRUNC_MOD_EXPR
:
1444 case TRUTH_ANDIF_EXPR
:
1445 case TRUTH_ORIF_EXPR
:
1452 case EXACT_DIV_EXPR
:
1453 dump_binary_op (operator_name_info
[(int) TREE_CODE (t
)].name
, t
, flags
);
1457 case FLOOR_DIV_EXPR
:
1458 case ROUND_DIV_EXPR
:
1459 dump_binary_op ("/", t
, flags
);
1463 case FLOOR_MOD_EXPR
:
1464 case ROUND_MOD_EXPR
:
1465 dump_binary_op ("%", t
, flags
);
1470 tree ob
= TREE_OPERAND (t
, 0);
1471 if (TREE_CODE (ob
) == INDIRECT_REF
)
1473 ob
= TREE_OPERAND (ob
, 0);
1474 if (TREE_CODE (ob
) != PARM_DECL
1475 || strcmp (IDENTIFIER_POINTER (DECL_NAME (ob
)), "this"))
1477 dump_expr (ob
, flags
| TFF_EXPR_IN_PARENS
);
1483 dump_expr (ob
, flags
| TFF_EXPR_IN_PARENS
);
1486 dump_expr (TREE_OPERAND (t
, 1), flags
& ~TFF_EXPR_IN_PARENS
);
1491 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1492 pp_left_bracket (cxx_pp
);
1493 dump_expr (TREE_OPERAND (t
, 1), flags
| TFF_EXPR_IN_PARENS
);
1494 pp_right_bracket (cxx_pp
);
1498 if (TREE_TYPE (t
) && VOID_TYPE_P (TREE_TYPE (t
)))
1500 pp_left_paren (cxx_pp
);
1501 dump_type (TREE_TYPE (t
), flags
);
1502 pp_right_paren (cxx_pp
);
1503 dump_expr (TREE_OPERAND (t
, 0), flags
);
1506 dump_unary_op ("+", t
, flags
);
1510 if (TREE_CODE (TREE_OPERAND (t
, 0)) == FUNCTION_DECL
1511 || TREE_CODE (TREE_OPERAND (t
, 0)) == STRING_CST
1512 /* An ADDR_EXPR can have reference type. In that case, we
1513 shouldn't print the `&' doing so indicates to the user
1514 that the expression has pointer type. */
1516 && TREE_CODE (TREE_TYPE (t
)) == REFERENCE_TYPE
))
1517 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1519 dump_unary_op ("&", t
, flags
);
1523 if (TREE_HAS_CONSTRUCTOR (t
))
1525 t
= TREE_OPERAND (t
, 0);
1526 my_friendly_assert (TREE_CODE (t
) == CALL_EXPR
, 237);
1527 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1528 pp_left_paren (cxx_pp
);
1529 dump_expr_list (TREE_CHAIN (TREE_OPERAND (t
, 1)), flags
);
1530 pp_right_paren (cxx_pp
);
1534 if (TREE_OPERAND (t
,0) != NULL_TREE
1535 && TREE_TYPE (TREE_OPERAND (t
, 0))
1536 && NEXT_CODE (TREE_OPERAND (t
, 0)) == REFERENCE_TYPE
)
1537 dump_expr (TREE_OPERAND (t
, 0), flags
);
1539 dump_unary_op ("*", t
, flags
);
1545 case TRUTH_NOT_EXPR
:
1546 case PREDECREMENT_EXPR
:
1547 case PREINCREMENT_EXPR
:
1548 dump_unary_op (operator_name_info
[(int)TREE_CODE (t
)].name
, t
, flags
);
1551 case POSTDECREMENT_EXPR
:
1552 case POSTINCREMENT_EXPR
:
1553 pp_left_paren (cxx_pp
);
1554 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1555 pp_identifier (cxx_pp
, operator_name_info
[(int)TREE_CODE (t
)].name
);
1556 pp_right_paren (cxx_pp
);
1559 case NON_LVALUE_EXPR
:
1560 /* FIXME: This is a KLUDGE workaround for a parsing problem. There
1561 should be another level of INDIRECT_REF so that I don't have to do
1563 if (TREE_TYPE (t
) != NULL_TREE
&& NEXT_CODE (t
) == POINTER_TYPE
)
1565 tree next
= TREE_TYPE (TREE_TYPE (t
));
1567 while (TREE_CODE (next
) == POINTER_TYPE
)
1568 next
= TREE_TYPE (next
);
1570 if (TREE_CODE (next
) == FUNCTION_TYPE
)
1572 if (flags
& TFF_EXPR_IN_PARENS
)
1573 pp_left_paren (cxx_pp
);
1575 dump_expr (TREE_OPERAND (t
, 0), flags
& ~TFF_EXPR_IN_PARENS
);
1576 if (flags
& TFF_EXPR_IN_PARENS
)
1577 pp_right_paren (cxx_pp
);
1580 /* Else fall through. */
1582 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1587 tree op
= TREE_OPERAND (t
, 0);
1589 if (!same_type_p (TREE_TYPE (op
), TREE_TYPE (t
)))
1591 /* It is a cast, but we cannot tell whether it is a
1592 reinterpret or static cast. Use the C style notation. */
1593 if (flags
& TFF_EXPR_IN_PARENS
)
1594 pp_left_paren (cxx_pp
);
1595 pp_left_paren (cxx_pp
);
1596 dump_type (TREE_TYPE (t
), flags
);
1597 pp_right_paren (cxx_pp
);
1598 dump_expr (op
, flags
| TFF_EXPR_IN_PARENS
);
1599 if (flags
& TFF_EXPR_IN_PARENS
)
1600 pp_right_paren (cxx_pp
);
1603 dump_expr (op
, flags
);
1607 case EXPR_WITH_FILE_LOCATION
:
1608 dump_expr (EXPR_WFL_NODE (t
), flags
);
1612 if (TREE_TYPE (t
) && TYPE_PTRMEMFUNC_P (TREE_TYPE (t
)))
1614 tree idx
= build_ptrmemfunc_access_expr (t
, pfn_identifier
);
1616 if (integer_zerop (idx
))
1618 /* A NULL pointer-to-member constant. */
1619 pp_left_paren (cxx_pp
);
1620 pp_left_paren (cxx_pp
);
1621 dump_type (TREE_TYPE (t
), flags
);
1622 pp_right_paren (cxx_pp
);
1623 pp_string (cxx_pp
, ")0)");
1626 else if (host_integerp (idx
, 0))
1629 unsigned HOST_WIDE_INT n
;
1631 t
= TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (t
)));
1632 t
= TYPE_METHOD_BASETYPE (t
);
1633 virtuals
= TYPE_BINFO_VIRTUALS (TYPE_MAIN_VARIANT (t
));
1635 n
= tree_low_cst (idx
, 0);
1637 /* Map vtable index back one, to allow for the null pointer to
1641 while (n
> 0 && virtuals
)
1644 virtuals
= TREE_CHAIN (virtuals
);
1648 dump_expr (BV_FN (virtuals
),
1649 flags
| TFF_EXPR_IN_PARENS
);
1654 if (TREE_TYPE (t
) && !CONSTRUCTOR_ELTS (t
))
1656 dump_type (TREE_TYPE (t
), 0);
1657 pp_left_paren (cxx_pp
);
1658 pp_right_paren (cxx_pp
);
1662 pp_left_brace (cxx_pp
);
1663 dump_expr_list (CONSTRUCTOR_ELTS (t
), flags
);
1664 pp_right_brace (cxx_pp
);
1671 tree ob
= TREE_OPERAND (t
, 0);
1672 if (is_dummy_object (ob
))
1674 t
= TREE_OPERAND (t
, 1);
1675 if (TREE_CODE (t
) == FUNCTION_DECL
)
1677 dump_expr (t
, flags
| TFF_EXPR_IN_PARENS
);
1678 else if (BASELINK_P (t
))
1679 dump_expr (OVL_CURRENT (BASELINK_FUNCTIONS (t
)),
1680 flags
| TFF_EXPR_IN_PARENS
);
1682 dump_decl (t
, flags
);
1686 if (TREE_CODE (ob
) == INDIRECT_REF
)
1688 dump_expr (TREE_OPERAND (ob
, 0), flags
| TFF_EXPR_IN_PARENS
);
1689 pp_string (cxx_pp
, "->*");
1693 dump_expr (ob
, flags
| TFF_EXPR_IN_PARENS
);
1694 pp_string (cxx_pp
, ".*");
1696 dump_expr (TREE_OPERAND (t
, 1), flags
| TFF_EXPR_IN_PARENS
);
1701 case TEMPLATE_PARM_INDEX
:
1702 dump_decl (TEMPLATE_PARM_DECL (t
), flags
& ~TFF_DECL_SPECIFIERS
);
1706 dump_type (TREE_OPERAND (t
, 0), flags
);
1707 pp_colon_colon (cxx_pp
);
1708 dump_expr (TREE_OPERAND (t
, 1), flags
| TFF_EXPR_IN_PARENS
);
1712 if (TREE_OPERAND (t
, 0) == NULL_TREE
1713 || TREE_CHAIN (TREE_OPERAND (t
, 0)))
1715 dump_type (TREE_TYPE (t
), flags
);
1716 pp_left_paren (cxx_pp
);
1717 dump_expr_list (TREE_OPERAND (t
, 0), flags
);
1718 pp_right_paren (cxx_pp
);
1722 pp_left_paren (cxx_pp
);
1723 dump_type (TREE_TYPE (t
), flags
);
1724 pp_string (cxx_pp
, ")(");
1725 dump_expr_list (TREE_OPERAND (t
, 0), flags
);
1726 pp_right_paren (cxx_pp
);
1730 case STATIC_CAST_EXPR
:
1731 pp_string (cxx_pp
, "static_cast<");
1733 case REINTERPRET_CAST_EXPR
:
1734 pp_string (cxx_pp
, "reinterpret_cast<");
1736 case CONST_CAST_EXPR
:
1737 pp_string (cxx_pp
, "const_cast<");
1739 case DYNAMIC_CAST_EXPR
:
1740 pp_string (cxx_pp
, "dynamic_cast<");
1742 dump_type (TREE_TYPE (t
), flags
);
1743 pp_string (cxx_pp
, ">(");
1744 dump_expr (TREE_OPERAND (t
, 0), flags
);
1745 pp_right_paren (cxx_pp
);
1749 dump_expr (TREE_OPERAND (t
, 0), flags
);
1755 if (TREE_CODE (t
) == SIZEOF_EXPR
)
1756 pp_string (cxx_pp
, "sizeof (");
1759 my_friendly_assert (TREE_CODE (t
) == ALIGNOF_EXPR
, 0);
1760 pp_string (cxx_pp
, "__alignof__ (");
1762 if (TYPE_P (TREE_OPERAND (t
, 0)))
1763 dump_type (TREE_OPERAND (t
, 0), flags
);
1765 dump_expr (TREE_OPERAND (t
, 0), flags
);
1766 pp_right_paren (cxx_pp
);
1771 pp_identifier (cxx_pp
, operator_name_info
[TREE_CODE (t
)].name
);
1773 dump_expr (TREE_OPERAND (t
, 0), flags
);
1777 pp_identifier (cxx_pp
, "<unparsed>");
1780 case TRY_CATCH_EXPR
:
1781 case WITH_CLEANUP_EXPR
:
1782 case CLEANUP_POINT_EXPR
:
1783 dump_expr (TREE_OPERAND (t
, 0), flags
);
1786 case PSEUDO_DTOR_EXPR
:
1787 dump_expr (TREE_OPERAND (t
, 2), flags
);
1789 dump_type (TREE_OPERAND (t
, 0), flags
);
1790 pp_colon_colon (cxx_pp
);
1791 pp_complement (cxx_pp
);
1792 dump_type (TREE_OPERAND (t
, 1), flags
);
1795 case TEMPLATE_ID_EXPR
:
1796 dump_decl (t
, flags
);
1800 /* We don't yet have a way of dumping statements in a
1801 human-readable format. */
1802 pp_string (cxx_pp
, "({...})");
1806 pp_left_brace (cxx_pp
);
1807 dump_expr (TREE_OPERAND (t
, 1), flags
& ~TFF_EXPR_IN_PARENS
);
1808 pp_right_brace (cxx_pp
);
1812 pp_string (cxx_pp
, "while (1) { ");
1813 dump_expr (TREE_OPERAND (t
, 0), flags
& ~TFF_EXPR_IN_PARENS
);
1814 pp_right_brace (cxx_pp
);
1818 pp_string (cxx_pp
, "if (");
1819 dump_expr (TREE_OPERAND (t
, 0), flags
& ~TFF_EXPR_IN_PARENS
);
1820 pp_string (cxx_pp
, ") break; ");
1824 dump_expr (get_first_fn (t
), flags
& ~TFF_EXPR_IN_PARENS
);
1827 case EMPTY_CLASS_EXPR
:
1828 dump_type (TREE_TYPE (t
), flags
);
1829 pp_left_paren (cxx_pp
);
1830 pp_right_paren (cxx_pp
);
1833 case NON_DEPENDENT_EXPR
:
1834 dump_expr (TREE_OPERAND (t
, 0), flags
);
1837 /* This list is incomplete, but should suffice for now.
1838 It is very important that `sorry' does not call
1839 `report_error_function'. That could cause an infinite loop. */
1841 pp_unsupported_tree (cxx_pp
, t
);
1842 /* fall through to ERROR_MARK... */
1844 pp_identifier (cxx_pp
, "<expression error>");
1850 dump_binary_op (const char *opstring
, tree t
, int flags
)
1852 pp_left_paren (cxx_pp
);
1853 dump_expr (TREE_OPERAND (t
, 0), flags
| TFF_EXPR_IN_PARENS
);
1856 pp_identifier (cxx_pp
, opstring
);
1858 pp_identifier (cxx_pp
, "<unknown operator>");
1860 dump_expr (TREE_OPERAND (t
, 1), flags
| TFF_EXPR_IN_PARENS
);
1861 pp_right_paren (cxx_pp
);
1865 dump_unary_op (const char *opstring
, tree t
, int flags
)
1867 if (flags
& TFF_EXPR_IN_PARENS
)
1868 pp_left_paren (cxx_pp
);
1869 pp_identifier (cxx_pp
, opstring
);
1870 dump_expr (TREE_OPERAND (t
, 0), flags
& ~TFF_EXPR_IN_PARENS
);
1871 if (flags
& TFF_EXPR_IN_PARENS
)
1872 pp_right_paren (cxx_pp
);
1875 /* Exported interface to stringifying types, exprs and decls under TFF_*
1879 type_as_string (tree typ
, int flags
)
1881 pp_clear_output_area (cxx_pp
);
1882 dump_type (typ
, flags
);
1883 return pp_formatted_text (cxx_pp
);
1887 expr_as_string (tree decl
, int flags
)
1889 pp_clear_output_area (cxx_pp
);
1890 dump_expr (decl
, flags
);
1891 return pp_formatted_text (cxx_pp
);
1895 decl_as_string (tree decl
, int flags
)
1897 pp_clear_output_area (cxx_pp
);
1898 dump_decl (decl
, flags
);
1899 return pp_formatted_text (cxx_pp
);
1903 context_as_string (tree context
, int flags
)
1905 pp_clear_output_area (cxx_pp
);
1906 dump_scope (context
, flags
);
1907 return pp_formatted_text (cxx_pp
);
1910 /* Generate the three forms of printable names for cxx_printable_name. */
1913 lang_decl_name (tree decl
, int v
)
1916 return decl_as_string (decl
, TFF_DECL_SPECIFIERS
);
1918 pp_clear_output_area (cxx_pp
);
1919 if (v
== 1 && DECL_CLASS_SCOPE_P (decl
))
1921 dump_type (CP_DECL_CONTEXT (decl
), TFF_PLAIN_IDENTIFIER
);
1922 pp_colon_colon (cxx_pp
);
1925 if (TREE_CODE (decl
) == FUNCTION_DECL
)
1926 dump_function_name (decl
, TFF_PLAIN_IDENTIFIER
);
1928 dump_decl (DECL_NAME (decl
), TFF_PLAIN_IDENTIFIER
);
1930 return pp_formatted_text (cxx_pp
);
1934 location_of (tree t
)
1936 if (TREE_CODE (t
) == PARM_DECL
&& DECL_CONTEXT (t
))
1937 t
= DECL_CONTEXT (t
);
1938 else if (TYPE_P (t
))
1939 t
= TYPE_MAIN_DECL (t
);
1940 else if (TREE_CODE (t
) == OVERLOAD
)
1941 t
= OVL_FUNCTION (t
);
1943 return DECL_SOURCE_LOCATION (t
);
1946 /* Now the interfaces from error et al to dump_type et al. Each takes an
1947 on/off VERBOSE flag and supply the appropriate TFF_ flags to a dump_
1951 decl_to_string (tree decl
, int verbose
)
1955 if (TREE_CODE (decl
) == TYPE_DECL
|| TREE_CODE (decl
) == RECORD_TYPE
1956 || TREE_CODE (decl
) == UNION_TYPE
|| TREE_CODE (decl
) == ENUMERAL_TYPE
)
1957 flags
= TFF_CLASS_KEY_OR_ENUM
;
1959 flags
|= TFF_DECL_SPECIFIERS
;
1960 else if (TREE_CODE (decl
) == FUNCTION_DECL
)
1961 flags
|= TFF_DECL_SPECIFIERS
| TFF_RETURN_TYPE
;
1962 flags
|= TFF_TEMPLATE_HEADER
;
1964 pp_clear_output_area (cxx_pp
);
1965 dump_decl (decl
, flags
);
1966 return pp_formatted_text (cxx_pp
);
1970 expr_to_string (tree decl
)
1972 pp_clear_output_area (cxx_pp
);
1973 dump_expr (decl
, 0);
1974 return pp_formatted_text (cxx_pp
);
1978 fndecl_to_string (tree fndecl
, int verbose
)
1982 flags
= TFF_EXCEPTION_SPECIFICATION
| TFF_DECL_SPECIFIERS
;
1984 flags
|= TFF_FUNCTION_DEFAULT_ARGUMENTS
;
1985 pp_clear_output_area (cxx_pp
);
1986 dump_decl (fndecl
, flags
);
1987 return pp_formatted_text (cxx_pp
);
1992 code_to_string (enum tree_code c
)
1994 return tree_code_name
[c
];
1998 language_to_string (enum languages c
)
2005 case lang_cplusplus
:
2017 /* Return the proper printed version of a parameter to a C++ function. */
2020 parm_to_string (int p
)
2022 pp_clear_output_area (cxx_pp
);
2024 pp_string (cxx_pp
, "'this'");
2026 pp_decimal_int (cxx_pp
, p
+ 1);
2027 return pp_formatted_text (cxx_pp
);
2031 op_to_string (enum tree_code p
)
2033 tree id
= operator_name_info
[(int) p
].identifier
;
2034 return id
? IDENTIFIER_POINTER (id
) : "<unknown>";
2038 type_to_string (tree typ
, int verbose
)
2042 flags
|= TFF_CLASS_KEY_OR_ENUM
;
2043 flags
|= TFF_TEMPLATE_HEADER
;
2045 pp_clear_output_area (cxx_pp
);
2046 dump_type (typ
, flags
);
2047 return pp_formatted_text (cxx_pp
);
2051 assop_to_string (enum tree_code p
)
2053 tree id
= assignment_operator_name_info
[(int) p
].identifier
;
2054 return id
? IDENTIFIER_POINTER (id
) : "{unknown}";
2058 args_to_string (tree p
, int verbose
)
2062 flags
|= TFF_CLASS_KEY_OR_ENUM
;
2067 if (TYPE_P (TREE_VALUE (p
)))
2068 return type_as_string (p
, flags
);
2070 pp_clear_output_area (cxx_pp
);
2071 for (; p
; p
= TREE_CHAIN (p
))
2073 if (TREE_VALUE (p
) == null_node
)
2074 pp_identifier (cxx_pp
, "NULL");
2076 dump_type (error_type (TREE_VALUE (p
)), flags
);
2078 pp_separate_with_comma (cxx_pp
);
2080 return pp_formatted_text (cxx_pp
);
2084 cv_to_string (tree p
, int v
)
2086 pp_clear_output_area (cxx_pp
);
2087 pp_base (cxx_pp
)->padding
= v
? pp_before
: pp_none
;
2088 pp_cxx_cv_qualifier_seq (cxx_pp
, p
);
2089 return pp_formatted_text (cxx_pp
);
2092 /* Langhook for print_error_function. */
2094 cxx_print_error_function (diagnostic_context
*context
, const char *file
)
2096 lhd_print_error_function (context
, file
);
2097 pp_base_set_prefix (context
->printer
, file
);
2098 maybe_print_instantiation_context (context
);
2102 cp_diagnostic_starter (diagnostic_context
*context
,
2103 diagnostic_info
*diagnostic
)
2105 diagnostic_report_current_module (context
);
2106 cp_print_error_function (context
, diagnostic
);
2107 maybe_print_instantiation_context (context
);
2108 pp_base_set_prefix (context
->printer
, diagnostic_build_prefix (diagnostic
));
2112 cp_diagnostic_finalizer (diagnostic_context
*context
,
2113 diagnostic_info
*diagnostic ATTRIBUTE_UNUSED
)
2115 pp_base_destroy_prefix (context
->printer
);
2118 /* Print current function onto BUFFER, in the process of reporting
2119 a diagnostic message. Called from cp_diagnostic_starter. */
2121 cp_print_error_function (diagnostic_context
*context
,
2122 diagnostic_info
*diagnostic
)
2124 if (diagnostic_last_function_changed (context
))
2126 const char *old_prefix
= context
->printer
->prefix
;
2127 char *new_prefix
= diagnostic
->location
.file
2128 ? file_name_as_prefix (diagnostic
->location
.file
)
2131 pp_base_set_prefix (context
->printer
, new_prefix
);
2133 if (current_function_decl
== NULL
)
2134 pp_base_string (context
->printer
, "At global scope:");
2136 pp_printf (context
->printer
, "In %s `%s':",
2137 function_category (current_function_decl
),
2138 cxx_printable_name (current_function_decl
, 2));
2139 pp_base_newline (context
->printer
);
2141 diagnostic_set_last_function (context
);
2142 pp_base_destroy_prefix (context
->printer
);
2143 context
->printer
->prefix
= old_prefix
;
2147 /* Returns a description of FUNCTION using standard terminology. */
2149 function_category (tree fn
)
2151 if (DECL_FUNCTION_MEMBER_P (fn
))
2153 if (DECL_STATIC_FUNCTION_P (fn
))
2154 return "static member function";
2155 else if (DECL_COPY_CONSTRUCTOR_P (fn
))
2156 return "copy constructor";
2157 else if (DECL_CONSTRUCTOR_P (fn
))
2158 return "constructor";
2159 else if (DECL_DESTRUCTOR_P (fn
))
2160 return "destructor";
2162 return "member function";
2168 /* Report the full context of a current template instantiation,
2171 print_instantiation_full_context (diagnostic_context
*context
)
2173 tree p
= current_instantiation ();
2174 location_t location
= input_location
;
2178 if (current_function_decl
!= TINST_DECL (p
)
2179 && current_function_decl
!= NULL_TREE
)
2180 /* We can get here during the processing of some synthesized
2181 method. Then, TINST_DECL (p) will be the function that's causing
2186 if (current_function_decl
== TINST_DECL (p
))
2187 /* Avoid redundancy with the the "In function" line. */;
2189 pp_verbatim (context
->printer
,
2190 "%s: In instantiation of `%s':\n", location
.file
,
2191 decl_as_string (TINST_DECL (p
),
2192 TFF_DECL_SPECIFIERS
| TFF_RETURN_TYPE
));
2194 location
.line
= TINST_LINE (p
);
2195 location
.file
= TINST_FILE (p
);
2200 print_instantiation_partial_context (context
, p
, location
);
2203 /* Same as above but less verbose. */
2205 print_instantiation_partial_context (diagnostic_context
*context
,
2206 tree t
, location_t loc
)
2208 for (; t
; t
= TREE_CHAIN (t
))
2210 pp_verbatim (context
->printer
, "%s:%d: instantiated from `%s'\n",
2212 decl_as_string (TINST_DECL (t
),
2213 TFF_DECL_SPECIFIERS
| TFF_RETURN_TYPE
));
2214 loc
.line
= TINST_LINE (t
);
2215 loc
.file
= TINST_FILE (t
);
2217 pp_verbatim (context
->printer
, "%s:%d: instantiated from here\n",
2218 loc
.file
, loc
.line
);
2221 /* Called from cp_thing to print the template context for an error. */
2223 maybe_print_instantiation_context (diagnostic_context
*context
)
2225 if (!problematic_instantiation_changed () || current_instantiation () == 0)
2228 record_last_problematic_instantiation ();
2229 print_instantiation_full_context (context
);
2232 /* Report the bare minimum context of a template instantiation. */
2234 print_instantiation_context (void)
2236 print_instantiation_partial_context
2237 (global_dc
, current_instantiation (), input_location
);
2238 diagnostic_flush_buffer (global_dc
);
2241 /* Called from output_format -- during diagnostic message processing --
2242 to handle C++ specific format specifier with the following meanings:
2243 %A function argument-list.
2247 %F function declaration.
2248 %L language as used in extern "lang".
2250 %P function parameter whose position is indicated by an integer.
2251 %Q assignment operator.
2255 cp_printer (pretty_printer
*pp
, text_info
*text
)
2259 #define next_tree va_arg (*text->args_ptr, tree)
2260 #define next_tcode va_arg (*text->args_ptr, enum tree_code)
2261 #define next_lang va_arg (*text->args_ptr, enum languages)
2262 #define next_int va_arg (*text->args_ptr, int)
2264 if (*text
->format_spec
== '+')
2265 ++text
->format_spec
;
2266 if (*text
->format_spec
== '#')
2269 ++text
->format_spec
;
2272 switch (*text
->format_spec
)
2274 case 'A': result
= args_to_string (next_tree
, verbose
); break;
2275 case 'C': result
= code_to_string (next_tcode
); break;
2276 case 'D': result
= decl_to_string (next_tree
, verbose
); break;
2277 case 'E': result
= expr_to_string (next_tree
); break;
2278 case 'F': result
= fndecl_to_string (next_tree
, verbose
); break;
2279 case 'L': result
= language_to_string (next_lang
); break;
2280 case 'O': result
= op_to_string (next_tcode
); break;
2281 case 'P': result
= parm_to_string (next_int
); break;
2282 case 'Q': result
= assop_to_string (next_tcode
); break;
2283 case 'T': result
= type_to_string (next_tree
, verbose
); break;
2284 case 'V': result
= cv_to_string (next_tree
, verbose
); break;
2290 pp_base_string (pp
, result
);
2299 pp_non_consecutive_character (cxx_pretty_printer
*pp
, int c
)
2301 const char *p
= pp_last_position_in_text (pp
);
2303 if (p
!= NULL
&& *p
== c
)
2305 pp_character (pp
, c
);
2308 /* These are temporary wrapper functions which handle the historic
2309 behavior of cp_*_at. */
2312 locate_error (const char *msgid
, va_list ap
)
2318 for (f
= msgid
; *f
; f
++)
2331 /* Just ignore these possibilities. */
2334 case 'd': (void) va_arg (ap
, int); break;
2335 case 's': (void) va_arg (ap
, char *); break;
2336 case 'L': (void) va_arg (ap
, enum languages
); break;
2339 case 'Q': (void) va_arg (ap
, enum tree_code
); break;
2341 /* These take a tree, which may be where the error is
2349 t
= va_arg (ap
, tree
);
2355 errorcount
= 0; /* damn ICE suppression */
2356 internal_error ("unexpected letter `%c' in locate_error\n", *f
);
2362 here
= va_arg (ap
, tree
);
2369 cp_error_at (const char *msgid
, ...)
2372 diagnostic_info diagnostic
;
2375 va_start (ap
, msgid
);
2376 here
= locate_error (msgid
, ap
);
2379 va_start (ap
, msgid
);
2380 diagnostic_set_info (&diagnostic
, msgid
, &ap
,
2381 location_of (here
), DK_ERROR
);
2382 report_diagnostic (&diagnostic
);
2387 cp_warning_at (const char *msgid
, ...)
2390 diagnostic_info diagnostic
;
2393 va_start (ap
, msgid
);
2394 here
= locate_error (msgid
, ap
);
2397 va_start (ap
, msgid
);
2398 diagnostic_set_info (&diagnostic
, msgid
, &ap
,
2399 location_of (here
), DK_WARNING
);
2400 report_diagnostic (&diagnostic
);
2405 cp_pedwarn_at (const char *msgid
, ...)
2408 diagnostic_info diagnostic
;
2411 va_start (ap
, msgid
);
2412 here
= locate_error (msgid
, ap
);
2415 va_start (ap
, msgid
);
2416 diagnostic_set_info (&diagnostic
, msgid
, &ap
,
2417 location_of (here
), pedantic_error_kind());
2418 report_diagnostic (&diagnostic
);