LCOV - code coverage report
Current view: top level - gcc/cp - error.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 87.9 % 2631 2313
Test Date: 2025-03-22 13:13:03 Functions: 94.2 % 104 98
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Call-backs for C++ error reporting.
       2                 :             :    This code is non-reentrant.
       3                 :             :    Copyright (C) 1993-2025 Free Software Foundation, Inc.
       4                 :             :    This file is part of GCC.
       5                 :             : 
       6                 :             : GCC is free software; you can redistribute it and/or modify
       7                 :             : it under the terms of the GNU General Public License as published by
       8                 :             : the Free Software Foundation; either version 3, or (at your option)
       9                 :             : any later version.
      10                 :             : 
      11                 :             : GCC is distributed in the hope that it will be useful,
      12                 :             : but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14                 :             : GNU General Public License for more details.
      15                 :             : 
      16                 :             : You should have received a copy of the GNU General Public License
      17                 :             : along with GCC; see the file COPYING3.  If not see
      18                 :             : <http://www.gnu.org/licenses/>.  */
      19                 :             : 
      20                 :             : #include "config.h"
      21                 :             : /* For use with name_hint.  */
      22                 :             : #include "system.h"
      23                 :             : #include "coretypes.h"
      24                 :             : #include "cp-tree.h"
      25                 :             : #include "stringpool.h"
      26                 :             : #include "tree-diagnostic.h"
      27                 :             : #include "diagnostic-color.h"
      28                 :             : #include "langhooks-def.h"
      29                 :             : #include "intl.h"
      30                 :             : #include "cxx-pretty-print.h"
      31                 :             : #include "tree-pretty-print.h"
      32                 :             : #include "tree-pretty-print-markup.h"
      33                 :             : #include "gimple-pretty-print.h"
      34                 :             : #include "c-family/c-objc.h"
      35                 :             : #include "ubsan.h"
      36                 :             : #include "internal-fn.h"
      37                 :             : #include "c-family/c-type-mismatch.h"
      38                 :             : #include "cp-name-hint.h"
      39                 :             : #include "attribs.h"
      40                 :             : #include "pretty-print-format-impl.h"
      41                 :             : #include "make-unique.h"
      42                 :             : #include "diagnostic-format-text.h"
      43                 :             : 
      44                 :             : #define pp_separate_with_comma(PP) pp_cxx_separate_with (PP, ',')
      45                 :             : #define pp_separate_with_semicolon(PP) pp_cxx_separate_with (PP, ';')
      46                 :             : 
      47                 :             : /* cxx_pp is a C++ front-end-specific pretty printer: this is where we
      48                 :             :    dump C++ ASTs as strings. It is mostly used only by the various
      49                 :             :    tree -> string functions that are occasionally called from the
      50                 :             :    debugger or by the front-end for things like
      51                 :             :    __PRETTY_FUNCTION__.  */
      52                 :             : static cxx_pretty_printer actual_pretty_printer;
      53                 :             : static cxx_pretty_printer * const cxx_pp = &actual_pretty_printer;
      54                 :             : 
      55                 :             : /* Translate if being used for diagnostics, but not for dump files or
      56                 :             :    __PRETTY_FUNCTION.  */
      57                 :             : #define M_(msgid) (pp_translate_identifiers (cxx_pp) ? _(msgid) : (msgid))
      58                 :             : 
      59                 :             : # define NEXT_CODE(T) (TREE_CODE (TREE_TYPE (T)))
      60                 :             : 
      61                 :             : static const char *args_to_string (tree, int);
      62                 :             : static const char *code_to_string (enum tree_code);
      63                 :             : static const char *cv_to_string (tree, int);
      64                 :             : static const char *decl_to_string (tree, int, bool);
      65                 :             : static const char *fndecl_to_string (tree, int);
      66                 :             : static const char *op_to_string (bool, enum tree_code);
      67                 :             : static const char *parm_to_string (int);
      68                 :             : static const char *type_to_string (tree, int, bool, bool *, bool,
      69                 :             :                                    const char * = nullptr);
      70                 :             : 
      71                 :             : static void dump_alias_template_specialization (cxx_pretty_printer *, tree, int);
      72                 :             : static void dump_type (cxx_pretty_printer *, tree, int);
      73                 :             : static void dump_typename (cxx_pretty_printer *, tree, int);
      74                 :             : static void dump_simple_decl (cxx_pretty_printer *, tree, tree, int);
      75                 :             : static void dump_decl (cxx_pretty_printer *, tree, int);
      76                 :             : static void dump_template_decl (cxx_pretty_printer *, tree, int);
      77                 :             : static void dump_function_decl (cxx_pretty_printer *, tree, int);
      78                 :             : static void dump_expr (cxx_pretty_printer *, tree, int);
      79                 :             : static void dump_unary_op (cxx_pretty_printer *, const char *, tree, int);
      80                 :             : static void dump_binary_op (cxx_pretty_printer *, const char *, tree, int);
      81                 :             : static void dump_aggr_type (cxx_pretty_printer *, tree, int);
      82                 :             : static void dump_type_prefix (cxx_pretty_printer *, tree, int);
      83                 :             : static void dump_type_suffix (cxx_pretty_printer *, tree, int);
      84                 :             : static void dump_function_name (cxx_pretty_printer *, tree, int);
      85                 :             : static void dump_call_expr_args (cxx_pretty_printer *, tree, int, bool);
      86                 :             : static void dump_expr_list (cxx_pretty_printer *, tree, int);
      87                 :             : static void dump_global_iord (cxx_pretty_printer *, tree);
      88                 :             : static void dump_parameters (cxx_pretty_printer *, tree, int);
      89                 :             : static void dump_ref_qualifier (cxx_pretty_printer *, tree, int);
      90                 :             : static void dump_exception_spec (cxx_pretty_printer *, tree, int);
      91                 :             : static void dump_template_argument (cxx_pretty_printer *, tree, int);
      92                 :             : static void dump_template_argument_list (cxx_pretty_printer *, tree, int);
      93                 :             : static void dump_template_parameter (cxx_pretty_printer *, tree, int);
      94                 :             : static void dump_template_bindings (cxx_pretty_printer *, tree, tree,
      95                 :             :                                     vec<tree, va_gc> *);
      96                 :             : static void dump_scope (cxx_pretty_printer *, tree, int);
      97                 :             : static void dump_template_parms (cxx_pretty_printer *, tree, int, int);
      98                 :             : static int get_non_default_template_args_count (tree, int);
      99                 :             : static const char *function_category (tree);
     100                 :             : static void maybe_print_constexpr_context (diagnostic_text_output_format &);
     101                 :             : static void maybe_print_instantiation_context (diagnostic_text_output_format &);
     102                 :             : static void print_instantiation_full_context (diagnostic_text_output_format &);
     103                 :             : static void print_instantiation_partial_context (diagnostic_text_output_format &,
     104                 :             :                                                  struct tinst_level *,
     105                 :             :                                                  location_t);
     106                 :             : static void maybe_print_constraint_context (diagnostic_text_output_format &);
     107                 :             : static void cp_diagnostic_text_starter (diagnostic_text_output_format &,
     108                 :             :                                         const diagnostic_info *);
     109                 :             : static void cp_print_error_function (diagnostic_text_output_format &,
     110                 :             :                                      const diagnostic_info *);
     111                 :             : 
     112                 :             : static bool cp_printer (pretty_printer *, text_info *, const char *,
     113                 :             :                         int, bool, bool, bool, bool *, pp_token_list &);
     114                 :             : 
     115                 :             : /* Color names for highlighting "%qH" vs "%qI" values,
     116                 :             :    and ranges corresponding to them.  */
     117                 :             : const char *const highlight_colors::percent_h = "highlight-a";
     118                 :             : const char *const highlight_colors::percent_i = "highlight-b";
     119                 :             : 
     120                 :             : /* Struct for handling %H or %I, which require delaying printing the
     121                 :             :    type until a postprocessing stage.  */
     122                 :             : 
     123                 :      125784 : class deferred_printed_type
     124                 :             : {
     125                 :             : public:
     126                 :      327136 :   deferred_printed_type ()
     127                 :      327136 :   : m_tree (NULL_TREE),
     128                 :       93457 :     m_printed_text (),
     129                 :      327136 :     m_token_list (nullptr),
     130                 :       20964 :     m_verbose (false), m_quote (false)
     131                 :             :   {}
     132                 :             : 
     133                 :       20964 :   deferred_printed_type (tree type,
     134                 :             :                          pp_token_list &token_list,
     135                 :             :                          bool verbose,
     136                 :             :                          bool quote)
     137                 :       20964 :   : m_tree (type),
     138                 :       20964 :     m_printed_text (),
     139                 :       20964 :     m_token_list (&token_list),
     140                 :       20964 :     m_verbose (verbose),
     141                 :       20964 :     m_quote (quote)
     142                 :             :   {
     143                 :       20964 :     gcc_assert (type);
     144                 :             :   }
     145                 :             : 
     146                 :       20964 :   void set_text_for_token_list (const char *text, bool quote)
     147                 :             :   {
     148                 :             :     /* Replace the contents of m_token_list with a text token for TEXT,
     149                 :             :        possibly wrapped by BEGIN_QUOTE/END_QUOTE (if QUOTE is true).
     150                 :             :        This allows us to ignore any {BEGIN,END}_QUOTE tokens added
     151                 :             :        by %qH and %qI, and instead use the quoting from type_to_string,
     152                 :             :        and its logic for "aka".  */
     153                 :       62892 :     while (m_token_list->m_first)
     154                 :       41928 :       m_token_list->pop_front ();
     155                 :             : 
     156                 :       20964 :     if (quote)
     157                 :         340 :       m_token_list->push_back<pp_token_begin_quote> ();
     158                 :             : 
     159                 :             :     // TEXT is gc-allocated, so we can borrow it
     160                 :       20964 :     m_token_list->push_back_text (label_text::borrow (text));
     161                 :             : 
     162                 :       20964 :     if (quote)
     163                 :         340 :       m_token_list->push_back<pp_token_end_quote> ();
     164                 :       20964 :   }
     165                 :             : 
     166                 :             :   /* The tree is not GTY-marked: they are only non-NULL within a
     167                 :             :      call to pp_format.  */
     168                 :             :   tree m_tree;
     169                 :             :   label_text m_printed_text;
     170                 :             :   pp_token_list *m_token_list;
     171                 :             :   bool m_verbose;
     172                 :             :   bool m_quote;
     173                 :             : };
     174                 :             : 
     175                 :             : /* Subclass of format_postprocessor for the C++ frontend.
     176                 :             :    This handles the %H and %I formatting codes, printing them
     177                 :             :    in a postprocessing phase (since they affect each other).  */
     178                 :             : 
     179                 :             : class cxx_format_postprocessor : public format_postprocessor
     180                 :             : {
     181                 :             :  public:
     182                 :      306172 :   cxx_format_postprocessor ()
     183                 :      306172 :   : m_type_a (), m_type_b ()
     184                 :             :   {}
     185                 :             : 
     186                 :      212715 :   format_postprocessor *clone() const final override
     187                 :             :   {
     188                 :      212715 :     return new cxx_format_postprocessor ();
     189                 :             :   }
     190                 :             : 
     191                 :             :   void handle (pretty_printer *pp) final override;
     192                 :             : 
     193                 :             :   deferred_printed_type m_type_a;
     194                 :             :   deferred_printed_type m_type_b;
     195                 :             : };
     196                 :             : 
     197                 :             : /* Return the in-scope template that's currently being parsed, or
     198                 :             :    NULL_TREE otherwise.  */
     199                 :             : 
     200                 :             : static tree
     201                 :       81222 : get_current_template ()
     202                 :             : {
     203                 :       81222 :   if (scope_chain && in_template_context && !current_instantiation ())
     204                 :       10186 :     if (tree ti = get_template_info (current_scope ()))
     205                 :             :       {
     206                 :        4417 :         if (PRIMARY_TEMPLATE_P (TI_TEMPLATE (ti)) && TI_PARTIAL_INFO (ti))
     207                 :          21 :           ti = TI_PARTIAL_INFO (ti);
     208                 :        4417 :         return TI_TEMPLATE (ti);
     209                 :             :       }
     210                 :             : 
     211                 :             :   return NULL_TREE;
     212                 :             : }
     213                 :             : 
     214                 :             : /* A map from TEMPLATE_DECLs that we've determined to be erroneous
     215                 :             :    at parse time to the location of the first error within.  */
     216                 :             : 
     217                 :             : erroneous_templates_t *erroneous_templates;
     218                 :             : 
     219                 :             : /* Callback function diagnostic_context::m_adjust_diagnostic_info.
     220                 :             : 
     221                 :             :    Errors issued when parsing a template are automatically treated like
     222                 :             :    permerrors associated with the -Wtemplate-body flag and can be
     223                 :             :    downgraded into warnings accordingly, in which case we'll still
     224                 :             :    issue an error if we later need to instantiate the template.  */
     225                 :             : 
     226                 :             : static void
     227                 :    83279918 : cp_adjust_diagnostic_info (diagnostic_context *context,
     228                 :             :                            diagnostic_info *diagnostic)
     229                 :             : {
     230                 :    83279918 :   if (diagnostic->kind == DK_ERROR)
     231                 :       81210 :     if (tree tmpl = get_current_template ())
     232                 :             :       {
     233                 :        4405 :         diagnostic->option_id = OPT_Wtemplate_body;
     234                 :             : 
     235                 :        4405 :         if (context->m_permissive)
     236                 :          48 :           diagnostic->kind = DK_WARNING;
     237                 :             : 
     238                 :        4405 :         bool existed;
     239                 :        4405 :         location_t &error_loc
     240                 :        4405 :           = hash_map_safe_get_or_insert<true> (erroneous_templates,
     241                 :             :                                                tmpl, &existed);
     242                 :        4405 :         if (!existed)
     243                 :             :           /* Remember that this template had a parse-time error so
     244                 :             :              that we'll ensure a hard error has been issued upon
     245                 :             :              its instantiation.  */
     246                 :        2178 :           error_loc = diagnostic->richloc->get_loc ();
     247                 :             :       }
     248                 :    83279918 : }
     249                 :             : 
     250                 :             : /* A generalization of seen_error which also returns true if we've
     251                 :             :    permissively downgraded an error to a warning inside a template.  */
     252                 :             : 
     253                 :             : bool
     254                 :     7756560 : cp_seen_error ()
     255                 :             : {
     256                 :     7756560 :   if ((seen_error) ())
     257                 :             :     return true;
     258                 :             : 
     259                 :     7736956 :   if (erroneous_templates)
     260                 :          12 :     if (tree tmpl = get_current_template ())
     261                 :          12 :       if (erroneous_templates->get (tmpl))
     262                 :          12 :         return true;
     263                 :             : 
     264                 :             :   return false;
     265                 :             : }
     266                 :             : 
     267                 :             : /* CONTEXT->printer is a basic pretty printer that was constructed
     268                 :             :    presumably by diagnostic_initialize(), called early in the
     269                 :             :    compiler's initialization process (in general_init) Before the FE
     270                 :             :    is initialized.  This (C++) FE-specific diagnostic initializer is
     271                 :             :    thus replacing the basic pretty printer with one that has C++-aware
     272                 :             :    capacities.  */
     273                 :             : 
     274                 :             : void
     275                 :       93457 : cxx_initialize_diagnostics (diagnostic_context *context)
     276                 :             : {
     277                 :       93457 :   cxx_pretty_printer *pp = new cxx_pretty_printer ();
     278                 :       93457 :   pp_format_postprocessor (pp) = new cxx_format_postprocessor ();
     279                 :       93457 :   context->set_pretty_printer (std::unique_ptr<pretty_printer> (pp));
     280                 :             : 
     281                 :       93457 :   c_common_diagnostics_set_defaults (context);
     282                 :       93457 :   diagnostic_text_starter (context) = cp_diagnostic_text_starter;
     283                 :             :   /* diagnostic_finalizer is already c_diagnostic_text_finalizer.  */
     284                 :       93457 :   context->set_format_decoder (cp_printer);
     285                 :       93457 :   context->m_adjust_diagnostic_info = cp_adjust_diagnostic_info;
     286                 :       93457 : }
     287                 :             : 
     288                 :             : /* Dump an '@module' name suffix for DECL, if it's attached to an import.  */
     289                 :             : 
     290                 :             : static void
     291                 :   183282832 : dump_module_suffix (cxx_pretty_printer *pp, tree decl)
     292                 :             : {
     293                 :   183282832 :   if (!modules_p ())
     294                 :             :     return;
     295                 :             : 
     296                 :        7195 :   if (!DECL_CONTEXT (decl))
     297                 :             :     return;
     298                 :             : 
     299                 :        6842 :   if (TREE_CODE (decl) != CONST_DECL
     300                 :        6842 :       || !UNSCOPED_ENUM_P (DECL_CONTEXT (decl)))
     301                 :             :     {
     302                 :        6814 :       if (!DECL_NAMESPACE_SCOPE_P (decl))
     303                 :             :         return;
     304                 :             : 
     305                 :        4463 :       if (TREE_CODE (decl) == NAMESPACE_DECL
     306                 :           0 :           && !DECL_NAMESPACE_ALIAS (decl)
     307                 :        4463 :           && (TREE_PUBLIC (decl) || !TREE_PUBLIC (CP_DECL_CONTEXT (decl))))
     308                 :             :         return;
     309                 :             :     }
     310                 :             : 
     311                 :        4491 :   if (unsigned m = get_originating_module (decl))
     312                 :         464 :     if (const char *n = module_name (m, false))
     313                 :             :       {
     314                 :         294 :         pp_character (pp, '@');
     315                 :         294 :         pp->set_padding (pp_none);
     316                 :         294 :         pp_string (pp, n);
     317                 :             :       }
     318                 :             : }
     319                 :             : 
     320                 :             : /* The scope of the declaration we're currently printing, to avoid redundantly
     321                 :             :    dumping the same scope on parameter types.  */
     322                 :             : static tree current_dump_scope;
     323                 :             : 
     324                 :             : /* Dump a scope, if deemed necessary.  */
     325                 :             : 
     326                 :             : static void
     327                 :   138011530 : dump_scope (cxx_pretty_printer *pp, tree scope, int flags)
     328                 :             : {
     329                 :   138011530 :   int f = flags & (TFF_SCOPE | TFF_CHASE_TYPEDEF);
     330                 :             : 
     331                 :   138011530 :   if (scope == NULL_TREE || scope == current_dump_scope)
     332                 :             :     return;
     333                 :             : 
     334                 :             :   /* Enum values within an unscoped enum will be CONST_DECL with an
     335                 :             :      ENUMERAL_TYPE as their "scope".  Use CP_TYPE_CONTEXT of the
     336                 :             :      ENUMERAL_TYPE, so as to print any enclosing namespace.  */
     337                 :   137842080 :   if (UNSCOPED_ENUM_P (scope))
     338                 :         180 :     scope = CP_TYPE_CONTEXT (scope);
     339                 :             : 
     340                 :   137842080 :   if (TREE_CODE (scope) == NAMESPACE_DECL)
     341                 :             :     {
     342                 :   118915222 :       if (scope != global_namespace)
     343                 :             :         {
     344                 :    65232231 :           dump_decl (pp, scope, f);
     345                 :    65232231 :           pp_cxx_colon_colon (pp);
     346                 :             :         }
     347                 :             :     }
     348                 :    18926858 :   else if (AGGREGATE_TYPE_P (scope)
     349                 :    18926858 :            || SCOPED_ENUM_P (scope))
     350                 :             :     {
     351                 :    18497034 :       dump_type (pp, scope, f);
     352                 :    18497034 :       pp_cxx_colon_colon (pp);
     353                 :             :     }
     354                 :      429824 :   else if ((flags & TFF_SCOPE) && TREE_CODE (scope) == FUNCTION_DECL)
     355                 :             :     {
     356                 :      417414 :       dump_function_decl (pp, scope, f | TFF_NO_TEMPLATE_BINDINGS);
     357                 :      417414 :       pp_cxx_colon_colon (pp);
     358                 :             :     }
     359                 :             : }
     360                 :             : 
     361                 :             : /* Dump the template ARGument under control of FLAGS.  */
     362                 :             : 
     363                 :             : static void
     364                 :   112617762 : dump_template_argument (cxx_pretty_printer *pp, tree arg, int flags)
     365                 :             : {
     366                 :   112617762 :   if (ARGUMENT_PACK_P (arg))
     367                 :     6330159 :     dump_template_argument_list (pp, ARGUMENT_PACK_ARGS (arg),
     368                 :             :                                  /* No default args in argument packs.  */
     369                 :             :                                  flags|TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS);
     370                 :   106287603 :   else if (TYPE_P (arg) || TREE_CODE (arg) == TEMPLATE_DECL)
     371                 :    94036932 :     dump_type (pp, arg, flags & ~TFF_CLASS_KEY_OR_ENUM);
     372                 :             :   else
     373                 :             :     {
     374                 :    12250671 :       if (TREE_CODE (arg) == TREE_LIST)
     375                 :           0 :         arg = TREE_VALUE (arg);
     376                 :             : 
     377                 :             :       /* Strip implicit conversions.  */
     378                 :    12250734 :       while (CONVERT_EXPR_P (arg))
     379                 :          63 :         arg = TREE_OPERAND (arg, 0);
     380                 :             : 
     381                 :    12250671 :       dump_expr (pp, arg, (flags | TFF_EXPR_IN_PARENS) & ~TFF_CLASS_KEY_OR_ENUM);
     382                 :             :     }
     383                 :   112617762 : }
     384                 :             : 
     385                 :             : /* Count the number of template arguments ARGS whose value does not
     386                 :             :    match the (optional) default template parameter in PARAMS  */
     387                 :             : 
     388                 :             : static int
     389                 :    72352850 : get_non_default_template_args_count (tree args, int flags)
     390                 :             : {
     391                 :    72352850 :   int n = TREE_VEC_LENGTH (INNERMOST_TEMPLATE_ARGS (args));
     392                 :             : 
     393                 :    72352850 :   if (/* We use this flag when generating debug information.  We don't
     394                 :             :          want to expand templates at this point, for this may generate
     395                 :             :          new decls, which gets decl counts out of sync, which may in
     396                 :             :          turn cause codegen differences between compilations with and
     397                 :             :          without -g.  */
     398                 :    72352850 :       (flags & TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS) != 0
     399                 :     3102823 :       || !flag_pretty_templates)
     400                 :             :     return n;
     401                 :             : 
     402                 :     3102766 :   return GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (INNERMOST_TEMPLATE_ARGS (args));
     403                 :             : }
     404                 :             : 
     405                 :             : /* Dump a template-argument-list ARGS (always a TREE_VEC) under control
     406                 :             :    of FLAGS.  */
     407                 :             : 
     408                 :             : static void
     409                 :     6333326 : dump_template_argument_list (cxx_pretty_printer *pp, tree args, int flags)
     410                 :             : {
     411                 :     6333326 :   int n = get_non_default_template_args_count (args, flags);
     412                 :     6333326 :   int need_comma = 0;
     413                 :     6333326 :   int i;
     414                 :             : 
     415                 :    19851382 :   for (i = 0; i < n; ++i)
     416                 :             :     {
     417                 :    13518056 :       tree arg = TREE_VEC_ELT (args, i);
     418                 :             : 
     419                 :             :       /* Only print a comma if we know there is an argument coming. In
     420                 :             :          the case of an empty template argument pack, no actual
     421                 :             :          argument will be printed.  */
     422                 :    13518056 :       if (need_comma
     423                 :    13518056 :           && (!ARGUMENT_PACK_P (arg)
     424                 :         144 :               || TREE_VEC_LENGTH (ARGUMENT_PACK_ARGS (arg)) > 0))
     425                 :     7691207 :         pp_separate_with_comma (pp);
     426                 :             : 
     427                 :    13518056 :       dump_template_argument (pp, arg, flags);
     428                 :    13518056 :       need_comma = 1;
     429                 :             :     }
     430                 :     6333326 : }
     431                 :             : 
     432                 :             : /* Dump a template parameter PARM (a TREE_LIST) under control of FLAGS.  */
     433                 :             : 
     434                 :             : static void
     435                 :       52355 : dump_template_parameter (cxx_pretty_printer *pp, tree parm, int flags)
     436                 :             : {
     437                 :       52355 :   tree p;
     438                 :       52355 :   tree a;
     439                 :             : 
     440                 :       52355 :   if (parm == error_mark_node)
     441                 :             :    return;
     442                 :             : 
     443                 :       52355 :   p = TREE_VALUE (parm);
     444                 :       52355 :   a = TREE_PURPOSE (parm);
     445                 :             : 
     446                 :       52355 :   if (TREE_CODE (p) == TYPE_DECL)
     447                 :             :     {
     448                 :       46563 :       if (flags & TFF_DECL_SPECIFIERS)
     449                 :             :         {
     450                 :       11249 :           pp_cxx_ws_string (pp, "class");
     451                 :       11249 :           if (TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (p)))
     452                 :         791 :             pp_cxx_ws_string (pp, "...");
     453                 :       11249 :           if (DECL_NAME (p))
     454                 :       10519 :             pp_cxx_tree_identifier (pp, DECL_NAME (p));
     455                 :             :         }
     456                 :       35314 :       else if (DECL_NAME (p))
     457                 :       34545 :         pp_cxx_tree_identifier (pp, DECL_NAME (p));
     458                 :             :       else
     459                 :         769 :         pp_cxx_canonical_template_parameter (pp, TREE_TYPE (p));
     460                 :             :     }
     461                 :             :   else
     462                 :        5792 :     dump_decl (pp, p, flags | TFF_DECL_SPECIFIERS);
     463                 :             : 
     464                 :       52355 :   if ((flags & TFF_FUNCTION_DEFAULT_ARGUMENTS) && a != NULL_TREE)
     465                 :             :     {
     466                 :           0 :       pp_cxx_whitespace (pp);
     467                 :           0 :       pp_equal (pp);
     468                 :           0 :       pp_cxx_whitespace (pp);
     469                 :           0 :       if (TREE_CODE (p) == TYPE_DECL || TREE_CODE (p) == TEMPLATE_DECL)
     470                 :           0 :         dump_type (pp, a, flags & ~TFF_CHASE_TYPEDEF);
     471                 :             :       else
     472                 :           0 :         dump_expr (pp, a, flags | TFF_EXPR_IN_PARENS);
     473                 :             :     }
     474                 :             : }
     475                 :             : 
     476                 :             : /* Dump, under control of FLAGS, a template-parameter-list binding.
     477                 :             :    PARMS is a TREE_LIST of TREE_VEC of TREE_LIST and ARGS is a
     478                 :             :    TREE_VEC.  */
     479                 :             : 
     480                 :             : static void
     481                 :       24372 : dump_template_bindings (cxx_pretty_printer *pp, tree parms, tree args,
     482                 :             :                         vec<tree, va_gc> *typenames)
     483                 :             : {
     484                 :             :   /* Print "[with" and ']', conditional on whether anything is printed at all.
     485                 :             :      This is tied to whether a semicolon is needed to separate multiple template
     486                 :             :      parameters.  */
     487                 :       24372 :   struct prepost_semicolon
     488                 :             :   {
     489                 :             :     cxx_pretty_printer *pp;
     490                 :             :     bool need_semicolon;
     491                 :             : 
     492                 :       47040 :     void operator() ()
     493                 :             :     {
     494                 :       47040 :       if (need_semicolon)
     495                 :       22668 :         pp_separate_with_semicolon (pp);
     496                 :             :       else
     497                 :             :         {
     498                 :       24372 :           pp_cxx_whitespace (pp);
     499                 :       24372 :           pp_string (pp, colorize_start (pp_show_color (pp), "targs"));
     500                 :       24372 :           pp_cxx_left_bracket (pp);
     501                 :       24372 :           pp->translate_string ("with");
     502                 :       24372 :           pp_cxx_whitespace (pp);
     503                 :       24372 :           need_semicolon = true;
     504                 :             :         }
     505                 :       47040 :     }
     506                 :             : 
     507                 :       24372 :     ~prepost_semicolon ()
     508                 :             :     {
     509                 :       24372 :       if (need_semicolon)
     510                 :             :         {
     511                 :       24372 :           pp_cxx_right_bracket (pp);
     512                 :       24372 :           pp_string (pp, colorize_stop (pp_show_color (pp)));
     513                 :             :         }
     514                 :       24372 :     }
     515                 :       24372 :   } semicolon_or_introducer = {pp, false};
     516                 :             : 
     517                 :       24372 :   int i;
     518                 :       24372 :   tree t;
     519                 :             : 
     520                 :       50272 :   while (parms)
     521                 :             :     {
     522                 :       25900 :       tree p = TREE_VALUE (parms);
     523                 :       25900 :       int lvl = TMPL_PARMS_DEPTH (parms);
     524                 :       25900 :       int arg_idx = 0;
     525                 :       25900 :       int i;
     526                 :       25900 :       tree lvl_args = NULL_TREE;
     527                 :             : 
     528                 :             :       /* Don't crash if we had an invalid argument list.  */
     529                 :       74466 :       if (TMPL_ARGS_DEPTH (args) >= lvl)
     530                 :       51800 :         lvl_args = TMPL_ARGS_LEVEL (args, lvl);
     531                 :             : 
     532                 :       65789 :       for (i = 0; i < TREE_VEC_LENGTH (p); ++i)
     533                 :             :         {
     534                 :       39889 :           tree arg = NULL_TREE;
     535                 :             : 
     536                 :             :           /* Don't crash if we had an invalid argument list.  */
     537                 :       79778 :           if (lvl_args && NUM_TMPL_ARGS (lvl_args) > arg_idx)
     538                 :       39883 :             arg = TREE_VEC_ELT (lvl_args, arg_idx);
     539                 :             : 
     540                 :       39889 :           tree parm_i = TREE_VEC_ELT (p, i);
     541                 :             :           /* If the template argument repeats the template parameter (T = T),
     542                 :             :              skip the parameter.*/
     543                 :       39852 :           if (arg && TREE_CODE (arg) == TEMPLATE_TYPE_PARM
     544                 :        1040 :                 && TREE_CODE (parm_i) == TREE_LIST
     545                 :        1040 :                 && TREE_CODE (TREE_VALUE (parm_i)) == TYPE_DECL
     546                 :        1020 :                 && TREE_CODE (TREE_TYPE (TREE_VALUE (parm_i)))
     547                 :             :                      == TEMPLATE_TYPE_PARM
     548                 :       40909 :                 && DECL_NAME (TREE_VALUE (parm_i))
     549                 :        1020 :                      == DECL_NAME (TREE_CHAIN (arg)))
     550                 :         583 :             continue;
     551                 :             : 
     552                 :       39306 :           semicolon_or_introducer ();
     553                 :       39306 :           dump_template_parameter (pp, parm_i, TFF_PLAIN_IDENTIFIER);
     554                 :       39306 :           pp_cxx_whitespace (pp);
     555                 :       39306 :           pp_equal (pp);
     556                 :       39306 :           pp_cxx_whitespace (pp);
     557                 :       39306 :           if (arg)
     558                 :             :             {
     559                 :       39269 :               if (ARGUMENT_PACK_P (arg))
     560                 :        1307 :                 pp_cxx_left_brace (pp);
     561                 :       39269 :               dump_template_argument (pp, arg, TFF_PLAIN_IDENTIFIER);
     562                 :       39269 :               if (ARGUMENT_PACK_P (arg))
     563                 :        1307 :                 pp_cxx_right_brace (pp);
     564                 :             :             }
     565                 :             :           else
     566                 :          37 :             pp_string (pp, M_("<missing>"));
     567                 :             : 
     568                 :       39306 :           ++arg_idx;
     569                 :             :         }
     570                 :             : 
     571                 :       25900 :       parms = TREE_CHAIN (parms);
     572                 :             :     }
     573                 :             : 
     574                 :             :   /* Don't bother with typenames for a partial instantiation.  */
     575                 :       30527 :   if (vec_safe_is_empty (typenames) || uses_template_parms (args))
     576                 :       18409 :     return;
     577                 :             : 
     578                 :             :   /* Don't try to print typenames when we're processing a clone.  */
     579                 :        5963 :   if (current_function_decl
     580                 :        5963 :       && !DECL_LANG_SPECIFIC (current_function_decl))
     581                 :             :     return;
     582                 :             : 
     583                 :             :   /* Don't try to do this once cgraph starts throwing away front-end
     584                 :             :      information.  */
     585                 :        5963 :   if (at_eof >= 3)
     586                 :             :     return;
     587                 :             : 
     588                 :       13469 :   FOR_EACH_VEC_SAFE_ELT (typenames, i, t)
     589                 :             :     {
     590                 :        7734 :       semicolon_or_introducer ();
     591                 :        7734 :       dump_type (pp, t, TFF_PLAIN_IDENTIFIER);
     592                 :        7734 :       pp_cxx_whitespace (pp);
     593                 :        7734 :       pp_equal (pp);
     594                 :        7734 :       pp_cxx_whitespace (pp);
     595                 :        7734 :       push_deferring_access_checks (dk_no_check);
     596                 :        7734 :       t = tsubst (t, args, tf_none, NULL_TREE);
     597                 :        7734 :       pop_deferring_access_checks ();
     598                 :             :       /* Strip typedefs.  We can't just use TFF_CHASE_TYPEDEF because
     599                 :             :          pp_simple_type_specifier doesn't know about it.  */
     600                 :        7734 :       t = strip_typedefs (t, NULL, STF_USER_VISIBLE);
     601                 :        7734 :       dump_type (pp, t, TFF_PLAIN_IDENTIFIER);
     602                 :             :     }
     603                 :       24372 : }
     604                 :             : 
     605                 :             : /* Dump a human-readable equivalent of the alias template
     606                 :             :    specialization of T.  */
     607                 :             : 
     608                 :             : static void
     609                 :        5225 : dump_alias_template_specialization (cxx_pretty_printer *pp, tree t, int flags)
     610                 :             : {
     611                 :        5225 :   gcc_assert (alias_template_specialization_p (t, nt_opaque));
     612                 :             : 
     613                 :        5225 :   tree decl = TYPE_NAME (t);
     614                 :        5225 :   if (!(flags & TFF_UNQUALIFIED_NAME))
     615                 :        5225 :     dump_scope (pp, CP_DECL_CONTEXT (decl), flags);
     616                 :        5225 :   pp_cxx_tree_identifier (pp, DECL_NAME (decl));
     617                 :        5225 :   dump_template_parms (pp, DECL_TEMPLATE_INFO (decl),
     618                 :             :                        /*primary=*/false,
     619                 :             :                        flags & ~TFF_TEMPLATE_HEADER);
     620                 :        5225 : }
     621                 :             : 
     622                 :             : /* Dump a human-readable equivalent of TYPE.  FLAGS controls the
     623                 :             :    format.  */
     624                 :             : 
     625                 :             : static void
     626                 :   168030939 : dump_type (cxx_pretty_printer *pp, tree t, int flags)
     627                 :             : {
     628                 :   168030969 :   if (t == NULL_TREE)
     629                 :             :     return;
     630                 :             : 
     631                 :             :   /* Don't print e.g. "struct mytypedef".  */
     632                 :   168030956 :   if (TYPE_P (t) && typedef_variant_p (t))
     633                 :             :     {
     634                 :      748818 :       tree decl = TYPE_NAME (t);
     635                 :      748818 :       if ((flags & TFF_CHASE_TYPEDEF)
     636                 :      748818 :                || DECL_SELF_REFERENCE_P (decl)
     637                 :     1497075 :                || (!flag_pretty_templates
     638                 :           6 :                    && DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl)))
     639                 :             :         {
     640                 :        1134 :           unsigned int stf_flags = (!(pp->flags & pp_c_flag_gnu_v3)
     641                 :         567 :                                     ? STF_USER_VISIBLE : 0);
     642                 :         567 :           t = strip_typedefs (t, NULL, stf_flags);
     643                 :             :         }
     644                 :      748251 :       else if (alias_template_specialization_p (t, nt_opaque))
     645                 :             :         {
     646                 :        5225 :           dump_alias_template_specialization (pp, t, flags);
     647                 :        5225 :           return;
     648                 :             :         }
     649                 :      743026 :       else if (same_type_p (t, TREE_TYPE (decl)))
     650                 :             :         t = decl;
     651                 :             :       else
     652                 :             :         {
     653                 :        2408 :           pp_cxx_cv_qualifier_seq (pp, t);
     654                 :        2408 :           if (! (flags & TFF_UNQUALIFIED_NAME))
     655                 :        2408 :             dump_scope (pp, CP_DECL_CONTEXT (decl), flags);
     656                 :        2408 :           pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t));
     657                 :        2408 :           return;
     658                 :             :         }
     659                 :             :     }
     660                 :             : 
     661                 :   168023323 :   if (TYPE_PTRMEMFUNC_P (t))
     662                 :      303329 :     goto offset_type;
     663                 :             : 
     664                 :   167719994 :   switch (TREE_CODE (t))
     665                 :             :     {
     666                 :         439 :     case LANG_TYPE:
     667                 :         439 :       if (t == init_list_type_node)
     668                 :         277 :         pp_string (pp, M_("<brace-enclosed initializer list>"));
     669                 :         162 :       else if (t == unknown_type_node)
     670                 :         162 :         pp_string (pp, M_("<unresolved overloaded function type>"));
     671                 :             :       else
     672                 :             :         {
     673                 :           0 :           pp_cxx_cv_qualifier_seq (pp, t);
     674                 :           0 :           if (tree id = TYPE_IDENTIFIER (t))
     675                 :           0 :             pp_cxx_tree_identifier (pp, id);
     676                 :             :         }
     677                 :             :       break;
     678                 :             : 
     679                 :           0 :     case TREE_LIST:
     680                 :             :       /* A list of function parms.  */
     681                 :           0 :       dump_parameters (pp, t, flags);
     682                 :           0 :       break;
     683                 :             : 
     684                 :         304 :     case IDENTIFIER_NODE:
     685                 :         304 :       pp_cxx_tree_identifier (pp, t);
     686                 :         304 :       break;
     687                 :             : 
     688                 :          24 :     case TREE_BINFO:
     689                 :          24 :       dump_type (pp, BINFO_TYPE (t), flags);
     690                 :          24 :       break;
     691                 :             : 
     692                 :   105878491 :     case RECORD_TYPE:
     693                 :   105878491 :     case UNION_TYPE:
     694                 :   105878491 :     case ENUMERAL_TYPE:
     695                 :   105878491 :       dump_aggr_type (pp, t, flags);
     696                 :   105878491 :       break;
     697                 :             : 
     698                 :      741176 :     case TYPE_DECL:
     699                 :      741176 :       if (flags & TFF_CHASE_TYPEDEF)
     700                 :             :         {
     701                 :           0 :           dump_type (pp, DECL_ORIGINAL_TYPE (t)
     702                 :           0 :                      ? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t), flags);
     703                 :           0 :           break;
     704                 :             :         }
     705                 :             :       /* Fall through.  */
     706                 :             : 
     707                 :     1114689 :     case TEMPLATE_DECL:
     708                 :     1114689 :     case NAMESPACE_DECL:
     709                 :     1114689 :       dump_decl (pp, t, flags & ~TFF_DECL_SPECIFIERS);
     710                 :     1114689 :       break;
     711                 :             : 
     712                 :    43564832 :     case INTEGER_TYPE:
     713                 :    43564832 :     case REAL_TYPE:
     714                 :    43564832 :     case VOID_TYPE:
     715                 :    43564832 :     case OPAQUE_TYPE:
     716                 :    43564832 :     case BOOLEAN_TYPE:
     717                 :    43564832 :     case COMPLEX_TYPE:
     718                 :    43564832 :     case VECTOR_TYPE:
     719                 :    43564832 :     case FIXED_POINT_TYPE:
     720                 :    43564832 :       pp_type_specifier_seq (pp, t);
     721                 :    43564832 :       break;
     722                 :             : 
     723                 :        1683 :     case TEMPLATE_TEMPLATE_PARM:
     724                 :             :       /* For parameters inside template signature.  */
     725                 :        1683 :       if (TYPE_IDENTIFIER (t))
     726                 :        3276 :         pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t));
     727                 :             :       else
     728                 :          45 :         pp_cxx_canonical_template_parameter (pp, t);
     729                 :             :       break;
     730                 :             : 
     731                 :         516 :     case BOUND_TEMPLATE_TEMPLATE_PARM:
     732                 :         516 :       {
     733                 :         516 :         tree args = TYPE_TI_ARGS (t);
     734                 :         516 :         pp_cxx_cv_qualifier_seq (pp, t);
     735                 :        1032 :         pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t));
     736                 :         516 :         pp_cxx_begin_template_argument_list (pp);
     737                 :         516 :         dump_template_argument_list (pp, args, flags);
     738                 :         516 :         pp_cxx_end_template_argument_list (pp);
     739                 :             :       }
     740                 :         516 :       break;
     741                 :             : 
     742                 :      234278 :     case TEMPLATE_TYPE_PARM:
     743                 :      234278 :       pp_cxx_cv_qualifier_seq (pp, t);
     744                 :      234278 :       if (template_placeholder_p (t))
     745                 :             :         {
     746                 :          59 :           tree tmpl = TREE_TYPE (CLASS_PLACEHOLDER_TEMPLATE (t));
     747                 :         118 :           pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (tmpl));
     748                 :          59 :           pp_string (pp, "<...auto...>");
     749                 :             :         }
     750                 :      234219 :       else if (TYPE_IDENTIFIER (t))
     751                 :      466914 :         pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t));
     752                 :             :       else
     753                 :         762 :         pp_cxx_canonical_template_parameter
     754                 :         762 :           (pp, TEMPLATE_TYPE_PARM_INDEX (t));
     755                 :             :       /* If this is a constrained placeholder, add the requirements.  */
     756                 :      234278 :       if (tree c = PLACEHOLDER_TYPE_CONSTRAINTS (t))
     757                 :         223 :         pp_cxx_constrained_type_spec (pp, c);
     758                 :             :       break;
     759                 :             : 
     760                 :             :       /* This is not always necessary for pointers and such, but doing this
     761                 :             :          reduces code size.  */
     762                 :    17106197 :     case ARRAY_TYPE:
     763                 :    17106197 :     case POINTER_TYPE:
     764                 :    17106197 :     case REFERENCE_TYPE:
     765                 :    17106197 :     case OFFSET_TYPE:
     766                 :    17106197 :     offset_type:
     767                 :    17106197 :     case FUNCTION_TYPE:
     768                 :    17106197 :     case METHOD_TYPE:
     769                 :    17106197 :     {
     770                 :    17106197 :       dump_type_prefix (pp, t, flags);
     771                 :    17106197 :       dump_type_suffix (pp, t, flags);
     772                 :    17106197 :       break;
     773                 :             :     }
     774                 :        3412 :     case TYPENAME_TYPE:
     775                 :        3412 :       if (! (flags & TFF_CHASE_TYPEDEF)
     776                 :        3412 :           && DECL_ORIGINAL_TYPE (TYPE_NAME (t)))
     777                 :             :         {
     778                 :           0 :           dump_decl (pp, TYPE_NAME (t), TFF_PLAIN_IDENTIFIER);
     779                 :           0 :           break;
     780                 :             :         }
     781                 :        3412 :       pp_cxx_cv_qualifier_seq (pp, t);
     782                 :        6797 :       pp_cxx_ws_string (pp,
     783                 :             :                          TYPENAME_IS_ENUM_P (t) ? "enum"
     784                 :             :                          : TYPENAME_IS_CLASS_P (t) ? "class"
     785                 :             :                          : "typename");
     786                 :        3412 :       dump_typename (pp, t, flags);
     787                 :        3412 :       break;
     788                 :             : 
     789                 :           6 :     case UNBOUND_CLASS_TEMPLATE:
     790                 :           6 :       if (! (flags & TFF_UNQUALIFIED_NAME))
     791                 :             :         {
     792                 :           6 :           dump_type (pp, TYPE_CONTEXT (t), flags);
     793                 :           6 :           pp_cxx_colon_colon (pp);
     794                 :             :         }
     795                 :           6 :       pp_cxx_ws_string (pp, "template");
     796                 :           6 :       dump_type (pp, TYPE_IDENTIFIER (t), flags);
     797                 :           6 :       break;
     798                 :             : 
     799                 :           6 :     case TYPEOF_TYPE:
     800                 :           6 :       pp_cxx_ws_string (pp, "__typeof__");
     801                 :           6 :       pp_cxx_whitespace (pp);
     802                 :           6 :       pp_cxx_left_paren (pp);
     803                 :           6 :       dump_expr (pp, TYPEOF_TYPE_EXPR (t), flags & ~TFF_EXPR_IN_PARENS);
     804                 :           6 :       pp_cxx_right_paren (pp);
     805                 :           6 :       break;
     806                 :             : 
     807                 :          60 :     case TRAIT_TYPE:
     808                 :          60 :       pp_cxx_trait (pp, t);
     809                 :          60 :       break;
     810                 :             : 
     811                 :       38855 :     case TYPE_PACK_EXPANSION:
     812                 :       38855 :       dump_type (pp, PACK_EXPANSION_PATTERN (t), flags);
     813                 :       38855 :       pp_cxx_ws_string (pp, "...");
     814                 :       38855 :       break;
     815                 :             : 
     816                 :           5 :     case PACK_INDEX_TYPE:
     817                 :           5 :       dump_type (pp, PACK_INDEX_PACK (t), flags);
     818                 :           5 :       pp_cxx_left_bracket (pp);
     819                 :           5 :       dump_expr (pp, PACK_INDEX_INDEX (t), flags & ~TFF_EXPR_IN_PARENS);
     820                 :           5 :       pp_cxx_right_bracket (pp);
     821                 :           5 :       break;
     822                 :             : 
     823                 :          74 :     case TYPE_ARGUMENT_PACK:
     824                 :          74 :       dump_template_argument (pp, t, flags);
     825                 :          74 :       break;
     826                 :             : 
     827                 :         567 :     case DECLTYPE_TYPE:
     828                 :         567 :       pp_cxx_ws_string (pp, "decltype");
     829                 :         567 :       pp_cxx_whitespace (pp);
     830                 :         567 :       pp_cxx_left_paren (pp);
     831                 :         567 :       dump_expr (pp, DECLTYPE_TYPE_EXPR (t), flags & ~TFF_EXPR_IN_PARENS);
     832                 :         567 :       pp_cxx_right_paren (pp);
     833                 :         567 :       break;
     834                 :             : 
     835                 :       78856 :     case NULLPTR_TYPE:
     836                 :       78856 :       pp_string (pp, "std::nullptr_t");
     837                 :       78856 :       break;
     838                 :             : 
     839                 :           0 :     default:
     840                 :           0 :       pp_unsupported_tree (pp, t);
     841                 :             :       /* Fall through.  */
     842                 :             : 
     843                 :          29 :     case ERROR_MARK:
     844                 :          29 :       pp_string (pp, M_("<type error>"));
     845                 :          29 :       break;
     846                 :             :     }
     847                 :             : }
     848                 :             : 
     849                 :             : /* Dump a TYPENAME_TYPE. We need to notice when the context is itself
     850                 :             :    a TYPENAME_TYPE.  */
     851                 :             : 
     852                 :             : static void
     853                 :        3781 : dump_typename (cxx_pretty_printer *pp, tree t, int flags)
     854                 :             : {
     855                 :        3781 :   tree ctx = TYPE_CONTEXT (t);
     856                 :             : 
     857                 :        3781 :   if (TREE_CODE (ctx) == TYPENAME_TYPE)
     858                 :         369 :     dump_typename (pp, ctx, flags);
     859                 :             :   else
     860                 :        3412 :     dump_type (pp, ctx, flags & ~TFF_CLASS_KEY_OR_ENUM);
     861                 :        3781 :   pp_cxx_colon_colon (pp);
     862                 :        3781 :   dump_decl (pp, TYPENAME_TYPE_FULLNAME (t), flags);
     863                 :        3781 : }
     864                 :             : 
     865                 :             : /* Return the name of the supplied aggregate, or enumeral type.  */
     866                 :             : 
     867                 :             : const char *
     868                 :   106186781 : class_key_or_enum_as_string (tree t)
     869                 :             : {
     870                 :   106186781 :   if (TREE_CODE (t) == ENUMERAL_TYPE)
     871                 :             :     {
     872                 :     2210543 :       if (SCOPED_ENUM_P (t))
     873                 :             :         return "enum class";
     874                 :             :       else
     875                 :     1622146 :         return "enum";
     876                 :             :     }
     877                 :   103976238 :   else if (TREE_CODE (t) == UNION_TYPE)
     878                 :             :     return "union";
     879                 :   103238832 :   else if (TYPE_LANG_SPECIFIC (t) && CLASSTYPE_DECLARED_CLASS (t))
     880                 :    27125171 :     return "class";
     881                 :             :   else
     882                 :             :     return "struct";
     883                 :             : }
     884                 :             : 
     885                 :             : /* Disable warnings about missing quoting in GCC diagnostics for
     886                 :             :    the pp_verbatim call.  Their format strings deliberately don't
     887                 :             :    follow GCC diagnostic conventions.  */
     888                 :             : #if __GNUC__ >= 10
     889                 :             : #pragma GCC diagnostic push
     890                 :             : #pragma GCC diagnostic ignored "-Wformat-diag"
     891                 :             : #endif
     892                 :             : 
     893                 :             : /* Print out a class declaration T under the control of FLAGS,
     894                 :             :    in the form `class foo'.  */
     895                 :             : 
     896                 :             : static void
     897                 :   106186679 : dump_aggr_type (cxx_pretty_printer *pp, tree t, int flags)
     898                 :             : {
     899                 :   106186679 :   const char *variety = class_key_or_enum_as_string (t);
     900                 :   106186679 :   int typdef = 0;
     901                 :   106186679 :   int tmplate = 0;
     902                 :             : 
     903                 :   106186679 :   pp_cxx_cv_qualifier_seq (pp, t);
     904                 :             : 
     905                 :   106186679 :   if (flags & TFF_CLASS_KEY_OR_ENUM)
     906                 :       11314 :     pp_cxx_ws_string (pp, variety);
     907                 :             : 
     908                 :   106186679 :   tree decl = TYPE_NAME (t);
     909                 :             : 
     910                 :   106186679 :   if (decl)
     911                 :             :     {
     912                 :   106186679 :       typdef = (!DECL_ARTIFICIAL (decl)
     913                 :             :                 /* An alias specialization is not considered to be a
     914                 :             :                    typedef.  */
     915                 :   106186679 :                 && !alias_template_specialization_p (t, nt_opaque));
     916                 :             : 
     917                 :      286713 :       if ((typdef
     918                 :      286713 :            && ((flags & TFF_CHASE_TYPEDEF)
     919                 :      286713 :                || (!flag_pretty_templates && DECL_LANG_SPECIFIC (decl)
     920                 :           0 :                    && DECL_TEMPLATE_INFO (decl))))
     921                 :   106186679 :           || DECL_SELF_REFERENCE_P (decl))
     922                 :             :         {
     923                 :           0 :           t = TYPE_MAIN_VARIANT (t);
     924                 :           0 :           decl = TYPE_NAME (t);
     925                 :           0 :           typdef = 0;
     926                 :             :         }
     927                 :             : 
     928                 :   105899966 :       tmplate = !typdef && TREE_CODE (t) != ENUMERAL_TYPE
     929                 :   103689506 :                 && TYPE_LANG_SPECIFIC (t) && CLASSTYPE_TEMPLATE_INFO (t)
     930                 :   173321334 :                 && (TREE_CODE (CLASSTYPE_TI_TEMPLATE (t)) != TEMPLATE_DECL
     931                 :    67134655 :                     || PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t)));
     932                 :             : 
     933                 :   106186679 :       if (! (flags & TFF_UNQUALIFIED_NAME))
     934                 :    71528288 :         dump_scope (pp, CP_DECL_CONTEXT (decl), flags | TFF_SCOPE);
     935                 :   106186679 :       flags &= ~TFF_UNQUALIFIED_NAME;
     936                 :   106186679 :       if (tmplate)
     937                 :             :         {
     938                 :             :           /* Because the template names are mangled, we have to locate
     939                 :             :              the most general template, and use that name.  */
     940                 :    65832175 :           tree tpl = TYPE_TI_TEMPLATE (t);
     941                 :             : 
     942                 :    66439859 :           while (DECL_TEMPLATE_INFO (tpl))
     943                 :      607684 :             tpl = DECL_TI_TEMPLATE (tpl);
     944                 :             :           decl = tpl;
     945                 :             :         }
     946                 :             :     }
     947                 :             : 
     948                 :   209425331 :   if (LAMBDA_TYPE_P (t))
     949                 :             :     {
     950                 :             :       /* A lambda's "type" is essentially its signature.  */
     951                 :      322567 :       pp_string (pp, M_("<lambda"));
     952                 :      322567 :       tree const fn = lambda_function (t);
     953                 :      322567 :       if (fn)
     954                 :             :         {
     955                 :      322549 :           int const parm_flags
     956                 :      322549 :             = DECL_XOBJ_MEMBER_FUNCTION_P (fn) ? TFF_XOBJ_FUNC | flags
     957                 :      322549 :                                                : flags;
     958                 :      322549 :           dump_parameters (pp, FUNCTION_FIRST_USER_PARMTYPE (fn), parm_flags);
     959                 :             :         }
     960                 :      322567 :       pp_greater (pp);
     961                 :             :     }
     962                 :   105864112 :   else if (!decl || IDENTIFIER_ANON_P (DECL_NAME (decl)))
     963                 :             :     {
     964                 :        2201 :       if (flags & TFF_CLASS_KEY_OR_ENUM)
     965                 :         206 :         pp_string (pp, M_("<unnamed>"));
     966                 :             :       else
     967                 :        1995 :         pp_printf (pp, M_("<unnamed %s>"), variety);
     968                 :             :     }
     969                 :             :   else
     970                 :   105861911 :     pp_cxx_tree_identifier (pp, DECL_NAME (decl));
     971                 :             : 
     972                 :   106186679 :   dump_module_suffix (pp, decl);
     973                 :             : 
     974                 :   106186679 :   if (tmplate)
     975                 :    65832175 :     dump_template_parms (pp, TYPE_TEMPLATE_INFO (t),
     976                 :    65832175 :                          !CLASSTYPE_USE_TEMPLATE (t),
     977                 :             :                          flags & ~TFF_TEMPLATE_HEADER);
     978                 :   106186679 : }
     979                 :             : 
     980                 :             : #if __GNUC__ >= 10
     981                 :             : #pragma GCC diagnostic pop
     982                 :             : #endif
     983                 :             : 
     984                 :             : /* Dump into the obstack the initial part of the output for a given type.
     985                 :             :    This is necessary when dealing with things like functions returning
     986                 :             :    functions.  Examples:
     987                 :             : 
     988                 :             :    return type of `int (* fee ())()': pointer -> function -> int.  Both
     989                 :             :    pointer (and reference and offset) and function (and member) types must
     990                 :             :    deal with prefix and suffix.
     991                 :             : 
     992                 :             :    Arrays must also do this for DECL nodes, like int a[], and for things like
     993                 :             :    int *[]&.  */
     994                 :             : 
     995                 :             : static void
     996                 :    35688317 : dump_type_prefix (cxx_pretty_printer *pp, tree t, int flags)
     997                 :             : {
     998                 :    36508366 :   if (TYPE_PTRMEMFUNC_P (t))
     999                 :             :     {
    1000                 :      308026 :       t = TYPE_PTRMEMFUNC_FN_TYPE (t);
    1001                 :      308026 :       goto offset_type;
    1002                 :             :     }
    1003                 :             : 
    1004                 :    36200340 :   switch (TREE_CODE (t))
    1005                 :             :     {
    1006                 :    17833653 :     case POINTER_TYPE:
    1007                 :    17833653 :     case REFERENCE_TYPE:
    1008                 :    17833653 :       {
    1009                 :    17833653 :         tree sub = TREE_TYPE (t);
    1010                 :             : 
    1011                 :    17833653 :         dump_type_prefix (pp, sub, flags);
    1012                 :    17833653 :         if (TREE_CODE (sub) == ARRAY_TYPE
    1013                 :    17766842 :             || TREE_CODE (sub) == FUNCTION_TYPE)
    1014                 :             :           {
    1015                 :      364999 :             pp_cxx_whitespace (pp);
    1016                 :      364999 :             pp_cxx_left_paren (pp);
    1017                 :             :             /* If we're dealing with the GNU form of attributes, print this:
    1018                 :             :                  void (__attribute__((noreturn)) *f) ();
    1019                 :             :                If it is the standard [[]] attribute, we'll print the attribute
    1020                 :             :                in dump_type_suffix.  */
    1021                 :      364999 :             if (!cxx11_attribute_p (TYPE_ATTRIBUTES (sub)))
    1022                 :      364994 :               pp_c_attributes_display (pp, TYPE_ATTRIBUTES (sub));
    1023                 :             :           }
    1024                 :    17833653 :         if (TYPE_PTR_P (t))
    1025                 :    10491699 :           pp_star (pp);
    1026                 :     7341954 :         else if (TYPE_REF_P (t))
    1027                 :             :           {
    1028                 :     7341954 :             if (TYPE_REF_IS_RVALUE (t))
    1029                 :      681578 :               pp_ampersand_ampersand (pp);
    1030                 :             :             else
    1031                 :     6660376 :               pp_ampersand (pp);
    1032                 :             :           }
    1033                 :    17833653 :         pp->set_padding (pp_before);
    1034                 :    17833653 :         pp_cxx_cv_qualifier_seq (pp, t);
    1035                 :             :       }
    1036                 :    17833653 :       break;
    1037                 :             : 
    1038                 :      321873 :     case OFFSET_TYPE:
    1039                 :      321873 :     offset_type:
    1040                 :      321873 :       dump_type_prefix (pp, TREE_TYPE (t), flags);
    1041                 :      321873 :       if (TREE_CODE (t) == OFFSET_TYPE) /* pmfs deal with this in d_t_p */
    1042                 :             :         {
    1043                 :       13847 :           pp_maybe_space (pp);
    1044                 :       13847 :           if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
    1045                 :           9 :              pp_cxx_left_paren (pp);
    1046                 :       13847 :           dump_type (pp, TYPE_OFFSET_BASETYPE (t), flags);
    1047                 :       13847 :           pp_cxx_colon_colon (pp);
    1048                 :             :         }
    1049                 :      321873 :       pp_cxx_star (pp);
    1050                 :      321873 :       pp_cxx_cv_qualifier_seq (pp, t);
    1051                 :      321873 :       pp->set_padding (pp_before);
    1052                 :      321873 :       break;
    1053                 :             : 
    1054                 :             :       /* This can be reached without a pointer when dealing with
    1055                 :             :          templates, e.g. std::is_function.  */
    1056                 :      664311 :     case FUNCTION_TYPE:
    1057                 :      664311 :       dump_type_prefix (pp, TREE_TYPE (t), flags);
    1058                 :      664311 :       break;
    1059                 :             : 
    1060                 :      308188 :     case METHOD_TYPE:
    1061                 :      308188 :       dump_type_prefix (pp, TREE_TYPE (t), flags);
    1062                 :      308188 :       pp_maybe_space (pp);
    1063                 :      308188 :       pp_cxx_left_paren (pp);
    1064                 :      308188 :       dump_aggr_type (pp, TYPE_METHOD_BASETYPE (t), flags);
    1065                 :      308188 :       pp_cxx_colon_colon (pp);
    1066                 :      308188 :       break;
    1067                 :             : 
    1068                 :      155738 :     case ARRAY_TYPE:
    1069                 :      155738 :       dump_type_prefix (pp, TREE_TYPE (t), flags);
    1070                 :      155738 :       break;
    1071                 :             : 
    1072                 :    17224568 :     case ENUMERAL_TYPE:
    1073                 :    17224568 :     case IDENTIFIER_NODE:
    1074                 :    17224568 :     case INTEGER_TYPE:
    1075                 :    17224568 :     case BOOLEAN_TYPE:
    1076                 :    17224568 :     case REAL_TYPE:
    1077                 :    17224568 :     case RECORD_TYPE:
    1078                 :    17224568 :     case TEMPLATE_TYPE_PARM:
    1079                 :    17224568 :     case TEMPLATE_TEMPLATE_PARM:
    1080                 :    17224568 :     case BOUND_TEMPLATE_TEMPLATE_PARM:
    1081                 :    17224568 :     case TREE_LIST:
    1082                 :    17224568 :     case TYPE_DECL:
    1083                 :    17224568 :     case TREE_VEC:
    1084                 :    17224568 :     case UNION_TYPE:
    1085                 :    17224568 :     case LANG_TYPE:
    1086                 :    17224568 :     case VOID_TYPE:
    1087                 :    17224568 :     case OPAQUE_TYPE:
    1088                 :    17224568 :     case TYPENAME_TYPE:
    1089                 :    17224568 :     case COMPLEX_TYPE:
    1090                 :    17224568 :     case VECTOR_TYPE:
    1091                 :    17224568 :     case TYPEOF_TYPE:
    1092                 :    17224568 :     case TRAIT_TYPE:
    1093                 :    17224568 :     case DECLTYPE_TYPE:
    1094                 :    17224568 :     case TYPE_PACK_EXPANSION:
    1095                 :    17224568 :     case FIXED_POINT_TYPE:
    1096                 :    17224568 :     case NULLPTR_TYPE:
    1097                 :    17224568 :     case PACK_INDEX_TYPE:
    1098                 :    17224568 :       dump_type (pp, t, flags);
    1099                 :    17224568 :       pp->set_padding (pp_before);
    1100                 :    17224568 :       break;
    1101                 :             : 
    1102                 :           0 :     default:
    1103                 :           0 :       pp_unsupported_tree (pp, t);
    1104                 :             :       /* fall through.  */
    1105                 :          35 :     case ERROR_MARK:
    1106                 :          35 :       pp_string (pp, M_("<typeprefixerror>"));
    1107                 :          35 :       break;
    1108                 :             :     }
    1109                 :    35688317 : }
    1110                 :             : 
    1111                 :             : /* Dump the suffix of type T, under control of FLAGS.  This is the part
    1112                 :             :    which appears after the identifier (or function parms).  */
    1113                 :             : 
    1114                 :             : static void
    1115                 :    17224889 : dump_type_suffix (cxx_pretty_printer *pp, tree t, int flags)
    1116                 :             : {
    1117                 :    36508652 :   if (TYPE_PTRMEMFUNC_P (t))
    1118                 :      308026 :     t = TYPE_PTRMEMFUNC_FN_TYPE (t);
    1119                 :             : 
    1120                 :    36508652 :   switch (TREE_CODE (t))
    1121                 :             :     {
    1122                 :    18155526 :     case POINTER_TYPE:
    1123                 :    18155526 :     case REFERENCE_TYPE:
    1124                 :    18155526 :     case OFFSET_TYPE:
    1125                 :    18155526 :       if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE
    1126                 :    18155526 :           || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
    1127                 :      365008 :         pp_cxx_right_paren (pp);
    1128                 :    18155526 :       if (TREE_CODE (t) == POINTER_TYPE)
    1129                 :    10799725 :         flags |= TFF_POINTER;
    1130                 :    18155526 :       dump_type_suffix (pp, TREE_TYPE (t), flags);
    1131                 :    18155526 :       break;
    1132                 :             : 
    1133                 :      972499 :     case FUNCTION_TYPE:
    1134                 :      972499 :     case METHOD_TYPE:
    1135                 :      972499 :       {
    1136                 :      972499 :         tree arg;
    1137                 :      972499 :         if (TREE_CODE (t) == METHOD_TYPE)
    1138                 :             :           /* Can only be reached through a pointer.  */
    1139                 :      308188 :           pp_cxx_right_paren (pp);
    1140                 :      972499 :         arg = TYPE_ARG_TYPES (t);
    1141                 :      972499 :         if (TREE_CODE (t) == METHOD_TYPE)
    1142                 :      308188 :           arg = TREE_CHAIN (arg);
    1143                 :             : 
    1144                 :             :         /* Function pointers don't have default args.  Not in standard C++,
    1145                 :             :            anyway; they may in g++, but we'll just pretend otherwise.  */
    1146                 :      972499 :         dump_parameters (pp, arg, flags & ~TFF_FUNCTION_DEFAULT_ARGUMENTS);
    1147                 :             : 
    1148                 :      972499 :         pp->set_padding (pp_before);
    1149                 :     1506022 :         pp_cxx_cv_qualifiers (pp, type_memfn_quals (t),
    1150                 :             :                               TREE_CODE (t) == FUNCTION_TYPE
    1151                 :             :                               && (flags & TFF_POINTER));
    1152                 :      972499 :         dump_ref_qualifier (pp, t, flags);
    1153                 :      972499 :         if (tx_safe_fn_type_p (t))
    1154                 :          19 :           pp_cxx_ws_string (pp, "transaction_safe");
    1155                 :      972499 :         dump_exception_spec (pp, TYPE_RAISES_EXCEPTIONS (t), flags);
    1156                 :             :         /* If this is the standard [[]] attribute, print
    1157                 :             :              void (*)() [[noreturn]];  */
    1158                 :      972499 :         if (cxx11_attribute_p (TYPE_ATTRIBUTES (t)))
    1159                 :             :           {
    1160                 :           2 :             pp_space (pp);
    1161                 :           2 :             pp_c_attributes_display (pp, TYPE_ATTRIBUTES (t));
    1162                 :           2 :             pp->set_padding (pp_before);
    1163                 :             :           }
    1164                 :      972499 :         dump_type_suffix (pp, TREE_TYPE (t), flags);
    1165                 :      972499 :         break;
    1166                 :             :       }
    1167                 :             : 
    1168                 :      155738 :     case ARRAY_TYPE:
    1169                 :      155738 :       pp_maybe_space (pp);
    1170                 :      155738 :       pp_cxx_left_bracket (pp);
    1171                 :      155738 :       if (tree dtype = TYPE_DOMAIN (t))
    1172                 :             :         {
    1173                 :      131538 :           tree max = TYPE_MAX_VALUE (dtype);
    1174                 :             :           /* Zero-length arrays have a null upper bound in C and SIZE_MAX
    1175                 :             :              in C++.  Handle both since the type might be constructed by
    1176                 :             :              the middle end and end up here as a result of a warning (see
    1177                 :             :              PR c++/97201).  */
    1178                 :      131538 :           if (!max || integer_all_onesp (max))
    1179                 :         687 :             pp_character (pp, '0');
    1180                 :      130851 :           else if (tree_fits_shwi_p (max))
    1181                 :      130259 :             pp_wide_integer (pp, tree_to_shwi (max) + 1);
    1182                 :             :           else
    1183                 :             :             {
    1184                 :         592 :               STRIP_NOPS (max);
    1185                 :         592 :               if (TREE_CODE (max) == SAVE_EXPR)
    1186                 :           0 :                 max = TREE_OPERAND (max, 0);
    1187                 :         592 :               if (TREE_CODE (max) == MINUS_EXPR
    1188                 :         592 :                   || TREE_CODE (max) == PLUS_EXPR)
    1189                 :             :                 {
    1190                 :         520 :                   max = TREE_OPERAND (max, 0);
    1191                 :         902 :                   while (CONVERT_EXPR_P (max))
    1192                 :         382 :                     max = TREE_OPERAND (max, 0);
    1193                 :             :                 }
    1194                 :             :               else
    1195                 :          72 :                 max = fold_build2_loc (input_location,
    1196                 :             :                                        PLUS_EXPR, dtype, max,
    1197                 :          72 :                                        build_int_cst (dtype, 1));
    1198                 :         592 :               dump_expr (pp, max, flags & ~TFF_EXPR_IN_PARENS);
    1199                 :             :             }
    1200                 :             :         }
    1201                 :      155738 :       pp_cxx_right_bracket (pp);
    1202                 :      155738 :       dump_type_suffix (pp, TREE_TYPE (t), flags);
    1203                 :      155738 :       break;
    1204                 :             : 
    1205                 :             :     case ENUMERAL_TYPE:
    1206                 :             :     case IDENTIFIER_NODE:
    1207                 :             :     case INTEGER_TYPE:
    1208                 :             :     case BOOLEAN_TYPE:
    1209                 :             :     case REAL_TYPE:
    1210                 :             :     case RECORD_TYPE:
    1211                 :             :     case TEMPLATE_TYPE_PARM:
    1212                 :             :     case TEMPLATE_TEMPLATE_PARM:
    1213                 :             :     case BOUND_TEMPLATE_TEMPLATE_PARM:
    1214                 :             :     case TREE_LIST:
    1215                 :             :     case TYPE_DECL:
    1216                 :             :     case TREE_VEC:
    1217                 :             :     case UNION_TYPE:
    1218                 :             :     case LANG_TYPE:
    1219                 :             :     case VOID_TYPE:
    1220                 :             :     case OPAQUE_TYPE:
    1221                 :             :     case TYPENAME_TYPE:
    1222                 :             :     case COMPLEX_TYPE:
    1223                 :             :     case VECTOR_TYPE:
    1224                 :             :     case TYPEOF_TYPE:
    1225                 :             :     case TRAIT_TYPE:
    1226                 :             :     case DECLTYPE_TYPE:
    1227                 :             :     case TYPE_PACK_EXPANSION:
    1228                 :             :     case FIXED_POINT_TYPE:
    1229                 :             :     case NULLPTR_TYPE:
    1230                 :             :     case PACK_INDEX_TYPE:
    1231                 :             :       break;
    1232                 :             : 
    1233                 :           0 :     default:
    1234                 :           0 :       pp_unsupported_tree (pp, t);
    1235                 :             :     case ERROR_MARK:
    1236                 :             :       /* Don't mark it here, we should have already done in
    1237                 :             :          dump_type_prefix.  */
    1238                 :             :       break;
    1239                 :             :     }
    1240                 :    17224889 : }
    1241                 :             : 
    1242                 :             : static void
    1243                 :          66 : dump_global_iord (cxx_pretty_printer *pp, tree t)
    1244                 :             : {
    1245                 :          66 :   const char *p = NULL;
    1246                 :             : 
    1247                 :          66 :   if (DECL_GLOBAL_CTOR_P (t))
    1248                 :          66 :     p = M_("(static initializers for %s)");
    1249                 :           0 :   else if (DECL_GLOBAL_DTOR_P (t))
    1250                 :           0 :     p = M_("(static destructors for %s)");
    1251                 :             :   else
    1252                 :           0 :     gcc_unreachable ();
    1253                 :             : 
    1254                 :          66 :   pp_printf (pp, p, DECL_SOURCE_FILE (t));
    1255                 :          66 : }
    1256                 :             : 
    1257                 :             : static void
    1258                 :      854861 : dump_simple_decl (cxx_pretty_printer *pp, tree t, tree type, int flags)
    1259                 :             : {
    1260                 :      854861 :   if (VAR_P (t) && DECL_NTTP_OBJECT_P (t))
    1261                 :          47 :     return dump_expr (pp, DECL_INITIAL (t), flags);
    1262                 :             : 
    1263                 :      854814 :   if (flags & TFF_DECL_SPECIFIERS)
    1264                 :             :     {
    1265                 :       24457 :       if (concept_definition_p (t))
    1266                 :         286 :         pp_cxx_ws_string (pp, "concept");
    1267                 :       24171 :       else if (VAR_P (t) && DECL_DECLARED_CONSTEXPR_P (t))
    1268                 :         471 :         pp_cxx_ws_string (pp, "constexpr");
    1269                 :             : 
    1270                 :       24457 :       if (!concept_definition_p (t))
    1271                 :       24171 :         dump_type_prefix (pp, type, flags & ~TFF_UNQUALIFIED_NAME);
    1272                 :       24457 :       pp_maybe_space (pp);
    1273                 :             :     }
    1274                 :      854814 :   if (! (flags & TFF_UNQUALIFIED_NAME)
    1275                 :      843458 :       && TREE_CODE (t) != PARM_DECL
    1276                 :     1682956 :       && (!DECL_INITIAL (t)
    1277                 :        7938 :           || TREE_CODE (DECL_INITIAL (t)) != TEMPLATE_PARM_INDEX))
    1278                 :      826001 :     dump_scope (pp, CP_DECL_CONTEXT (t), flags);
    1279                 :      854814 :   flags &= ~TFF_UNQUALIFIED_NAME;
    1280                 :      854814 :   if ((flags & TFF_DECL_SPECIFIERS)
    1281                 :       24457 :       && DECL_TEMPLATE_PARM_P (t)
    1282                 :      859638 :       && TEMPLATE_PARM_PARAMETER_PACK (DECL_INITIAL (t)))
    1283                 :         127 :     pp_string (pp, "...");
    1284                 :      854814 :   if (DECL_NAME (t))
    1285                 :             :     {
    1286                 :      853349 :       if (TREE_CODE (t) == FIELD_DECL && DECL_NORMAL_CAPTURE_P (t))
    1287                 :             :         {
    1288                 :          12 :           pp_less (pp);
    1289                 :          12 :           pp_string (pp, IDENTIFIER_POINTER (DECL_NAME (t)) + 2);
    1290                 :          12 :           pp_string (pp, " capture>");
    1291                 :             :         }
    1292                 :             :       else
    1293                 :      853337 :         dump_decl (pp, DECL_NAME (t), flags);
    1294                 :             :     }
    1295                 :        1465 :   else if (DECL_DECOMPOSITION_P (t))
    1296                 :          44 :     pp_string (pp, M_("<structured bindings>"));
    1297                 :        1421 :   else if (TREE_CODE (t) == FIELD_DECL && DECL_FIELD_IS_BASE (t))
    1298                 :          83 :     dump_type (pp, TREE_TYPE (t), flags);
    1299                 :             :   else
    1300                 :        1338 :     pp_string (pp, M_("<anonymous>"));
    1301                 :             : 
    1302                 :      854814 :   dump_module_suffix (pp, t);
    1303                 :             : 
    1304                 :      854814 :   if (flags & TFF_DECL_SPECIFIERS)
    1305                 :       24457 :     dump_type_suffix (pp, type, flags);
    1306                 :             : }
    1307                 :             : 
    1308                 :             : class colorize_guard
    1309                 :             : {
    1310                 :             :   bool colorize;
    1311                 :             :   cxx_pretty_printer *pp;
    1312                 :             : public:
    1313                 :    76247229 :   colorize_guard (bool _colorize, cxx_pretty_printer *pp, const char *name)
    1314                 :    76247229 :     : colorize (_colorize && pp_show_color (pp)), pp (pp)
    1315                 :             :   {
    1316                 :    76247229 :     pp_string (pp, colorize_start (colorize, name));
    1317                 :    76247229 :   }
    1318                 :    76247229 :   ~colorize_guard ()
    1319                 :             :   {
    1320                 :    76247229 :     pp_string (pp, colorize_stop (colorize));
    1321                 :    76247229 :   }
    1322                 :             : };
    1323                 :             : 
    1324                 :             : /* Print an IDENTIFIER_NODE that is the name of a declaration.  */
    1325                 :             : 
    1326                 :             : static void
    1327                 :   144366829 : dump_decl_name (cxx_pretty_printer *pp, tree t, int flags)
    1328                 :             : {
    1329                 :             :   /* These special cases are duplicated here so that other functions
    1330                 :             :      can feed identifiers to error and get them demangled properly.  */
    1331                 :   144366829 :   if (IDENTIFIER_CONV_OP_P (t))
    1332                 :             :     {
    1333                 :          27 :       pp_cxx_ws_string (pp, "operator");
    1334                 :             :       /* Not exactly IDENTIFIER_TYPE_VALUE.  */
    1335                 :          27 :       dump_type (pp, TREE_TYPE (t), flags);
    1336                 :          27 :       return;
    1337                 :             :     }
    1338                 :   144366802 :   if (dguide_name_p (t))
    1339                 :             :     {
    1340                 :         876 :       dump_decl (pp, CLASSTYPE_TI_TEMPLATE (TREE_TYPE (t)),
    1341                 :             :                  TFF_UNQUALIFIED_NAME);
    1342                 :         876 :       return;
    1343                 :             :     }
    1344                 :             : 
    1345                 :   144365926 :   const char *str = IDENTIFIER_POINTER (t);
    1346                 :   144365926 :   if (startswith (str, "_ZGR"))
    1347                 :             :     {
    1348                 :           9 :       pp_cxx_ws_string (pp, "<temporary>");
    1349                 :           9 :       return;
    1350                 :             :     }
    1351                 :             : 
    1352                 :   144365917 :   pp_cxx_tree_identifier (pp, t);
    1353                 :             : }
    1354                 :             : 
    1355                 :             : /* Dump a human readable string for the decl T under control of FLAGS.  */
    1356                 :             : 
    1357                 :             : static void
    1358                 :   245642821 : dump_decl (cxx_pretty_printer *pp, tree t, int flags)
    1359                 :             : {
    1360                 :   245644464 :   if (t == NULL_TREE)
    1361                 :             :     return;
    1362                 :             : 
    1363                 :             :   /* If doing Objective-C++, give Objective-C a chance to demangle
    1364                 :             :      Objective-C method names.  */
    1365                 :   245644464 :   if (c_dialect_objc ())
    1366                 :             :     {
    1367                 :           0 :       const char *demangled = objc_maybe_printable_name (t, flags);
    1368                 :           0 :       if (demangled)
    1369                 :             :         {
    1370                 :           0 :           pp_string (pp, demangled);
    1371                 :           0 :           return;
    1372                 :             :         }
    1373                 :             :     }
    1374                 :             : 
    1375                 :   245644464 :   switch (TREE_CODE (t))
    1376                 :             :     {
    1377                 :    35496406 :     case TYPE_DECL:
    1378                 :             :       /* Don't say 'typedef class A' */
    1379                 :    35496406 :       if (DECL_ARTIFICIAL (t) && !DECL_SELF_REFERENCE_P (t))
    1380                 :             :         {
    1381                 :    34689036 :           if ((flags & TFF_DECL_SPECIFIERS)
    1382                 :    34689036 :               && TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TYPE_PARM)
    1383                 :             :             {
    1384                 :             :               /* Say `class T' not just `T'.  */
    1385                 :          51 :               pp_cxx_ws_string (pp, "class");
    1386                 :             : 
    1387                 :             :               /* Emit the `...' for a parameter pack.  */
    1388                 :          51 :               if (TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (t)))
    1389                 :           3 :                 pp_cxx_ws_string (pp, "...");
    1390                 :             :             }
    1391                 :             : 
    1392                 :    34689036 :           dump_type (pp, TREE_TYPE (t), flags);
    1393                 :    34689036 :           break;
    1394                 :             :         }
    1395                 :      807370 :       if (TYPE_DECL_ALIAS_P (t)
    1396                 :      807370 :           && (flags & TFF_DECL_SPECIFIERS
    1397                 :             :               || flags & TFF_CLASS_KEY_OR_ENUM))
    1398                 :             :         {
    1399                 :         514 :           pp_cxx_ws_string (pp, "using");
    1400                 :         514 :           if (! (flags & TFF_UNQUALIFIED_NAME))
    1401                 :         514 :             dump_scope (pp, CP_DECL_CONTEXT (t), flags);
    1402                 :         514 :           dump_decl (pp, DECL_NAME (t), flags);
    1403                 :         514 :           pp_cxx_whitespace (pp);
    1404                 :         514 :           pp_cxx_ws_string (pp, "=");
    1405                 :         514 :           pp_cxx_whitespace (pp);
    1406                 :         537 :           dump_type (pp, (DECL_ORIGINAL_TYPE (t)
    1407                 :          23 :                           ? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t)),
    1408                 :             :                      flags);
    1409                 :         514 :           break;
    1410                 :             :         }
    1411                 :      806856 :       if ((flags & TFF_DECL_SPECIFIERS)
    1412                 :      806856 :           && !DECL_SELF_REFERENCE_P (t))
    1413                 :       11572 :         pp_cxx_ws_string (pp, "typedef");
    1414                 :      818299 :       dump_simple_decl (pp, t, DECL_ORIGINAL_TYPE (t)
    1415                 :       11443 :                         ? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t),
    1416                 :             :                         flags);
    1417                 :      806856 :       break;
    1418                 :             : 
    1419                 :       22602 :     case VAR_DECL:
    1420                 :       22602 :       if (DECL_NAME (t) && VTABLE_NAME_P (DECL_NAME (t)))
    1421                 :             :         {
    1422                 :           0 :           pp_string (pp, M_("vtable for "));
    1423                 :           0 :           gcc_assert (TYPE_P (DECL_CONTEXT (t)));
    1424                 :           0 :           dump_type (pp, DECL_CONTEXT (t), flags);
    1425                 :           0 :           break;
    1426                 :             :         }
    1427                 :             :       /* Fall through.  */
    1428                 :       45296 :     case FIELD_DECL:
    1429                 :       45296 :     case PARM_DECL:
    1430                 :       45296 :       dump_simple_decl (pp, t, TREE_TYPE (t), flags);
    1431                 :             : 
    1432                 :             :       /* Handle variable template specializations.  */
    1433                 :       45296 :       if (VAR_P (t)
    1434                 :       22602 :           && DECL_LANG_SPECIFIC (t)
    1435                 :        4117 :           && DECL_TEMPLATE_INFO (t)
    1436                 :       46405 :           && PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t)))
    1437                 :             :         {
    1438                 :         487 :           pp_cxx_begin_template_argument_list (pp);
    1439                 :         487 :           tree args = INNERMOST_TEMPLATE_ARGS (DECL_TI_ARGS (t));
    1440                 :         487 :           dump_template_argument_list (pp, args, flags);
    1441                 :         487 :           pp_cxx_end_template_argument_list (pp);
    1442                 :             :         }
    1443                 :             :       break;
    1444                 :             : 
    1445                 :           0 :     case RESULT_DECL:
    1446                 :           0 :       pp_string (pp, M_("<return value> "));
    1447                 :           0 :       dump_simple_decl (pp, t, TREE_TYPE (t), flags);
    1448                 :           0 :       break;
    1449                 :             : 
    1450                 :    65259128 :     case NAMESPACE_DECL:
    1451                 :    65259128 :       if (flags & TFF_DECL_SPECIFIERS)
    1452                 :          63 :         pp->declaration (t);
    1453                 :             :       else
    1454                 :             :         {
    1455                 :    65259065 :           if (! (flags & TFF_UNQUALIFIED_NAME))
    1456                 :    65259044 :             dump_scope (pp, CP_DECL_CONTEXT (t), flags);
    1457                 :    65259065 :           flags &= ~TFF_UNQUALIFIED_NAME;
    1458                 :    65259065 :           if (DECL_NAME (t) == NULL_TREE)
    1459                 :             :             {
    1460                 :        6326 :               if (!(pp->flags & pp_c_flag_gnu_v3))
    1461                 :        1153 :                 pp_cxx_ws_string (pp, M_("{anonymous}"));
    1462                 :             :               else
    1463                 :        5173 :                 pp_cxx_ws_string (pp, M_("(anonymous namespace)"));
    1464                 :             :             }
    1465                 :             :           else
    1466                 :    65252739 :             pp_cxx_tree_identifier (pp, DECL_NAME (t));
    1467                 :             :         }
    1468                 :             :       break;
    1469                 :             : 
    1470                 :        1036 :     case SCOPE_REF:
    1471                 :        1036 :       dump_type (pp, TREE_OPERAND (t, 0), flags);
    1472                 :        1036 :       pp_cxx_colon_colon (pp);
    1473                 :        1036 :       dump_decl (pp, TREE_OPERAND (t, 1), TFF_UNQUALIFIED_NAME);
    1474                 :        1036 :       break;
    1475                 :             : 
    1476                 :           0 :     case ARRAY_REF:
    1477                 :           0 :       dump_decl (pp, TREE_OPERAND (t, 0), flags);
    1478                 :           0 :       pp_cxx_left_bracket (pp);
    1479                 :           0 :       dump_decl (pp, TREE_OPERAND (t, 1), flags);
    1480                 :           0 :       pp_cxx_right_bracket (pp);
    1481                 :           0 :       break;
    1482                 :             : 
    1483                 :             :       /* So that we can do dump_decl on an aggr type.  */
    1484                 :        1408 :     case RECORD_TYPE:
    1485                 :        1408 :     case UNION_TYPE:
    1486                 :        1408 :     case ENUMERAL_TYPE:
    1487                 :        1408 :       dump_type (pp, t, flags);
    1488                 :        1408 :       break;
    1489                 :             : 
    1490                 :          49 :     case BIT_NOT_EXPR:
    1491                 :             :       /* This is a pseudo destructor call which has not been folded into
    1492                 :             :          a PSEUDO_DTOR_EXPR yet.  */
    1493                 :          49 :       pp_cxx_complement (pp);
    1494                 :          49 :       dump_type (pp, TREE_OPERAND (t, 0), flags);
    1495                 :          49 :       break;
    1496                 :             : 
    1497                 :           0 :     case TYPE_EXPR:
    1498                 :           0 :       gcc_unreachable ();
    1499                 :   144366829 :       break;
    1500                 :             : 
    1501                 :   144366829 :     case IDENTIFIER_NODE:
    1502                 :   144366829 :       dump_decl_name (pp, t, flags);
    1503                 :   144366829 :       break;
    1504                 :             : 
    1505                 :         283 :     case OVERLOAD:
    1506                 :         283 :       if (!OVL_SINGLE_P (t))
    1507                 :             :         {
    1508                 :         126 :           tree ctx = ovl_scope (t);
    1509                 :         126 :           if (ctx != global_namespace)
    1510                 :             :             {
    1511                 :          73 :               if (TYPE_P (ctx))
    1512                 :          59 :                 dump_type (pp, ctx, flags);
    1513                 :             :               else
    1514                 :          14 :                 dump_decl (pp, ctx, flags);
    1515                 :          73 :               pp_cxx_colon_colon (pp);
    1516                 :             :             }
    1517                 :         252 :           dump_decl (pp, OVL_NAME (t), flags);
    1518                 :         126 :           break;
    1519                 :             :         }
    1520                 :             : 
    1521                 :             :       /* If there's only one function, dump that.  */
    1522                 :   245644464 :       return dump_decl (pp, OVL_FIRST (t), flags);
    1523                 :             : 
    1524                 :      112114 :     case FUNCTION_DECL:
    1525                 :      112114 :       if (! DECL_LANG_SPECIFIC (t))
    1526                 :             :         {
    1527                 :        1459 :           if (DECL_ABSTRACT_ORIGIN (t)
    1528                 :        1459 :               && DECL_ABSTRACT_ORIGIN (t) != t)
    1529                 :         244 :             dump_decl (pp, DECL_ABSTRACT_ORIGIN (t), flags);
    1530                 :             :           else
    1531                 :        1215 :             dump_function_name (pp, t, flags);
    1532                 :             :         }
    1533                 :      110655 :       else if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t))
    1534                 :          66 :         dump_global_iord (pp, t);
    1535                 :             :       else
    1536                 :      110589 :         dump_function_decl (pp, t, flags);
    1537                 :             :       break;
    1538                 :             : 
    1539                 :      356375 :     case TEMPLATE_DECL:
    1540                 :      356375 :       dump_template_decl (pp, t, flags);
    1541                 :      356375 :       break;
    1542                 :             : 
    1543                 :         307 :     case CONCEPT_DECL:
    1544                 :         307 :       dump_simple_decl (pp, t, TREE_TYPE (t), flags);
    1545                 :         307 :       break;
    1546                 :             : 
    1547                 :        2263 :     case TEMPLATE_ID_EXPR:
    1548                 :        2263 :       {
    1549                 :        2263 :         tree name = TREE_OPERAND (t, 0);
    1550                 :        2263 :         tree args = TREE_OPERAND (t, 1);
    1551                 :             : 
    1552                 :        2830 :         if (!identifier_p (name))
    1553                 :        1613 :           name = OVL_NAME (name);
    1554                 :        2263 :         dump_decl (pp, name, flags);
    1555                 :        2263 :         pp_cxx_begin_template_argument_list (pp);
    1556                 :        2263 :         if (args == error_mark_node)
    1557                 :           3 :           pp_string (pp, M_("<template arguments error>"));
    1558                 :        2260 :         else if (args)
    1559                 :        2164 :           dump_template_argument_list
    1560                 :        2164 :             (pp, args, flags|TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS);
    1561                 :        2263 :         pp_cxx_end_template_argument_list (pp);
    1562                 :             :       }
    1563                 :        2263 :       break;
    1564                 :             : 
    1565                 :         292 :     case LABEL_DECL:
    1566                 :         292 :       if (DECL_NAME (t))
    1567                 :         286 :         pp_cxx_tree_identifier (pp, DECL_NAME (t));
    1568                 :             :       else
    1569                 :           6 :         dump_generic_node (pp, t, 0, TDF_SLIM, false);
    1570                 :             :       break;
    1571                 :             : 
    1572                 :        2444 :     case CONST_DECL:
    1573                 :        4882 :       if ((TREE_TYPE (t) != NULL_TREE && NEXT_CODE (t) == ENUMERAL_TYPE)
    1574                 :        4527 :           || (DECL_INITIAL (t) &&
    1575                 :        2083 :               TREE_CODE (DECL_INITIAL (t)) == TEMPLATE_PARM_INDEX))
    1576                 :        2402 :         dump_simple_decl (pp, t, TREE_TYPE (t), flags);
    1577                 :          42 :       else if (DECL_NAME (t))
    1578                 :          42 :         dump_decl (pp, DECL_NAME (t), flags);
    1579                 :           0 :       else if (DECL_INITIAL (t))
    1580                 :           0 :         dump_expr (pp, DECL_INITIAL (t), flags | TFF_EXPR_IN_PARENS);
    1581                 :             :       else
    1582                 :           0 :         pp_string (pp, M_("<enumerator>"));
    1583                 :             :       break;
    1584                 :             : 
    1585                 :         136 :     case USING_DECL:
    1586                 :         136 :       {
    1587                 :         136 :         if (flags & TFF_DECL_SPECIFIERS)
    1588                 :         130 :           pp_cxx_ws_string (pp, "using");
    1589                 :         136 :         bool variadic = false;
    1590                 :         136 :         if (!(flags & TFF_UNQUALIFIED_NAME))
    1591                 :             :           {
    1592                 :         136 :             tree scope = USING_DECL_SCOPE (t);
    1593                 :         136 :             tree name = DECL_NAME (t);
    1594                 :         136 :             if (PACK_EXPANSION_P (scope))
    1595                 :             :               {
    1596                 :           0 :                 scope = PACK_EXPANSION_PATTERN (scope);
    1597                 :             :                 variadic = true;
    1598                 :             :               }
    1599                 :         136 :             if (identifier_p (name)
    1600                 :         136 :                 && IDENTIFIER_CONV_OP_P (name)
    1601                 :           0 :                 && PACK_EXPANSION_P (TREE_TYPE (name)))
    1602                 :             :               {
    1603                 :           0 :                 name = make_conv_op_name (PACK_EXPANSION_PATTERN
    1604                 :             :                                           (TREE_TYPE (name)));
    1605                 :           0 :                 variadic = true;
    1606                 :             :               }
    1607                 :         136 :             dump_type (pp, scope, flags);
    1608                 :         136 :             pp_cxx_colon_colon (pp);
    1609                 :             :           }
    1610                 :         136 :         dump_decl (pp, DECL_NAME (t), flags);
    1611                 :         136 :         if (variadic)
    1612                 :           0 :           pp_cxx_ws_string (pp, "...");
    1613                 :             :       }
    1614                 :             :       break;
    1615                 :             : 
    1616                 :           0 :     case STATIC_ASSERT:
    1617                 :           0 :       pp->declaration (t);
    1618                 :           0 :       break;
    1619                 :             : 
    1620                 :          38 :     case BASELINK:
    1621                 :          38 :       dump_decl (pp, BASELINK_FUNCTIONS (t), flags);
    1622                 :          38 :       break;
    1623                 :             : 
    1624                 :           0 :     case TEMPLATE_TYPE_PARM:
    1625                 :           0 :       if (flags & TFF_DECL_SPECIFIERS)
    1626                 :           0 :         pp->declaration (t);
    1627                 :             :       else
    1628                 :           0 :         pp->type_id (t);
    1629                 :             :       break;
    1630                 :             : 
    1631                 :           9 :     case UNBOUND_CLASS_TEMPLATE:
    1632                 :           9 :     case TYPE_PACK_EXPANSION:
    1633                 :           9 :     case TREE_BINFO:
    1634                 :           9 :       dump_type (pp, t, flags);
    1635                 :           9 :       break;
    1636                 :             : 
    1637                 :          30 :     default:
    1638                 :          30 :       pp_unsupported_tree (pp, t);
    1639                 :             :       /* Fall through.  */
    1640                 :             : 
    1641                 :          51 :     case ERROR_MARK:
    1642                 :          51 :       pp_string (pp, M_("<declaration error>"));
    1643                 :          51 :       break;
    1644                 :             :     }
    1645                 :             : }
    1646                 :             : 
    1647                 :             : /* Dump a template declaration T under control of FLAGS. This means the
    1648                 :             :    'template <...> leaders plus the 'class X' or 'void fn(...)' part.  */
    1649                 :             : 
    1650                 :             : static void
    1651                 :      357895 : dump_template_decl (cxx_pretty_printer *pp, tree t, int flags)
    1652                 :             : {
    1653                 :      357895 :   tree orig_parms = DECL_TEMPLATE_PARMS (t);
    1654                 :      357895 :   tree parms;
    1655                 :      357895 :   int i;
    1656                 :             : 
    1657                 :      357895 :   if (flags & TFF_TEMPLATE_HEADER)
    1658                 :             :     {
    1659                 :        8200 :       for (parms = orig_parms = nreverse (orig_parms);
    1660                 :       16947 :            parms;
    1661                 :        8747 :            parms = TREE_CHAIN (parms))
    1662                 :             :         {
    1663                 :        8747 :           tree inner_parms = INNERMOST_TEMPLATE_PARMS (parms);
    1664                 :        8747 :           int len = TREE_VEC_LENGTH (inner_parms);
    1665                 :             : 
    1666                 :        8747 :           if (len == 0)
    1667                 :             :             {
    1668                 :             :               /* Skip over the dummy template levels of a template template
    1669                 :             :                  parm.  */
    1670                 :         292 :               gcc_assert (TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TEMPLATE_PARM);
    1671                 :         292 :               continue;
    1672                 :             :             }
    1673                 :             : 
    1674                 :        8455 :           pp_cxx_ws_string (pp, "template");
    1675                 :        8455 :           pp_cxx_begin_template_argument_list (pp);
    1676                 :             : 
    1677                 :             :           /* If we've shown the template prefix, we'd better show the
    1678                 :             :              parameters' and decl's type too.  */
    1679                 :        8455 :             flags |= TFF_DECL_SPECIFIERS;
    1680                 :             : 
    1681                 :       21504 :           for (i = 0; i < len; i++)
    1682                 :             :             {
    1683                 :       13049 :               if (i)
    1684                 :        4594 :                 pp_separate_with_comma (pp);
    1685                 :       13049 :               dump_template_parameter (pp, TREE_VEC_ELT (inner_parms, i),
    1686                 :             :                                        flags);
    1687                 :             :             }
    1688                 :        8455 :           pp_cxx_end_template_argument_list (pp);
    1689                 :        8455 :           pp_cxx_whitespace (pp);
    1690                 :             :         }
    1691                 :        8200 :       nreverse(orig_parms);
    1692                 :             : 
    1693                 :        8200 :       if (DECL_TEMPLATE_TEMPLATE_PARM_P (t))
    1694                 :             :         {
    1695                 :             :           /* Say `template<arg> class TT' not just `template<arg> TT'.  */
    1696                 :         310 :           pp_cxx_ws_string (pp, "class");
    1697                 :             : 
    1698                 :             :           /* If this is a parameter pack, print the ellipsis.  */
    1699                 :         310 :           if (TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (t)))
    1700                 :          54 :             pp_cxx_ws_string (pp, "...");
    1701                 :             :         }
    1702                 :             : 
    1703                 :             :       /* Only print the requirements if we're also printing
    1704                 :             :          the template header.  */
    1705                 :        8200 :       if (flag_concepts)
    1706                 :        5028 :         if (tree ci = get_constraints (t))
    1707                 :        2302 :           if (check_constraint_info (ci))
    1708                 :        2302 :             if (tree reqs = CI_TEMPLATE_REQS (ci))
    1709                 :             :               {
    1710                 :        1911 :                 pp_cxx_requires_clause (pp, reqs);
    1711                 :        1911 :                 pp_cxx_whitespace (pp);
    1712                 :             :               }
    1713                 :             :     }
    1714                 :             : 
    1715                 :             : 
    1716                 :      357895 :   if (DECL_CLASS_TEMPLATE_P (t))
    1717                 :      294817 :     dump_type (pp, TREE_TYPE (t),
    1718                 :      294817 :                ((flags & ~TFF_CLASS_KEY_OR_ENUM) | TFF_TEMPLATE_NAME
    1719                 :      294817 :                 | (flags & TFF_DECL_SPECIFIERS ? TFF_CLASS_KEY_OR_ENUM : 0)));
    1720                 :       63078 :   else if (DECL_TEMPLATE_RESULT (t)
    1721                 :       63078 :            && (VAR_P (DECL_TEMPLATE_RESULT (t))
    1722                 :             :                /* Alias template.  */
    1723                 :       62950 :                || DECL_TYPE_TEMPLATE_P (t)
    1724                 :             :                /* Concept definition.  &*/
    1725                 :        6689 :                || TREE_CODE (DECL_TEMPLATE_RESULT (t)) == CONCEPT_DECL))
    1726                 :       56681 :     dump_decl (pp, DECL_TEMPLATE_RESULT (t), flags | TFF_TEMPLATE_NAME);
    1727                 :             :   else
    1728                 :             :     {
    1729                 :        6397 :       gcc_assert (TREE_TYPE (t));
    1730                 :        6397 :       switch (NEXT_CODE (t))
    1731                 :             :         {
    1732                 :        6397 :         case METHOD_TYPE:
    1733                 :        6397 :         case FUNCTION_TYPE:
    1734                 :        6397 :           dump_function_decl (pp, t, flags | TFF_TEMPLATE_NAME);
    1735                 :        6397 :           break;
    1736                 :           0 :         default:
    1737                 :             :           /* This case can occur with some invalid code.  */
    1738                 :           0 :           dump_type (pp, TREE_TYPE (t),
    1739                 :           0 :                      (flags & ~TFF_CLASS_KEY_OR_ENUM) | TFF_TEMPLATE_NAME
    1740                 :             :                      | (flags & TFF_DECL_SPECIFIERS
    1741                 :           0 :                         ? TFF_CLASS_KEY_OR_ENUM : 0));
    1742                 :             :         }
    1743                 :             :     }
    1744                 :      357895 : }
    1745                 :             : 
    1746                 :             : /* find_typenames looks through the type of the function template T
    1747                 :             :    and returns a vec containing any typedefs, decltypes or TYPENAME_TYPEs
    1748                 :             :    it finds.  */
    1749                 :             : 
    1750                 :             : struct find_typenames_t
    1751                 :             : {
    1752                 :             :   hash_set<tree> *p_set;
    1753                 :             :   vec<tree, va_gc> *typenames;
    1754                 :             : };
    1755                 :             : 
    1756                 :             : static tree
    1757                 :      186967 : find_typenames_r (tree *tp, int *walk_subtrees, void *data)
    1758                 :             : {
    1759                 :      186967 :   struct find_typenames_t *d = (struct find_typenames_t *)data;
    1760                 :      186967 :   tree mv = NULL_TREE;
    1761                 :             : 
    1762                 :      186967 :   if (TYPE_P (*tp) && is_typedef_decl (TYPE_NAME (*tp)))
    1763                 :             :     /* Add the type of the typedef without any additional cv-quals.  */
    1764                 :        7623 :     mv = TREE_TYPE (TYPE_NAME (*tp));
    1765                 :      179344 :   else if (TREE_CODE (*tp) == TYPENAME_TYPE
    1766                 :      178859 :            || TREE_CODE (*tp) == DECLTYPE_TYPE)
    1767                 :             :     /* Add the typename without any cv-qualifiers.  */
    1768                 :         628 :     mv = TYPE_MAIN_VARIANT (*tp);
    1769                 :             : 
    1770                 :      186967 :   if (PACK_EXPANSION_P (*tp))
    1771                 :             :     {
    1772                 :             :       /* Don't mess with parameter packs since we don't remember
    1773                 :             :          the pack expansion context for a particular typename.  */
    1774                 :        1099 :       *walk_subtrees = false;
    1775                 :        1099 :       return NULL_TREE;
    1776                 :             :     }
    1777                 :             : 
    1778                 :      185868 :   if (mv && (mv == *tp || !d->p_set->add (mv)))
    1779                 :        8251 :     vec_safe_push (d->typenames, mv);
    1780                 :             : 
    1781                 :             :   return NULL_TREE;
    1782                 :             : }
    1783                 :             : 
    1784                 :             : static vec<tree, va_gc> *
    1785                 :       22852 : find_typenames (tree t)
    1786                 :             : {
    1787                 :       22852 :   struct find_typenames_t ft;
    1788                 :       22852 :   ft.p_set = new hash_set<tree>;
    1789                 :       22852 :   ft.typenames = NULL;
    1790                 :       22852 :   cp_walk_tree (&TREE_TYPE (DECL_TEMPLATE_RESULT (t)),
    1791                 :             :                 find_typenames_r, &ft, ft.p_set);
    1792                 :       45704 :   delete ft.p_set;
    1793                 :       22852 :   return ft.typenames;
    1794                 :             : }
    1795                 :             : 
    1796                 :             : /* Output the "[with ...]" clause for a template instantiation T iff
    1797                 :             :    TEMPLATE_PARMS, TEMPLATE_ARGS and FLAGS are suitable.  T may be NULL if
    1798                 :             :    formatting a deduction/substitution diagnostic rather than an
    1799                 :             :    instantiation.  */
    1800                 :             : 
    1801                 :             : static void
    1802                 :      525347 : dump_substitution (cxx_pretty_printer *pp,
    1803                 :             :                    tree t, tree template_parms, tree template_args,
    1804                 :             :                    int flags)
    1805                 :             : {
    1806                 :      525347 :   if (template_parms != NULL_TREE && template_args != NULL_TREE
    1807                 :       24372 :       && !(flags & TFF_NO_TEMPLATE_BINDINGS))
    1808                 :             :     {
    1809                 :       24372 :       vec<tree, va_gc> *typenames = t ? find_typenames (t) : NULL;
    1810                 :       24372 :       dump_template_bindings (pp, template_parms, template_args, typenames);
    1811                 :             :     }
    1812                 :      525347 : }
    1813                 :             : 
    1814                 :             : /* Dump the lambda function FN including its 'mutable' qualifier and any
    1815                 :             :    template bindings.  */
    1816                 :             : 
    1817                 :             : static void
    1818                 :        4881 : dump_lambda_function (cxx_pretty_printer *pp,
    1819                 :             :                       tree fn, tree template_parms, tree template_args,
    1820                 :             :                       int flags)
    1821                 :             : {
    1822                 :             :   /* A lambda's signature is essentially its "type".  */
    1823                 :        4881 :   dump_type (pp, DECL_CONTEXT (fn), flags);
    1824                 :        4881 :   if (DECL_XOBJ_MEMBER_FUNCTION_P (fn))
    1825                 :             :     /* Early escape.  */;
    1826                 :        4855 :   else if (TREE_CODE (TREE_TYPE (fn)) == FUNCTION_TYPE)
    1827                 :             :     {
    1828                 :           0 :       pp->set_padding (pp_before);
    1829                 :           0 :       pp_c_ws_string (pp, "static");
    1830                 :             :     }
    1831                 :        4855 :   else if (!(TYPE_QUALS (class_of_this_parm (TREE_TYPE (fn)))
    1832                 :        4855 :              & TYPE_QUAL_CONST))
    1833                 :             :     {
    1834                 :         248 :       pp->set_padding (pp_before);
    1835                 :         248 :       pp_c_ws_string (pp, "mutable");
    1836                 :             :     }
    1837                 :        4881 :   dump_substitution (pp, fn, template_parms, template_args, flags);
    1838                 :        4881 : }
    1839                 :             : 
    1840                 :             : /* Pretty print a function decl. There are several ways we want to print a
    1841                 :             :    function declaration. The TFF_ bits in FLAGS tells us how to behave.
    1842                 :             :    As error can only apply the '#' flag once to give 0 and 1 for V, there
    1843                 :             :    is %D which doesn't print the throw specs, and %F which does.  */
    1844                 :             : 
    1845                 :             : static void
    1846                 :      534400 : dump_function_decl (cxx_pretty_printer *pp, tree t, int flags)
    1847                 :             : {
    1848                 :      534400 :   tree fntype;
    1849                 :      534400 :   tree parmtypes;
    1850                 :      534400 :   tree cname = NULL_TREE;
    1851                 :      534400 :   tree template_args = NULL_TREE;
    1852                 :      534400 :   tree template_parms = NULL_TREE;
    1853                 :      534400 :   int show_return = flags & TFF_RETURN_TYPE || flags & TFF_DECL_SPECIFIERS;
    1854                 :      534400 :   int do_outer_scope = ! (flags & TFF_UNQUALIFIED_NAME);
    1855                 :      534400 :   tree exceptions;
    1856                 :      534400 :   bool constexpr_p;
    1857                 :      534400 :   tree ret = NULL_TREE;
    1858                 :             : 
    1859                 :      534400 :   int dump_function_name_flags = flags & ~TFF_UNQUALIFIED_NAME;
    1860                 :      534400 :   flags = dump_function_name_flags & ~TFF_TEMPLATE_NAME;
    1861                 :      534400 :   if (TREE_CODE (t) == TEMPLATE_DECL)
    1862                 :        6397 :     t = DECL_TEMPLATE_RESULT (t);
    1863                 :             : 
    1864                 :             :   /* Save the exceptions, in case t is a specialization and we are
    1865                 :             :      emitting an error about incompatible specifications.  */
    1866                 :      534400 :   exceptions = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (t));
    1867                 :             : 
    1868                 :             :   /* Likewise for the constexpr specifier, in case t is a specialization.  */
    1869                 :      534400 :   constexpr_p = (DECL_DECLARED_CONSTEXPR_P (t)
    1870                 :      534400 :                  && !decl_implicit_constexpr_p (t));
    1871                 :             : 
    1872                 :             :   /* Pretty print template instantiations only.  */
    1873                 :      731743 :   if (DECL_USE_TEMPLATE (t) && DECL_TEMPLATE_INFO (t)
    1874                 :      197289 :       && !(flags & TFF_NO_TEMPLATE_BINDINGS)
    1875                 :      557293 :       && flag_pretty_templates)
    1876                 :             :     {
    1877                 :       22866 :       tree tmpl;
    1878                 :             : 
    1879                 :       22866 :       template_args = DECL_TI_ARGS (t);
    1880                 :       22866 :       tmpl = most_general_template (t);
    1881                 :       22866 :       if (tmpl && TREE_CODE (tmpl) == TEMPLATE_DECL)
    1882                 :             :         {
    1883                 :       22852 :           template_parms = DECL_TEMPLATE_PARMS (tmpl);
    1884                 :       22852 :           t = tmpl;
    1885                 :             :         }
    1886                 :             :     }
    1887                 :             : 
    1888                 :      545613 :   if (DECL_NAME (t) && LAMBDA_FUNCTION_P (t))
    1889                 :        4881 :     return dump_lambda_function (pp, t, template_parms, template_args, flags);
    1890                 :             : 
    1891                 :      529519 :   fntype = TREE_TYPE (t);
    1892                 :      529519 :   parmtypes = FUNCTION_FIRST_USER_PARMTYPE (t);
    1893                 :             : 
    1894                 :      529519 :   if (DECL_CLASS_SCOPE_P (t))
    1895                 :      139469 :     cname = DECL_CONTEXT (t);
    1896                 :             :   /* This is for partially instantiated template methods.  */
    1897                 :      390050 :   else if (TREE_CODE (fntype) == METHOD_TYPE)
    1898                 :           0 :     cname = TREE_TYPE (TREE_VALUE (parmtypes));
    1899                 :             : 
    1900                 :      529519 :   if (flags & TFF_DECL_SPECIFIERS)
    1901                 :             :     {
    1902                 :      105633 :       if (DECL_STATIC_FUNCTION_P (t))
    1903                 :        2711 :         pp_cxx_ws_string (pp, "static");
    1904                 :      102922 :       else if (DECL_VIRTUAL_P (t))
    1905                 :        2425 :         pp_cxx_ws_string (pp, "virtual");
    1906                 :             : 
    1907                 :      105633 :       if (constexpr_p)
    1908                 :             :         {
    1909                 :       33878 :           if (DECL_IMMEDIATE_FUNCTION_P (t))
    1910                 :         212 :             pp_cxx_ws_string (pp, "consteval");
    1911                 :             :           else
    1912                 :       16727 :             pp_cxx_ws_string (pp, "constexpr");
    1913                 :             :         }
    1914                 :             :     }
    1915                 :             : 
    1916                 :             :   /* Print the return type?  */
    1917                 :      529519 :   if (show_return)
    1918                 :      316131 :     show_return = (!DECL_CONV_FN_P (t)  && !DECL_CONSTRUCTOR_P (t)
    1919                 :      201536 :                    && !DECL_DESTRUCTOR_P (t) && !deduction_guide_p (t));
    1920                 :       94235 :   if (show_return)
    1921                 :             :     {
    1922                 :       94235 :       ret = fndecl_declared_return_type (t);
    1923                 :       94235 :       dump_type_prefix (pp, ret, flags);
    1924                 :             :     }
    1925                 :             : 
    1926                 :             :   /* Print the function name.  */
    1927                 :      529519 :   if (!do_outer_scope)
    1928                 :             :     /* Nothing.  */;
    1929                 :      529519 :   else if (cname)
    1930                 :             :     {
    1931                 :      139469 :       dump_type (pp, cname, flags);
    1932                 :      139469 :       pp_cxx_colon_colon (pp);
    1933                 :             :     }
    1934                 :             :   else
    1935                 :      390050 :     dump_scope (pp, CP_DECL_CONTEXT (t), flags);
    1936                 :             : 
    1937                 :             :   /* Name lookup for the rest of the function declarator is implicitly in the
    1938                 :             :      scope of the function, so avoid printing redundant scope qualifiers.  */
    1939                 :      529519 :   auto cds = make_temp_override (current_dump_scope, CP_DECL_CONTEXT (t));
    1940                 :             : 
    1941                 :      529519 :   dump_function_name (pp, t, dump_function_name_flags);
    1942                 :             : 
    1943                 :      529519 :   if (!(flags & TFF_NO_FUNCTION_ARGUMENTS))
    1944                 :             :     {
    1945                 :      518946 :       int const parm_flags
    1946                 :      518946 :         = DECL_XOBJ_MEMBER_FUNCTION_P (t) ? TFF_XOBJ_FUNC | flags : flags;
    1947                 :      518946 :       dump_parameters (pp, parmtypes, parm_flags);
    1948                 :             : 
    1949                 :      518946 :       if (TREE_CODE (fntype) == METHOD_TYPE)
    1950                 :             :         {
    1951                 :      133918 :           pp->set_padding (pp_before);
    1952                 :      133918 :           pp_cxx_cv_qualifier_seq (pp, class_of_this_parm (fntype));
    1953                 :      133918 :           dump_ref_qualifier (pp, fntype, flags);
    1954                 :             :         }
    1955                 :             : 
    1956                 :      518946 :       if (tx_safe_fn_type_p (fntype))
    1957                 :             :         {
    1958                 :          18 :           pp->set_padding (pp_before);
    1959                 :          18 :           pp_cxx_ws_string (pp, "transaction_safe");
    1960                 :             :         }
    1961                 :             : 
    1962                 :      518946 :       if (flags & TFF_EXCEPTION_SPECIFICATION)
    1963                 :             :         {
    1964                 :         349 :           pp->set_padding (pp_before);
    1965                 :         349 :           dump_exception_spec (pp, exceptions, flags);
    1966                 :             :         }
    1967                 :             : 
    1968                 :      518946 :       if (show_return)
    1969                 :       94235 :         dump_type_suffix (pp, ret, flags);
    1970                 :      424711 :       else if (deduction_guide_p (t))
    1971                 :             :         {
    1972                 :         688 :           pp->set_padding (pp_before);
    1973                 :         688 :           pp_cxx_ws_string (pp, "->");
    1974                 :         688 :           dump_type (pp, TREE_TYPE (TREE_TYPE (t)), flags);
    1975                 :             :         }
    1976                 :             : 
    1977                 :      518946 :       if (flag_concepts)
    1978                 :      358988 :         if (tree ci = get_constraints (t))
    1979                 :       61384 :           if (tree reqs = CI_DECLARATOR_REQS (ci))
    1980                 :       18938 :             pp_cxx_requires_clause (pp, reqs);
    1981                 :             : 
    1982                 :      518946 :       dump_substitution (pp, t, template_parms, template_args, flags);
    1983                 :             : 
    1984                 :     1048536 :       if (tree base = DECL_INHERITED_CTOR_BASE (t))
    1985                 :             :         {
    1986                 :          71 :           pp_cxx_ws_string (pp, "[inherited from");
    1987                 :          71 :           dump_type (pp, base, TFF_PLAIN_IDENTIFIER);
    1988                 :          71 :           pp_character (pp, ']');
    1989                 :             :         }
    1990                 :             :     }
    1991                 :       10573 :   else if (template_args)
    1992                 :             :     {
    1993                 :           0 :       bool need_comma = false;
    1994                 :           0 :       int i;
    1995                 :           0 :       pp_cxx_begin_template_argument_list (pp);
    1996                 :           0 :       template_args = INNERMOST_TEMPLATE_ARGS (template_args);
    1997                 :           0 :       for (i = 0; i < TREE_VEC_LENGTH (template_args); ++i)
    1998                 :             :         {
    1999                 :           0 :           tree arg = TREE_VEC_ELT (template_args, i);
    2000                 :           0 :           if (need_comma)
    2001                 :           0 :             pp_separate_with_comma (pp);
    2002                 :           0 :           if (ARGUMENT_PACK_P (arg))
    2003                 :           0 :             pp_cxx_left_brace (pp);
    2004                 :           0 :           dump_template_argument (pp, arg, TFF_PLAIN_IDENTIFIER);
    2005                 :           0 :           if (ARGUMENT_PACK_P (arg))
    2006                 :           0 :             pp_cxx_right_brace (pp);
    2007                 :           0 :           need_comma = true;
    2008                 :             :         }
    2009                 :           0 :       pp_cxx_end_template_argument_list (pp);
    2010                 :             :     }
    2011                 :      529519 : }
    2012                 :             : 
    2013                 :             : /* Print a parameter list. If this is for a member function, the
    2014                 :             :    member object ptr (and any other hidden args) should have
    2015                 :             :    already been removed.  */
    2016                 :             : 
    2017                 :             : static void
    2018                 :     1813994 : dump_parameters (cxx_pretty_printer *pp, tree parmtypes, int flags)
    2019                 :             : {
    2020                 :     1813994 :   int first = 1;
    2021                 :     1813994 :   flags &= ~TFF_SCOPE;
    2022                 :     1813994 :   pp_cxx_left_paren (pp);
    2023                 :             : 
    2024                 :     5579458 :   for (first = 1; parmtypes != void_list_node;
    2025                 :     1951470 :        parmtypes = TREE_CHAIN (parmtypes))
    2026                 :             :     {
    2027                 :     1953860 :       if (first && flags & TFF_XOBJ_FUNC)
    2028                 :        1521 :         pp_string (pp, "this ");
    2029                 :      961192 :       if (!first)
    2030                 :      961192 :         pp_separate_with_comma (pp);
    2031                 :     1953860 :       first = 0;
    2032                 :     1953860 :       if (!parmtypes)
    2033                 :             :         {
    2034                 :        2390 :           pp_cxx_ws_string (pp, "...");
    2035                 :        2390 :           break;
    2036                 :             :         }
    2037                 :             : 
    2038                 :     1951470 :       dump_type (pp, TREE_VALUE (parmtypes), flags);
    2039                 :             : 
    2040                 :     1951482 :       if ((flags & TFF_FUNCTION_DEFAULT_ARGUMENTS) && TREE_PURPOSE (parmtypes))
    2041                 :             :         {
    2042                 :           6 :           pp_cxx_whitespace (pp);
    2043                 :           6 :           pp_equal (pp);
    2044                 :           6 :           pp_cxx_whitespace (pp);
    2045                 :           6 :           dump_expr (pp, TREE_PURPOSE (parmtypes), flags | TFF_EXPR_IN_PARENS);
    2046                 :             :         }
    2047                 :             :     }
    2048                 :             : 
    2049                 :     1813994 :   pp_cxx_right_paren (pp);
    2050                 :     1813994 : }
    2051                 :             : 
    2052                 :             : /* Print ref-qualifier of a FUNCTION_TYPE or METHOD_TYPE. FLAGS are ignored. */
    2053                 :             : 
    2054                 :             : static void
    2055                 :     1106417 : dump_ref_qualifier (cxx_pretty_printer *pp, tree t, int flags ATTRIBUTE_UNUSED)
    2056                 :             : {
    2057                 :     1106417 :   if (FUNCTION_REF_QUALIFIED (t))
    2058                 :             :     {
    2059                 :        1344 :       pp->set_padding (pp_before);
    2060                 :        1344 :       if (FUNCTION_RVALUE_QUALIFIED (t))
    2061                 :         461 :         pp_cxx_ws_string (pp, "&&");
    2062                 :             :       else
    2063                 :         883 :         pp_cxx_ws_string (pp, "&");
    2064                 :             :     }
    2065                 :     1106417 : }
    2066                 :             : 
    2067                 :             : /* Print an exception specification. T is the exception specification.  */
    2068                 :             : 
    2069                 :             : static void
    2070                 :      972848 : dump_exception_spec (cxx_pretty_printer *pp, tree t, int flags)
    2071                 :             : {
    2072                 :     1006393 :   if (t && TREE_PURPOSE (t))
    2073                 :             :     {
    2074                 :       33445 :       pp_cxx_ws_string (pp, "noexcept");
    2075                 :       33445 :       if (!integer_onep (TREE_PURPOSE (t)))
    2076                 :             :         {
    2077                 :          86 :           pp_cxx_whitespace (pp);
    2078                 :          86 :           pp_cxx_left_paren (pp);
    2079                 :          86 :           if (DEFERRED_NOEXCEPT_SPEC_P (t))
    2080                 :           0 :             pp_cxx_ws_string (pp, "<uninstantiated>");
    2081                 :             :           else
    2082                 :          86 :             dump_expr (pp, TREE_PURPOSE (t), flags);
    2083                 :          86 :           pp_cxx_right_paren (pp);
    2084                 :             :         }
    2085                 :             :     }
    2086                 :      939403 :   else if (t)
    2087                 :             :     {
    2088                 :         100 :       pp_cxx_ws_string (pp, "throw");
    2089                 :         100 :       pp_cxx_whitespace (pp);
    2090                 :         100 :       pp_cxx_left_paren (pp);
    2091                 :         100 :       if (TREE_VALUE (t) != NULL_TREE)
    2092                 :          75 :         while (1)
    2093                 :             :           {
    2094                 :          63 :             dump_type (pp, TREE_VALUE (t), flags);
    2095                 :          63 :             t = TREE_CHAIN (t);
    2096                 :          63 :             if (!t)
    2097                 :             :               break;
    2098                 :          12 :             pp_separate_with_comma (pp);
    2099                 :             :           }
    2100                 :         100 :       pp_cxx_right_paren (pp);
    2101                 :             :     }
    2102                 :      972848 : }
    2103                 :             : 
    2104                 :             : /* Handle the function name for a FUNCTION_DECL node, grokking operators
    2105                 :             :    and destructors properly.  */
    2106                 :             : 
    2107                 :             : static void
    2108                 :    76247229 : dump_function_name (cxx_pretty_printer *pp, tree t, int flags)
    2109                 :             : {
    2110                 :             :   /* Only colorize when we're printing something before the name; in
    2111                 :             :      particular, not when printing a CALL_EXPR.  */
    2112                 :    76247229 :   bool colorize = flags & (TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE
    2113                 :             :                            | TFF_TEMPLATE_HEADER);
    2114                 :             : 
    2115                 :    76247229 :   colorize_guard g (colorize, pp, "fnname");
    2116                 :             : 
    2117                 :    76247229 :   tree name = DECL_NAME (t);
    2118                 :             : 
    2119                 :             :   /* We can get here with a decl that was synthesized by language-
    2120                 :             :      independent machinery (e.g. coverage.cc) in which case it won't
    2121                 :             :      have a lang_specific structure attached and DECL_CONSTRUCTOR_P
    2122                 :             :      will crash.  In this case it is safe just to print out the
    2123                 :             :      literal name.  */
    2124                 :    76247229 :   if (!DECL_LANG_SPECIFIC (t))
    2125                 :             :     {
    2126                 :        5890 :       pp_cxx_tree_identifier (pp, name);
    2127                 :        5890 :       return;
    2128                 :             :     }
    2129                 :             : 
    2130                 :    76241339 :   if (TREE_CODE (t) == TEMPLATE_DECL)
    2131                 :       22597 :     t = DECL_TEMPLATE_RESULT (t);
    2132                 :             : 
    2133                 :             :   /* Don't let the user see __comp_ctor et al.  */
    2134                 :    76241339 :   if (DECL_CONSTRUCTOR_P (t)
    2135                 :    76241339 :       || DECL_DESTRUCTOR_P (t))
    2136                 :             :     {
    2137                 :    30259683 :       if (LAMBDA_TYPE_P (DECL_CONTEXT (t)))
    2138                 :      252822 :         name = get_identifier ("<lambda>");
    2139                 :    29781599 :       else if (TYPE_UNNAMED_P (DECL_CONTEXT (t)))
    2140                 :         101 :         name = get_identifier ("<constructor>");
    2141                 :             :       else
    2142                 :    14890648 :         name = constructor_name (DECL_CONTEXT (t));
    2143                 :             :     }
    2144                 :             : 
    2145                 :   152482678 :   if (DECL_DESTRUCTOR_P (t))
    2146                 :             :     {
    2147                 :     2134672 :       pp_cxx_complement (pp);
    2148                 :     2134672 :       dump_decl (pp, name, TFF_PLAIN_IDENTIFIER);
    2149                 :             :     }
    2150                 :    74106667 :   else if (DECL_CONV_FN_P (t))
    2151                 :             :     {
    2152                 :             :       /* This cannot use the hack that the operator's return
    2153                 :             :          type is stashed off of its name because it may be
    2154                 :             :          used for error reporting.  In the case of conflicting
    2155                 :             :          declarations, both will have the same name, yet
    2156                 :             :          the types will be different, hence the TREE_TYPE field
    2157                 :             :          of the first name will be clobbered by the second.  */
    2158                 :      961477 :       pp_cxx_ws_string (pp, "operator");
    2159                 :      961477 :       dump_type (pp, TREE_TYPE (TREE_TYPE (t)), flags);
    2160                 :             :     }
    2161                 :             :   else
    2162                 :    73145190 :     dump_decl (pp, name, flags);
    2163                 :             : 
    2164                 :    76241339 :   dump_module_suffix (pp, t);
    2165                 :             : 
    2166                 :    76241339 :   if (DECL_TEMPLATE_INFO (t)
    2167                 :    58613174 :       && !(flags & TFF_TEMPLATE_NAME)
    2168                 :    58607088 :       && !DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t)
    2169                 :   134813736 :       && (TREE_CODE (DECL_TI_TEMPLATE (t)) != TEMPLATE_DECL
    2170                 :    58572383 :           || PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t))))
    2171                 :      495733 :     dump_template_parms (pp, DECL_TEMPLATE_INFO (t), !DECL_USE_TEMPLATE (t),
    2172                 :             :                          flags);
    2173                 :    76247229 : }
    2174                 :             : 
    2175                 :             : /* Dump the template parameters from the template info INFO under control of
    2176                 :             :    FLAGS. PRIMARY indicates whether this is a primary template decl, or
    2177                 :             :    specialization (partial or complete). For partial specializations we show
    2178                 :             :    the specialized parameter values. For a primary template we show no
    2179                 :             :    decoration.  */
    2180                 :             : 
    2181                 :             : static void
    2182                 :    66333133 : dump_template_parms (cxx_pretty_printer *pp, tree info,
    2183                 :             :                      int primary, int flags)
    2184                 :             : {
    2185                 :   132666266 :   tree args = info ? TI_ARGS (info) : NULL_TREE;
    2186                 :             : 
    2187                 :    66333133 :   if (primary && flags & TFF_TEMPLATE_NAME)
    2188                 :             :     return;
    2189                 :    66038281 :   flags &= ~(TFF_CLASS_KEY_OR_ENUM | TFF_TEMPLATE_NAME);
    2190                 :    66038281 :   pp_cxx_begin_template_argument_list (pp);
    2191                 :             : 
    2192                 :             :   /* Be careful only to print things when we have them, so as not
    2193                 :             :      to crash producing error messages.  */
    2194                 :    66038281 :   if (args && !primary)
    2195                 :             :     {
    2196                 :    66018626 :       int len, ix;
    2197                 :    66018626 :       len = get_non_default_template_args_count (args, flags);
    2198                 :             : 
    2199                 :    66018626 :       args = INNERMOST_TEMPLATE_ARGS (args);
    2200                 :   165078989 :       for (ix = 0; ix != len; ix++)
    2201                 :             :         {
    2202                 :    99060363 :           tree arg = TREE_VEC_ELT (args, ix);
    2203                 :             : 
    2204                 :             :           /* Only print a comma if we know there is an argument coming. In
    2205                 :             :              the case of an empty template argument pack, no actual
    2206                 :             :              argument will be printed.  */
    2207                 :    99060363 :           if (ix
    2208                 :    99060363 :               && (!ARGUMENT_PACK_P (arg)
    2209                 :     4567434 :                   || TREE_VEC_LENGTH (ARGUMENT_PACK_ARGS (arg)) > 0))
    2210                 :    32703093 :             pp_separate_with_comma (pp);
    2211                 :             : 
    2212                 :    99060363 :           if (!arg)
    2213                 :           0 :             pp_string (pp, M_("<template parameter error>"));
    2214                 :             :           else
    2215                 :    99060363 :             dump_template_argument (pp, arg, flags);
    2216                 :             :         }
    2217                 :             :     }
    2218                 :       19655 :   else if (primary)
    2219                 :             :     {
    2220                 :       19649 :       tree tpl = TI_TEMPLATE (info);
    2221                 :       19649 :       tree parms = DECL_TEMPLATE_PARMS (tpl);
    2222                 :       19649 :       int len, ix;
    2223                 :             : 
    2224                 :       19649 :       parms = TREE_CODE (parms) == TREE_LIST ? TREE_VALUE (parms) : NULL_TREE;
    2225                 :       39298 :       len = parms ? TREE_VEC_LENGTH (parms) : 0;
    2226                 :             : 
    2227                 :       50810 :       for (ix = 0; ix != len; ix++)
    2228                 :             :         {
    2229                 :       31161 :           tree parm;
    2230                 :             : 
    2231                 :       31161 :           if (TREE_VEC_ELT (parms, ix) == error_mark_node)
    2232                 :             :             {
    2233                 :           0 :               pp_string (pp, M_("<template parameter error>"));
    2234                 :           0 :               continue;
    2235                 :             :             }
    2236                 :             : 
    2237                 :       31161 :           parm = TREE_VALUE (TREE_VEC_ELT (parms, ix));
    2238                 :             : 
    2239                 :       31161 :           if (ix)
    2240                 :       11512 :             pp_separate_with_comma (pp);
    2241                 :             : 
    2242                 :       31161 :           dump_decl (pp, parm, flags & ~TFF_DECL_SPECIFIERS);
    2243                 :             :         }
    2244                 :             :     }
    2245                 :    66038281 :   pp_cxx_end_template_argument_list (pp);
    2246                 :             : }
    2247                 :             : 
    2248                 :             : /* Print out the arguments of CALL_EXPR T as a parenthesized list using
    2249                 :             :    flags FLAGS.  Skip over the first argument if SKIPFIRST is true.  */
    2250                 :             : 
    2251                 :             : static void
    2252                 :        2818 : dump_call_expr_args (cxx_pretty_printer *pp, tree t, int flags, bool skipfirst)
    2253                 :             : {
    2254                 :        2818 :   const int len = call_expr_nargs (t);
    2255                 :             : 
    2256                 :        2818 :   pp_cxx_left_paren (pp);
    2257                 :        4874 :   for (int i = skipfirst; i < len; ++i)
    2258                 :             :     {
    2259                 :        2056 :       tree arg = get_nth_callarg (t, i);
    2260                 :        2056 :       dump_expr (pp, arg, flags | TFF_EXPR_IN_PARENS);
    2261                 :        2056 :       if (i + 1 < len)
    2262                 :         420 :         pp_separate_with_comma (pp);
    2263                 :             :     }
    2264                 :        2818 :   pp_cxx_right_paren (pp);
    2265                 :        2818 : }
    2266                 :             : 
    2267                 :             : /* Print out a list of initializers (subr of dump_expr).  */
    2268                 :             : 
    2269                 :             : static void
    2270                 :         212 : dump_expr_list (cxx_pretty_printer *pp, tree l, int flags)
    2271                 :             : {
    2272                 :         223 :   while (l)
    2273                 :             :     {
    2274                 :         105 :       dump_expr (pp, TREE_VALUE (l), flags | TFF_EXPR_IN_PARENS);
    2275                 :         105 :       l = TREE_CHAIN (l);
    2276                 :         105 :       if (l)
    2277                 :          11 :         pp_separate_with_comma (pp);
    2278                 :             :     }
    2279                 :         212 : }
    2280                 :             : 
    2281                 :             : /* Print out a vector of initializers (subr of dump_expr).  */
    2282                 :             : 
    2283                 :             : static void
    2284                 :         280 : dump_expr_init_vec (cxx_pretty_printer *pp, vec<constructor_elt, va_gc> *v,
    2285                 :             :                     int flags)
    2286                 :             : {
    2287                 :         280 :   unsigned HOST_WIDE_INT idx;
    2288                 :         280 :   tree value;
    2289                 :             : 
    2290                 :         638 :   FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value)
    2291                 :             :     {
    2292                 :         358 :       if (TREE_CODE (value) == RAW_DATA_CST)
    2293                 :           0 :         for (unsigned i = 0; i < (unsigned) RAW_DATA_LENGTH (value); ++i)
    2294                 :             :           {
    2295                 :           0 :             if (TYPE_UNSIGNED (TREE_TYPE (value))
    2296                 :           0 :                 || TYPE_PRECISION (TREE_TYPE (value)) > CHAR_BIT)
    2297                 :           0 :               pp_decimal_int (pp, RAW_DATA_UCHAR_ELT (value, i));
    2298                 :             :             else
    2299                 :           0 :               pp_decimal_int (pp, RAW_DATA_SCHAR_ELT (value, i));
    2300                 :           0 :             if (i == RAW_DATA_LENGTH (value) - 1U)
    2301                 :             :               break;
    2302                 :           0 :             else if (i == 9 && RAW_DATA_LENGTH (value) > 20)
    2303                 :             :               {
    2304                 :           0 :                 pp_string (pp, ", ..., ");
    2305                 :           0 :                 i = RAW_DATA_LENGTH (value) - 11;
    2306                 :             :               }
    2307                 :             :             else
    2308                 :           0 :               pp_separate_with_comma (pp);
    2309                 :             :           }
    2310                 :             :       else
    2311                 :         358 :         dump_expr (pp, value, flags | TFF_EXPR_IN_PARENS);
    2312                 :         358 :       if (idx != v->length () - 1)
    2313                 :         105 :         pp_separate_with_comma (pp);
    2314                 :             :     }
    2315                 :         280 : }
    2316                 :             : 
    2317                 :             : 
    2318                 :             : /* We've gotten an indirect REFERENCE (an OBJ_TYPE_REF) to a virtual
    2319                 :             :    function.  Resolve it to a close relative -- in the sense of static
    2320                 :             :    type -- variant being overridden.  That is close to what was written in
    2321                 :             :    the source code.  Subroutine of dump_expr.  */
    2322                 :             : 
    2323                 :             : static tree
    2324                 :          22 : resolve_virtual_fun_from_obj_type_ref (tree ref)
    2325                 :             : {
    2326                 :          22 :   tree obj_type = TREE_TYPE (OBJ_TYPE_REF_TOKEN (ref));
    2327                 :          22 :   HOST_WIDE_INT index = tree_to_uhwi (OBJ_TYPE_REF_TOKEN (ref));
    2328                 :          22 :   tree fun = BINFO_VIRTUALS (TYPE_BINFO (TREE_TYPE (obj_type)));
    2329                 :          38 :   while (index)
    2330                 :             :     {
    2331                 :          16 :       fun = TREE_CHAIN (fun);
    2332                 :          16 :       index -= (TARGET_VTABLE_USES_DESCRIPTORS
    2333                 :             :                 ? TARGET_VTABLE_USES_DESCRIPTORS : 1);
    2334                 :             :     }
    2335                 :             : 
    2336                 :          22 :   return BV_FN (fun);
    2337                 :             : }
    2338                 :             : 
    2339                 :             : /* Print out an expression E under control of FLAGS.  */
    2340                 :             : 
    2341                 :             : static void
    2342                 :    12316411 : dump_expr (cxx_pretty_printer *pp, tree t, int flags)
    2343                 :             : {
    2344                 :    12330976 :   tree op;
    2345                 :             : 
    2346                 :    12330976 :   if (t == 0)
    2347                 :             :     return;
    2348                 :             : 
    2349                 :    12330964 :   if (STATEMENT_CLASS_P (t))
    2350                 :             :     {
    2351                 :          15 :       pp_cxx_ws_string (pp, M_("<statement>"));
    2352                 :          15 :       return;
    2353                 :             :     }
    2354                 :             : 
    2355                 :    12330949 :   switch (TREE_CODE (t))
    2356                 :             :     {
    2357                 :       38369 :     case VAR_DECL:
    2358                 :       38369 :     case PARM_DECL:
    2359                 :       38369 :     case FIELD_DECL:
    2360                 :       38369 :     case CONST_DECL:
    2361                 :       38369 :     case FUNCTION_DECL:
    2362                 :       38369 :     case TEMPLATE_DECL:
    2363                 :       38369 :     case NAMESPACE_DECL:
    2364                 :       38369 :     case LABEL_DECL:
    2365                 :       38369 :     case OVERLOAD:
    2366                 :       38369 :     case TYPE_DECL:
    2367                 :       38369 :     case USING_DECL:
    2368                 :       38369 :     case IDENTIFIER_NODE:
    2369                 :       38369 :       dump_decl (pp, t, ((flags & ~(TFF_DECL_SPECIFIERS|TFF_RETURN_TYPE
    2370                 :             :                                     |TFF_TEMPLATE_HEADER))
    2371                 :             :                          | TFF_NO_TEMPLATE_BINDINGS
    2372                 :       38369 :                          | TFF_NO_FUNCTION_ARGUMENTS));
    2373                 :       38369 :       break;
    2374                 :             : 
    2375                 :        6407 :     case SSA_NAME:
    2376                 :        6407 :       if (SSA_NAME_VAR (t)
    2377                 :        6335 :           && !DECL_ARTIFICIAL (SSA_NAME_VAR (t)))
    2378                 :             :         dump_expr (pp, SSA_NAME_VAR (t), flags);
    2379                 :             :       else
    2380                 :          73 :         pp_cxx_ws_string (pp, M_("<unknown>"));
    2381                 :             :       break;
    2382                 :             : 
    2383                 :    12259526 :     case VOID_CST:
    2384                 :    12259526 :     case INTEGER_CST:
    2385                 :    12259526 :     case REAL_CST:
    2386                 :    12259526 :     case STRING_CST:
    2387                 :    12259526 :     case COMPLEX_CST:
    2388                 :    12259526 :       pp->constant (t);
    2389                 :    12259526 :       break;
    2390                 :             : 
    2391                 :           0 :     case USERDEF_LITERAL:
    2392                 :           0 :       pp_cxx_userdef_literal (pp, t);
    2393                 :           0 :       break;
    2394                 :             : 
    2395                 :         139 :     case THROW_EXPR:
    2396                 :             :       /* While waiting for caret diagnostics, avoid printing
    2397                 :             :          __cxa_allocate_exception, __cxa_throw, and the like.  */
    2398                 :         139 :       pp_cxx_ws_string (pp, M_("<throw-expression>"));
    2399                 :         139 :       break;
    2400                 :             : 
    2401                 :         333 :     case PTRMEM_CST:
    2402                 :         333 :       pp_ampersand (pp);
    2403                 :         333 :       dump_type (pp, PTRMEM_CST_CLASS (t), flags);
    2404                 :         333 :       pp_cxx_colon_colon (pp);
    2405                 :         333 :       pp_cxx_tree_identifier (pp, DECL_NAME (PTRMEM_CST_MEMBER (t)));
    2406                 :         333 :       break;
    2407                 :             : 
    2408                 :         116 :     case COMPOUND_EXPR:
    2409                 :         116 :       pp_cxx_left_paren (pp);
    2410                 :         116 :       dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
    2411                 :         116 :       pp_separate_with_comma (pp);
    2412                 :         116 :       dump_expr (pp, TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
    2413                 :         116 :       pp_cxx_right_paren (pp);
    2414                 :         116 :       break;
    2415                 :             : 
    2416                 :          64 :     case COND_EXPR:
    2417                 :          64 :     case VEC_COND_EXPR:
    2418                 :          64 :       pp_cxx_left_paren (pp);
    2419                 :          64 :       dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
    2420                 :          64 :       pp_string (pp, " ? ");
    2421                 :          64 :       dump_expr (pp, TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
    2422                 :          64 :       pp_string (pp, " : ");
    2423                 :          64 :       dump_expr (pp, TREE_OPERAND (t, 2), flags | TFF_EXPR_IN_PARENS);
    2424                 :          64 :       pp_cxx_right_paren (pp);
    2425                 :          64 :       break;
    2426                 :             : 
    2427                 :         236 :     case SAVE_EXPR:
    2428                 :         236 :       if (TREE_HAS_CONSTRUCTOR (t))
    2429                 :             :         {
    2430                 :           0 :           pp_cxx_ws_string (pp, "new");
    2431                 :           0 :           pp_cxx_whitespace (pp);
    2432                 :           0 :           dump_type (pp, TREE_TYPE (TREE_TYPE (t)), flags);
    2433                 :             :         }
    2434                 :             :       else
    2435                 :         236 :         dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
    2436                 :             :       break;
    2437                 :             : 
    2438                 :        2818 :     case AGGR_INIT_EXPR:
    2439                 :        2818 :     case CALL_EXPR:
    2440                 :        2818 :       {
    2441                 :        2818 :         tree fn = cp_get_callee (t);
    2442                 :        2818 :         bool skipfirst = false;
    2443                 :             : 
    2444                 :             :         /* Deal with internal functions.  */
    2445                 :        2818 :         if (fn == NULL_TREE)
    2446                 :             :           {
    2447                 :           3 :             pp_string (pp, internal_fn_name (CALL_EXPR_IFN (t)));
    2448                 :           3 :             dump_call_expr_args (pp, t, flags, skipfirst);
    2449                 :           3 :             break;
    2450                 :             :           }
    2451                 :             : 
    2452                 :        2815 :         if (TREE_CODE (fn) == ADDR_EXPR)
    2453                 :        1956 :           fn = TREE_OPERAND (fn, 0);
    2454                 :             : 
    2455                 :             :         /* Nobody is interested in seeing the guts of vcalls.  */
    2456                 :        2815 :         if (TREE_CODE (fn) == OBJ_TYPE_REF)
    2457                 :          16 :           fn = resolve_virtual_fun_from_obj_type_ref (fn);
    2458                 :             : 
    2459                 :        2815 :         if (TREE_TYPE (fn) != NULL_TREE
    2460                 :        2466 :             && NEXT_CODE (fn) == METHOD_TYPE
    2461                 :        3333 :             && call_expr_nargs (t))
    2462                 :             :           {
    2463                 :         515 :             tree ob = get_nth_callarg (t, 0);
    2464                 :         515 :             if (is_dummy_object (ob))
    2465                 :             :               /* Don't print dummy object.  */;
    2466                 :         414 :             else if (TREE_CODE (ob) == ADDR_EXPR)
    2467                 :             :               {
    2468                 :         265 :                 dump_expr (pp, TREE_OPERAND (ob, 0),
    2469                 :             :                            flags | TFF_EXPR_IN_PARENS);
    2470                 :         265 :                 pp_cxx_dot (pp);
    2471                 :             :               }
    2472                 :         149 :             else if (!is_this_parameter (ob))
    2473                 :             :               {
    2474                 :         149 :                 dump_expr (pp, ob, flags | TFF_EXPR_IN_PARENS);
    2475                 :         149 :                 pp_cxx_arrow (pp);
    2476                 :             :               }
    2477                 :             :             skipfirst = true;
    2478                 :             :           }
    2479                 :        2815 :         if (flag_sanitize & SANITIZE_UNDEFINED
    2480                 :        2815 :             && is_ubsan_builtin_p (fn))
    2481                 :             :           {
    2482                 :           0 :             pp_string (cxx_pp, M_("<ubsan routine call>"));
    2483                 :           0 :             break;
    2484                 :             :           }
    2485                 :             : 
    2486                 :        2815 :         if (TREE_CODE (fn) == FUNCTION_DECL
    2487                 :        2030 :             && DECL_CONSTRUCTOR_P (fn)
    2488                 :        3043 :             && is_dummy_object (get_nth_callarg (t, 0)))
    2489                 :         101 :           dump_type (pp, DECL_CONTEXT (fn), flags);
    2490                 :             :         else
    2491                 :        2714 :           dump_expr (pp, fn, flags | TFF_EXPR_IN_PARENS);
    2492                 :        2815 :         dump_call_expr_args (pp, t, flags, skipfirst);
    2493                 :             :       }
    2494                 :        2815 :       break;
    2495                 :             : 
    2496                 :         860 :     case TARGET_EXPR:
    2497                 :             :       /* Note that this only works for G++ target exprs.  If somebody
    2498                 :             :          builds a general TARGET_EXPR, there's no way to represent that
    2499                 :             :          it initializes anything other that the parameter slot for the
    2500                 :             :          default argument.  Note we may have cleared out the first
    2501                 :             :          operand in expand_expr, so don't go killing ourselves.  */
    2502                 :         860 :       if (TARGET_EXPR_INITIAL (t))
    2503                 :         860 :         dump_expr (pp, TARGET_EXPR_INITIAL (t), flags | TFF_EXPR_IN_PARENS);
    2504                 :             :       break;
    2505                 :             : 
    2506                 :         281 :     case POINTER_PLUS_EXPR:
    2507                 :         281 :       dump_binary_op (pp, "+", t, flags);
    2508                 :         281 :       break;
    2509                 :             : 
    2510                 :           2 :     case POINTER_DIFF_EXPR:
    2511                 :           2 :       dump_binary_op (pp, "-", t, flags);
    2512                 :           2 :       break;
    2513                 :             : 
    2514                 :          22 :     case INIT_EXPR:
    2515                 :          22 :     case MODIFY_EXPR:
    2516                 :          22 :       dump_binary_op (pp, OVL_OP_INFO (true, NOP_EXPR)->name, t, flags);
    2517                 :          22 :       break;
    2518                 :             : 
    2519                 :        1620 :     case PLUS_EXPR:
    2520                 :        1620 :     case MINUS_EXPR:
    2521                 :        1620 :     case MULT_EXPR:
    2522                 :        1620 :     case TRUNC_DIV_EXPR:
    2523                 :        1620 :     case TRUNC_MOD_EXPR:
    2524                 :        1620 :     case MIN_EXPR:
    2525                 :        1620 :     case MAX_EXPR:
    2526                 :        1620 :     case LSHIFT_EXPR:
    2527                 :        1620 :     case RSHIFT_EXPR:
    2528                 :        1620 :     case BIT_IOR_EXPR:
    2529                 :        1620 :     case BIT_XOR_EXPR:
    2530                 :        1620 :     case BIT_AND_EXPR:
    2531                 :        1620 :     case TRUTH_ANDIF_EXPR:
    2532                 :        1620 :     case TRUTH_ORIF_EXPR:
    2533                 :        1620 :     case LT_EXPR:
    2534                 :        1620 :     case LE_EXPR:
    2535                 :        1620 :     case GT_EXPR:
    2536                 :        1620 :     case GE_EXPR:
    2537                 :        1620 :     case EQ_EXPR:
    2538                 :        1620 :     case NE_EXPR:
    2539                 :        1620 :     case SPACESHIP_EXPR:
    2540                 :        1620 :     case EXACT_DIV_EXPR:
    2541                 :        1620 :       dump_binary_op (pp, OVL_OP_INFO (false, TREE_CODE (t))->name, t, flags);
    2542                 :        1620 :       break;
    2543                 :             : 
    2544                 :           7 :     case CEIL_DIV_EXPR:
    2545                 :           7 :     case FLOOR_DIV_EXPR:
    2546                 :           7 :     case ROUND_DIV_EXPR:
    2547                 :           7 :     case RDIV_EXPR:
    2548                 :           7 :       dump_binary_op (pp, "/", t, flags);
    2549                 :           7 :       break;
    2550                 :             : 
    2551                 :           0 :     case CEIL_MOD_EXPR:
    2552                 :           0 :     case FLOOR_MOD_EXPR:
    2553                 :           0 :     case ROUND_MOD_EXPR:
    2554                 :           0 :       dump_binary_op (pp, "%", t, flags);
    2555                 :           0 :       break;
    2556                 :             : 
    2557                 :        1060 :     case COMPONENT_REF:
    2558                 :        1060 :       {
    2559                 :        1060 :         tree ob = TREE_OPERAND (t, 0);
    2560                 :        1060 :         if (INDIRECT_REF_P (ob))
    2561                 :             :           {
    2562                 :         450 :             ob = TREE_OPERAND (ob, 0);
    2563                 :         450 :             if (!is_this_parameter (ob)
    2564                 :         450 :                 && !is_dummy_object (ob))
    2565                 :             :               {
    2566                 :         426 :                 dump_expr (pp, ob, flags | TFF_EXPR_IN_PARENS);
    2567                 :         426 :                 if (TYPE_REF_P (TREE_TYPE (ob)))
    2568                 :         173 :                   pp_cxx_dot (pp);
    2569                 :             :                 else
    2570                 :         253 :                   pp_cxx_arrow (pp);
    2571                 :             :               }
    2572                 :             :           }
    2573                 :             :         else
    2574                 :             :           {
    2575                 :         610 :             dump_expr (pp, ob, flags | TFF_EXPR_IN_PARENS);
    2576                 :         610 :             if (TREE_CODE (ob) != ARROW_EXPR)
    2577                 :         607 :               pp_cxx_dot (pp);
    2578                 :             :           }
    2579                 :        1060 :         dump_expr (pp, TREE_OPERAND (t, 1), flags & ~TFF_EXPR_IN_PARENS);
    2580                 :             :       }
    2581                 :        1060 :       break;
    2582                 :             : 
    2583                 :         253 :     case ARRAY_REF:
    2584                 :         253 :       dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
    2585                 :         253 :       pp_cxx_left_bracket (pp);
    2586                 :         253 :       dump_expr (pp, TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
    2587                 :         253 :       pp_cxx_right_bracket (pp);
    2588                 :         253 :       break;
    2589                 :             : 
    2590                 :          30 :     case OMP_ARRAY_SECTION:
    2591                 :          30 :       dump_expr (pp, TREE_OPERAND (t, 0), flags);
    2592                 :          30 :       pp_cxx_left_bracket (pp);
    2593                 :          30 :       dump_expr (pp, TREE_OPERAND (t, 1), flags);
    2594                 :          30 :       pp_colon (pp);
    2595                 :          30 :       dump_expr (pp, TREE_OPERAND (t, 2), flags);
    2596                 :          30 :       pp_cxx_right_bracket (pp);
    2597                 :          30 :       break;
    2598                 :             : 
    2599                 :           0 :     case UNARY_PLUS_EXPR:
    2600                 :           0 :       dump_unary_op (pp, "+", t, flags);
    2601                 :           0 :       break;
    2602                 :             : 
    2603                 :        1255 :     case ADDR_EXPR:
    2604                 :        1255 :       if (TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL
    2605                 :         942 :           || TREE_CODE (TREE_OPERAND (t, 0)) == STRING_CST
    2606                 :             :           /* An ADDR_EXPR can have reference type.  In that case, we
    2607                 :             :              shouldn't print the `&' doing so indicates to the user
    2608                 :             :              that the expression has pointer type.  */
    2609                 :        2146 :           || (TREE_TYPE (t)
    2610                 :         891 :               && TYPE_REF_P (TREE_TYPE (t))))
    2611                 :         367 :         dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
    2612                 :         888 :       else if (TREE_CODE (TREE_OPERAND (t, 0)) == LABEL_DECL)
    2613                 :           3 :         dump_unary_op (pp, "&&", t, flags);
    2614                 :             :       else
    2615                 :         885 :         dump_unary_op (pp, "&", t, flags);
    2616                 :             :       break;
    2617                 :             : 
    2618                 :         653 :     case INDIRECT_REF:
    2619                 :         653 :       if (TREE_HAS_CONSTRUCTOR (t))
    2620                 :             :         {
    2621                 :           0 :           t = TREE_OPERAND (t, 0);
    2622                 :           0 :           gcc_assert (TREE_CODE (t) == CALL_EXPR);
    2623                 :           0 :           dump_expr (pp, CALL_EXPR_FN (t), flags | TFF_EXPR_IN_PARENS);
    2624                 :           0 :           dump_call_expr_args (pp, t, flags, true);
    2625                 :             :         }
    2626                 :         653 :       else if (is_stub_object (t))
    2627                 :             :         {
    2628                 :           0 :           pp_string (pp, "std::declval<");
    2629                 :           0 :           if (lvalue_p (t)) /* T& */
    2630                 :           0 :             dump_type (pp, TREE_TYPE (STRIP_REFERENCE_REF (t)), flags);
    2631                 :             :           else /* T */
    2632                 :           0 :             dump_type (pp, TREE_TYPE (t), flags);
    2633                 :           0 :           pp_string (pp, ">()");
    2634                 :             :         }
    2635                 :             :       else
    2636                 :             :         {
    2637                 :         653 :           if (TREE_OPERAND (t,0) != NULL_TREE
    2638                 :         653 :               && TREE_TYPE (TREE_OPERAND (t, 0))
    2639                 :        1298 :               && NEXT_CODE (TREE_OPERAND (t, 0)) == REFERENCE_TYPE)
    2640                 :         408 :             dump_expr (pp, TREE_OPERAND (t, 0), flags);
    2641                 :             :           else
    2642                 :         245 :             dump_unary_op (pp, "*", t, flags);
    2643                 :             :         }
    2644                 :             :       break;
    2645                 :             : 
    2646                 :         585 :     case MEM_REF:
    2647                 :             :       /* Delegate to the base "C" pretty printer.  */
    2648                 :         585 :       pp->c_pretty_printer::unary_expression (t);
    2649                 :         585 :       break;
    2650                 :             : 
    2651                 :           0 :     case TARGET_MEM_REF:
    2652                 :             :       /* TARGET_MEM_REF can't appear directly from source, but can appear
    2653                 :             :          during late GIMPLE optimizations and through late diagnostic we might
    2654                 :             :          need to support it.  Print it as dereferencing of a pointer after
    2655                 :             :          cast to the TARGET_MEM_REF type, with pointer arithmetics on some
    2656                 :             :          pointer to single byte types, so
    2657                 :             :          *(type *)((char *) ptr + step * index + index2) if all the operands
    2658                 :             :          are present and the casts are needed.  */
    2659                 :           0 :       pp_cxx_star (pp);
    2660                 :           0 :       pp_cxx_left_paren (pp);
    2661                 :           0 :       if (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (TMR_BASE (t)))) == NULL_TREE
    2662                 :           0 :           || !integer_onep (TYPE_SIZE_UNIT
    2663                 :             :                                 (TREE_TYPE (TREE_TYPE (TMR_BASE (t))))))
    2664                 :             :         {
    2665                 :           0 :           if (TYPE_SIZE_UNIT (TREE_TYPE (t))
    2666                 :           0 :               && integer_onep (TYPE_SIZE_UNIT (TREE_TYPE (t))))
    2667                 :             :             {
    2668                 :           0 :               pp_cxx_left_paren (pp);
    2669                 :           0 :               dump_type (pp, build_pointer_type (TREE_TYPE (t)), flags);
    2670                 :             :             }
    2671                 :             :           else
    2672                 :             :             {
    2673                 :           0 :               dump_type (pp, build_pointer_type (TREE_TYPE (t)), flags);
    2674                 :           0 :               pp_cxx_right_paren (pp);
    2675                 :           0 :               pp_cxx_left_paren (pp);
    2676                 :           0 :               pp_cxx_left_paren (pp);
    2677                 :           0 :               dump_type (pp, build_pointer_type (char_type_node), flags);
    2678                 :             :             }
    2679                 :           0 :           pp_cxx_right_paren (pp);
    2680                 :             :         }
    2681                 :           0 :       else if (!same_type_p (TREE_TYPE (t),
    2682                 :             :                              TREE_TYPE (TREE_TYPE (TMR_BASE (t)))))
    2683                 :             :         {
    2684                 :           0 :           dump_type (pp, build_pointer_type (TREE_TYPE (t)), flags);
    2685                 :           0 :           pp_cxx_right_paren (pp);
    2686                 :           0 :           pp_cxx_left_paren (pp);
    2687                 :             :         }
    2688                 :           0 :       dump_expr (pp, TMR_BASE (t), flags);
    2689                 :           0 :       if (TMR_STEP (t) && TMR_INDEX (t))
    2690                 :             :         {
    2691                 :           0 :           pp_cxx_ws_string (pp, "+");
    2692                 :           0 :           dump_expr (pp, TMR_INDEX (t), flags);
    2693                 :           0 :           pp_cxx_ws_string (pp, "*");
    2694                 :           0 :           dump_expr (pp, TMR_STEP (t), flags);
    2695                 :             :         }
    2696                 :           0 :       if (TMR_INDEX2 (t))
    2697                 :             :         {
    2698                 :           0 :           pp_cxx_ws_string (pp, "+");
    2699                 :           0 :           dump_expr (pp, TMR_INDEX2 (t), flags);
    2700                 :             :         }
    2701                 :           0 :       if (!integer_zerop (TMR_OFFSET (t)))
    2702                 :             :         {
    2703                 :           0 :           pp_cxx_ws_string (pp, "+");
    2704                 :           0 :           dump_expr (pp, fold_convert (ssizetype, TMR_OFFSET (t)), flags);
    2705                 :             :         }
    2706                 :           0 :       pp_cxx_right_paren (pp);
    2707                 :           0 :       break;
    2708                 :             : 
    2709                 :         222 :     case NEGATE_EXPR:
    2710                 :         222 :     case BIT_NOT_EXPR:
    2711                 :         222 :     case TRUTH_NOT_EXPR:
    2712                 :         222 :     case PREDECREMENT_EXPR:
    2713                 :         222 :     case PREINCREMENT_EXPR:
    2714                 :         222 :       dump_unary_op (pp, OVL_OP_INFO (false, TREE_CODE (t))->name, t, flags);
    2715                 :         222 :       break;
    2716                 :             : 
    2717                 :           0 :     case POSTDECREMENT_EXPR:
    2718                 :           0 :     case POSTINCREMENT_EXPR:
    2719                 :           0 :       pp_cxx_left_paren (pp);
    2720                 :           0 :       dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
    2721                 :           0 :       pp_cxx_ws_string (pp, OVL_OP_INFO (false, TREE_CODE (t))->name);
    2722                 :           0 :       pp_cxx_right_paren (pp);
    2723                 :           0 :       break;
    2724                 :             : 
    2725                 :        1187 :     case NON_LVALUE_EXPR:
    2726                 :             :       /* FIXME: This is a KLUDGE workaround for a parsing problem.  There
    2727                 :             :          should be another level of INDIRECT_REF so that I don't have to do
    2728                 :             :          this.  */
    2729                 :        1187 :       if (TREE_TYPE (t) != NULL_TREE && NEXT_CODE (t) == POINTER_TYPE)
    2730                 :             :         {
    2731                 :          23 :           tree next = TREE_TYPE (TREE_TYPE (t));
    2732                 :             : 
    2733                 :          23 :           while (TYPE_PTR_P (next))
    2734                 :           0 :             next = TREE_TYPE (next);
    2735                 :             : 
    2736                 :          23 :           if (TREE_CODE (next) == FUNCTION_TYPE)
    2737                 :             :             {
    2738                 :           0 :               if (flags & TFF_EXPR_IN_PARENS)
    2739                 :           0 :                 pp_cxx_left_paren (pp);
    2740                 :           0 :               pp_cxx_star (pp);
    2741                 :           0 :               dump_expr (pp, TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
    2742                 :           0 :               if (flags & TFF_EXPR_IN_PARENS)
    2743                 :           0 :                 pp_cxx_right_paren (pp);
    2744                 :             :               break;
    2745                 :             :             }
    2746                 :             :           /* Else fall through.  */
    2747                 :             :         }
    2748                 :        1187 :       dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
    2749                 :        1187 :       break;
    2750                 :             : 
    2751                 :        5466 :     CASE_CONVERT:
    2752                 :        5466 :     case IMPLICIT_CONV_EXPR:
    2753                 :        5466 :     case VIEW_CONVERT_EXPR:
    2754                 :        5466 :     case EXCESS_PRECISION_EXPR:
    2755                 :        5466 :       {
    2756                 :        5466 :         tree op = TREE_OPERAND (t, 0);
    2757                 :             : 
    2758                 :        5466 :         if (location_wrapper_p (t))
    2759                 :             :           {
    2760                 :             :             dump_expr (pp, op, flags);
    2761                 :             :             break;
    2762                 :             :           }
    2763                 :             : 
    2764                 :        1847 :         tree ttype = TREE_TYPE (t);
    2765                 :        1847 :         tree optype = TREE_TYPE (op);
    2766                 :        1847 :         if (!optype)
    2767                 :         105 :           optype = unknown_type_node;
    2768                 :             : 
    2769                 :        1847 :         if (TREE_CODE (ttype) != TREE_CODE (optype)
    2770                 :         691 :             && INDIRECT_TYPE_P (ttype)
    2771                 :         379 :             && INDIRECT_TYPE_P (optype)
    2772                 :        2145 :             && same_type_p (TREE_TYPE (optype),
    2773                 :             :                             TREE_TYPE (ttype)))
    2774                 :             :           {
    2775                 :         254 :             if (TYPE_REF_P (ttype))
    2776                 :             :               {
    2777                 :         218 :                 STRIP_NOPS (op);
    2778                 :         218 :                 if (TREE_CODE (op) == ADDR_EXPR)
    2779                 :         209 :                   dump_expr (pp, TREE_OPERAND (op, 0), flags);
    2780                 :             :                 else
    2781                 :           9 :                   dump_unary_op (pp, "*", t, flags);
    2782                 :             :               }
    2783                 :             :             else
    2784                 :          36 :               dump_unary_op (pp, "&", t, flags);
    2785                 :             :           }
    2786                 :        1593 :         else if (!same_type_p (optype, ttype))
    2787                 :             :           {
    2788                 :             :             /* It is a cast, but we cannot tell whether it is a
    2789                 :             :                reinterpret or static cast. Use the C style notation.  */
    2790                 :        1478 :             if (flags & TFF_EXPR_IN_PARENS)
    2791                 :         908 :               pp_cxx_left_paren (pp);
    2792                 :        1478 :             pp_cxx_left_paren (pp);
    2793                 :        1478 :             dump_type (pp, TREE_TYPE (t), flags);
    2794                 :        1478 :             pp_cxx_right_paren (pp);
    2795                 :        1478 :             dump_expr (pp, op, flags | TFF_EXPR_IN_PARENS);
    2796                 :        1478 :             if (flags & TFF_EXPR_IN_PARENS)
    2797                 :         908 :               pp_cxx_right_paren (pp);
    2798                 :             :           }
    2799                 :             :         else
    2800                 :             :           dump_expr (pp, op, flags);
    2801                 :             :         break;
    2802                 :             :       }
    2803                 :             : 
    2804                 :        1030 :     case CONSTRUCTOR:
    2805                 :        1030 :       if (TREE_TYPE (t) && TYPE_PTRMEMFUNC_P (TREE_TYPE (t)))
    2806                 :             :         {
    2807                 :           6 :           tree idx = build_ptrmemfunc_access_expr (t, pfn_identifier);
    2808                 :             : 
    2809                 :           6 :           if (integer_zerop (idx))
    2810                 :             :             {
    2811                 :             :               /* A NULL pointer-to-member constant.  */
    2812                 :           2 :               pp_cxx_left_paren (pp);
    2813                 :           2 :               pp_cxx_left_paren (pp);
    2814                 :           2 :               dump_type (pp, TREE_TYPE (t), flags);
    2815                 :           2 :               pp_cxx_right_paren (pp);
    2816                 :           2 :               pp_character (pp, '0');
    2817                 :           2 :               pp_cxx_right_paren (pp);
    2818                 :           2 :               break;
    2819                 :             :             }
    2820                 :           4 :           else if (tree_fits_shwi_p (idx))
    2821                 :             :             {
    2822                 :           4 :               tree virtuals;
    2823                 :           4 :               unsigned HOST_WIDE_INT n;
    2824                 :             : 
    2825                 :           4 :               t = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (t)));
    2826                 :           4 :               t = TYPE_METHOD_BASETYPE (t);
    2827                 :           4 :               virtuals = BINFO_VIRTUALS (TYPE_BINFO (TYPE_MAIN_VARIANT (t)));
    2828                 :             : 
    2829                 :           4 :               n = tree_to_shwi (idx);
    2830                 :             : 
    2831                 :             :               /* Map vtable index back one, to allow for the null pointer to
    2832                 :             :                  member.  */
    2833                 :           4 :               --n;
    2834                 :             : 
    2835                 :           4 :               while (n > 0 && virtuals)
    2836                 :             :                 {
    2837                 :           0 :                   --n;
    2838                 :           0 :                   virtuals = TREE_CHAIN (virtuals);
    2839                 :             :                 }
    2840                 :           4 :               if (virtuals)
    2841                 :             :                 {
    2842                 :           4 :                   dump_expr (pp, BV_FN (virtuals),
    2843                 :             :                              flags | TFF_EXPR_IN_PARENS);
    2844                 :           4 :                   break;
    2845                 :             :                 }
    2846                 :             :             }
    2847                 :             :         }
    2848                 :        1885 :       if (TREE_TYPE (t) && LAMBDA_TYPE_P (TREE_TYPE (t)))
    2849                 :          15 :         pp_string (pp, "<lambda closure object>");
    2850                 :        1024 :       if (TREE_TYPE (t) && EMPTY_CONSTRUCTOR_P (t))
    2851                 :             :         {
    2852                 :         744 :           dump_type (pp, TREE_TYPE (t), 0);
    2853                 :         744 :           pp_cxx_left_paren (pp);
    2854                 :         744 :           pp_cxx_right_paren (pp);
    2855                 :             :         }
    2856                 :             :       else
    2857                 :             :         {
    2858                 :         280 :           if (!BRACE_ENCLOSED_INITIALIZER_P (t))
    2859                 :         225 :             dump_type (pp, TREE_TYPE (t), 0);
    2860                 :         280 :           pp_cxx_left_brace (pp);
    2861                 :         280 :           dump_expr_init_vec (pp, CONSTRUCTOR_ELTS (t), flags);
    2862                 :         280 :           pp_cxx_right_brace (pp);
    2863                 :             :         }
    2864                 :             : 
    2865                 :             :       break;
    2866                 :             : 
    2867                 :          28 :     case OFFSET_REF:
    2868                 :          28 :       {
    2869                 :          28 :         tree ob = TREE_OPERAND (t, 0);
    2870                 :          28 :         if (is_dummy_object (ob))
    2871                 :             :           {
    2872                 :          25 :             t = TREE_OPERAND (t, 1);
    2873                 :          25 :             if (TREE_CODE (t) == FUNCTION_DECL)
    2874                 :             :               /* A::f */
    2875                 :           0 :               dump_expr (pp, t, flags | TFF_EXPR_IN_PARENS);
    2876                 :          25 :             else if (BASELINK_P (t))
    2877                 :    12330998 :               dump_expr (pp, OVL_FIRST (BASELINK_FUNCTIONS (t)),
    2878                 :             :                          flags | TFF_EXPR_IN_PARENS);
    2879                 :             :             else
    2880                 :           3 :               dump_decl (pp, t, flags);
    2881                 :             :           }
    2882                 :             :         else
    2883                 :             :           {
    2884                 :           3 :             if (INDIRECT_REF_P (ob))
    2885                 :             :               {
    2886                 :           3 :                 dump_expr (pp, TREE_OPERAND (ob, 0), flags | TFF_EXPR_IN_PARENS);
    2887                 :           3 :                 pp_cxx_arrow (pp);
    2888                 :           3 :                 pp_cxx_star (pp);
    2889                 :             :               }
    2890                 :             :             else
    2891                 :             :               {
    2892                 :           0 :                 dump_expr (pp, ob, flags | TFF_EXPR_IN_PARENS);
    2893                 :           0 :                 pp_cxx_dot (pp);
    2894                 :           0 :                 pp_cxx_star (pp);
    2895                 :             :               }
    2896                 :           3 :             dump_expr (pp, TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
    2897                 :             :           }
    2898                 :             :         break;
    2899                 :             :       }
    2900                 :             : 
    2901                 :        2072 :     case TEMPLATE_PARM_INDEX:
    2902                 :        2072 :       dump_decl (pp, TEMPLATE_PARM_DECL (t), flags & ~TFF_DECL_SPECIFIERS);
    2903                 :        2072 :       break;
    2904                 :             : 
    2905                 :         179 :     case CAST_EXPR:
    2906                 :         179 :       if (TREE_OPERAND (t, 0) == NULL_TREE
    2907                 :         179 :           || TREE_CHAIN (TREE_OPERAND (t, 0)))
    2908                 :             :         {
    2909                 :         120 :           dump_type (pp, TREE_TYPE (t), flags);
    2910                 :         120 :           pp_cxx_left_paren (pp);
    2911                 :         120 :           dump_expr_list (pp, TREE_OPERAND (t, 0), flags);
    2912                 :         120 :           pp_cxx_right_paren (pp);
    2913                 :             :         }
    2914                 :             :       else
    2915                 :             :         {
    2916                 :          59 :           pp_cxx_left_paren (pp);
    2917                 :          59 :           dump_type (pp, TREE_TYPE (t), flags);
    2918                 :          59 :           pp_cxx_right_paren (pp);
    2919                 :          59 :           pp_cxx_left_paren (pp);
    2920                 :          59 :           dump_expr_list (pp, TREE_OPERAND (t, 0), flags);
    2921                 :          59 :           pp_cxx_right_paren (pp);
    2922                 :             :         }
    2923                 :             :       break;
    2924                 :             : 
    2925                 :          31 :     case STATIC_CAST_EXPR:
    2926                 :          31 :       pp_cxx_ws_string (pp, "static_cast");
    2927                 :          31 :       goto cast;
    2928                 :           0 :     case REINTERPRET_CAST_EXPR:
    2929                 :           0 :       pp_cxx_ws_string (pp, "reinterpret_cast");
    2930                 :           0 :       goto cast;
    2931                 :           3 :     case CONST_CAST_EXPR:
    2932                 :           3 :       pp_cxx_ws_string (pp, "const_cast");
    2933                 :           3 :       goto cast;
    2934                 :           0 :     case DYNAMIC_CAST_EXPR:
    2935                 :           0 :       pp_cxx_ws_string (pp, "dynamic_cast");
    2936                 :          34 :     cast:
    2937                 :          34 :       pp_cxx_begin_template_argument_list (pp);
    2938                 :          34 :       dump_type (pp, TREE_TYPE (t), flags);
    2939                 :          34 :       pp_cxx_end_template_argument_list (pp);
    2940                 :          34 :       pp_cxx_left_paren (pp);
    2941                 :          34 :       dump_expr (pp, TREE_OPERAND (t, 0), flags);
    2942                 :          34 :       pp_cxx_right_paren (pp);
    2943                 :          34 :       break;
    2944                 :             : 
    2945                 :           3 :     case ARROW_EXPR:
    2946                 :           3 :       dump_expr (pp, TREE_OPERAND (t, 0), flags);
    2947                 :           3 :       pp_cxx_arrow (pp);
    2948                 :           3 :       break;
    2949                 :             : 
    2950                 :         198 :     case SIZEOF_EXPR:
    2951                 :         198 :     case ALIGNOF_EXPR:
    2952                 :         198 :       if (TREE_CODE (t) == SIZEOF_EXPR)
    2953                 :         180 :         pp_cxx_ws_string (pp, "sizeof");
    2954                 :          18 :       else if (ALIGNOF_EXPR_STD_P (t))
    2955                 :          12 :         pp_cxx_ws_string (pp, "alignof");
    2956                 :             :       else
    2957                 :           6 :         pp_cxx_ws_string (pp, "__alignof__");
    2958                 :         198 :       op = TREE_OPERAND (t, 0);
    2959                 :         198 :       if (PACK_EXPANSION_P (op))
    2960                 :             :         {
    2961                 :          84 :           pp_string (pp, "...");
    2962                 :          84 :           op = PACK_EXPANSION_PATTERN (op);
    2963                 :             :         }
    2964                 :         198 :       pp_cxx_whitespace (pp);
    2965                 :         198 :       pp_cxx_left_paren (pp);
    2966                 :         198 :       if (TREE_CODE (t) == SIZEOF_EXPR && SIZEOF_EXPR_TYPE_P (t))
    2967                 :          29 :         dump_type (pp, TREE_TYPE (op), flags);
    2968                 :         169 :       else if (TYPE_P (TREE_OPERAND (t, 0)))
    2969                 :         106 :         dump_type (pp, op, flags);
    2970                 :             :       else
    2971                 :          63 :         dump_expr (pp, op, flags);
    2972                 :         198 :       pp_cxx_right_paren (pp);
    2973                 :         198 :       break;
    2974                 :             : 
    2975                 :           0 :     case AT_ENCODE_EXPR:
    2976                 :           0 :       pp_cxx_ws_string (pp, "@encode");
    2977                 :           0 :       pp_cxx_whitespace (pp);
    2978                 :           0 :       pp_cxx_left_paren (pp);
    2979                 :           0 :       dump_type (pp, TREE_OPERAND (t, 0), flags);
    2980                 :           0 :       pp_cxx_right_paren (pp);
    2981                 :           0 :       break;
    2982                 :             : 
    2983                 :          12 :     case NOEXCEPT_EXPR:
    2984                 :          12 :       pp_cxx_ws_string (pp, "noexcept");
    2985                 :          12 :       pp_cxx_whitespace (pp);
    2986                 :          12 :       pp_cxx_left_paren (pp);
    2987                 :          12 :       dump_expr (pp, TREE_OPERAND (t, 0), flags);
    2988                 :          12 :       pp_cxx_right_paren (pp);
    2989                 :          12 :       break;
    2990                 :             : 
    2991                 :           0 :     case REALPART_EXPR:
    2992                 :           0 :     case IMAGPART_EXPR:
    2993                 :           0 :       pp_cxx_ws_string (pp, OVL_OP_INFO (false, TREE_CODE (t))->name);
    2994                 :           0 :       pp_cxx_whitespace (pp);
    2995                 :           0 :       dump_expr (pp, TREE_OPERAND (t, 0), flags);
    2996                 :           0 :       break;
    2997                 :             : 
    2998                 :           0 :     case DEFERRED_PARSE:
    2999                 :           0 :       pp_string (pp, M_("<unparsed>"));
    3000                 :           0 :       break;
    3001                 :             : 
    3002                 :           0 :     case TRY_CATCH_EXPR:
    3003                 :           0 :     case CLEANUP_POINT_EXPR:
    3004                 :           0 :       dump_expr (pp, TREE_OPERAND (t, 0), flags);
    3005                 :           0 :       break;
    3006                 :             : 
    3007                 :           0 :     case PSEUDO_DTOR_EXPR:
    3008                 :           0 :       dump_expr (pp, TREE_OPERAND (t, 0), flags);
    3009                 :           0 :       pp_cxx_dot (pp);
    3010                 :           0 :       if (TREE_OPERAND (t, 1))
    3011                 :             :         {
    3012                 :           0 :           dump_type (pp, TREE_OPERAND (t, 1), flags);
    3013                 :           0 :           pp_cxx_colon_colon (pp);
    3014                 :             :         }
    3015                 :           0 :       pp_cxx_complement (pp);
    3016                 :           0 :       dump_type (pp, TREE_OPERAND (t, 2), flags);
    3017                 :           0 :       break;
    3018                 :             : 
    3019                 :        1406 :     case TEMPLATE_ID_EXPR:
    3020                 :        1406 :       dump_decl (pp, t, flags);
    3021                 :        1406 :       break;
    3022                 :             : 
    3023                 :          28 :     case BIND_EXPR:
    3024                 :          28 :     case STMT_EXPR:
    3025                 :          28 :     case EXPR_STMT:
    3026                 :          28 :     case STATEMENT_LIST:
    3027                 :             :       /* We don't yet have a way of dumping statements in a
    3028                 :             :          human-readable format.  */
    3029                 :          28 :       pp_string (pp, "({...})");
    3030                 :          28 :       break;
    3031                 :             : 
    3032                 :           0 :     case LOOP_EXPR:
    3033                 :           0 :       pp_string (pp, "while (1) { ");
    3034                 :           0 :       dump_expr (pp, TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
    3035                 :           0 :       pp_cxx_right_brace (pp);
    3036                 :           0 :       break;
    3037                 :             : 
    3038                 :           0 :     case EXIT_EXPR:
    3039                 :           0 :       pp_string (pp, "if (");
    3040                 :           0 :       dump_expr (pp, TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
    3041                 :           0 :       pp_string (pp, ") break; ");
    3042                 :           0 :       break;
    3043                 :             : 
    3044                 :         135 :     case BASELINK:
    3045                 :         135 :       dump_expr (pp, BASELINK_FUNCTIONS (t), flags & ~TFF_EXPR_IN_PARENS);
    3046                 :         135 :       break;
    3047                 :             : 
    3048                 :          48 :     case EMPTY_CLASS_EXPR:
    3049                 :          48 :       dump_type (pp, TREE_TYPE (t), flags);
    3050                 :          48 :       pp_cxx_left_paren (pp);
    3051                 :          48 :       pp_cxx_right_paren (pp);
    3052                 :          48 :       break;
    3053                 :             : 
    3054                 :           0 :     case ARGUMENT_PACK_SELECT:
    3055                 :           0 :       dump_template_argument (pp, ARGUMENT_PACK_SELECT_FROM_PACK (t), flags);
    3056                 :           0 :       break;
    3057                 :             : 
    3058                 :          68 :     case RECORD_TYPE:
    3059                 :          68 :     case UNION_TYPE:
    3060                 :          68 :     case ENUMERAL_TYPE:
    3061                 :          68 :     case REAL_TYPE:
    3062                 :          68 :     case VOID_TYPE:
    3063                 :          68 :     case OPAQUE_TYPE:
    3064                 :          68 :     case BOOLEAN_TYPE:
    3065                 :          68 :     case INTEGER_TYPE:
    3066                 :          68 :     case COMPLEX_TYPE:
    3067                 :          68 :     case VECTOR_TYPE:
    3068                 :          68 :     case DECLTYPE_TYPE:
    3069                 :          68 :       pp_type_specifier_seq (pp, t);
    3070                 :          68 :       break;
    3071                 :             : 
    3072                 :           0 :     case TYPENAME_TYPE:
    3073                 :             :       /* We get here when we want to print a dependent type as an
    3074                 :             :          id-expression, without any disambiguator decoration.  */
    3075                 :           0 :       pp->id_expression (t);
    3076                 :           0 :       break;
    3077                 :             : 
    3078                 :          33 :     case TEMPLATE_TYPE_PARM:
    3079                 :          33 :     case TEMPLATE_TEMPLATE_PARM:
    3080                 :          33 :     case BOUND_TEMPLATE_TEMPLATE_PARM:
    3081                 :          33 :       dump_type (pp, t, flags);
    3082                 :          33 :       break;
    3083                 :             : 
    3084                 :          59 :     case TRAIT_EXPR:
    3085                 :          59 :       pp_cxx_trait (pp, t);
    3086                 :          59 :       break;
    3087                 :             : 
    3088                 :           3 :     case VA_ARG_EXPR:
    3089                 :           3 :       pp_cxx_va_arg_expression (pp, t);
    3090                 :           3 :       break;
    3091                 :             : 
    3092                 :          15 :     case OFFSETOF_EXPR:
    3093                 :          15 :       pp_cxx_offsetof_expression (pp, t);
    3094                 :          15 :       break;
    3095                 :             : 
    3096                 :           0 :     case ADDRESSOF_EXPR:
    3097                 :           0 :       pp_cxx_addressof_expression (pp, t);
    3098                 :           0 :       break;
    3099                 :             : 
    3100                 :        1033 :     case SCOPE_REF:
    3101                 :        1033 :       dump_decl (pp, t, flags);
    3102                 :        1033 :       break;
    3103                 :             : 
    3104                 :        2347 :     case EXPR_PACK_EXPANSION:
    3105                 :        2347 :     case UNARY_LEFT_FOLD_EXPR:
    3106                 :        2347 :     case UNARY_RIGHT_FOLD_EXPR:
    3107                 :        2347 :     case BINARY_LEFT_FOLD_EXPR:
    3108                 :        2347 :     case BINARY_RIGHT_FOLD_EXPR:
    3109                 :        2347 :     case TYPEID_EXPR:
    3110                 :        2347 :     case MEMBER_REF:
    3111                 :        2347 :     case DOTSTAR_EXPR:
    3112                 :        2347 :     case NEW_EXPR:
    3113                 :        2347 :     case VEC_NEW_EXPR:
    3114                 :        2347 :     case DELETE_EXPR:
    3115                 :        2347 :     case VEC_DELETE_EXPR:
    3116                 :        2347 :     case MODOP_EXPR:
    3117                 :        2347 :     case ABS_EXPR:
    3118                 :        2347 :     case ABSU_EXPR:
    3119                 :        2347 :     case CONJ_EXPR:
    3120                 :        2347 :     case VECTOR_CST:
    3121                 :        2347 :     case FIXED_CST:
    3122                 :        2347 :     case UNORDERED_EXPR:
    3123                 :        2347 :     case ORDERED_EXPR:
    3124                 :        2347 :     case UNLT_EXPR:
    3125                 :        2347 :     case UNLE_EXPR:
    3126                 :        2347 :     case UNGT_EXPR:
    3127                 :        2347 :     case UNGE_EXPR:
    3128                 :        2347 :     case UNEQ_EXPR:
    3129                 :        2347 :     case LTGT_EXPR:
    3130                 :        2347 :     case COMPLEX_EXPR:
    3131                 :        2347 :     case BIT_FIELD_REF:
    3132                 :        2347 :     case FIX_TRUNC_EXPR:
    3133                 :        2347 :     case FLOAT_EXPR:
    3134                 :        2347 :       pp->expression (t);
    3135                 :        2347 :       break;
    3136                 :             : 
    3137                 :           2 :     case PACK_INDEX_EXPR:
    3138                 :           2 :       pp->expression (PACK_INDEX_PACK (t));
    3139                 :           2 :       pp_cxx_left_bracket (pp);
    3140                 :           2 :       pp->expression (PACK_INDEX_INDEX (t));
    3141                 :           2 :       pp_cxx_right_bracket (pp);
    3142                 :           2 :       break;
    3143                 :             : 
    3144                 :           0 :     case TRUTH_AND_EXPR:
    3145                 :           0 :     case TRUTH_OR_EXPR:
    3146                 :           0 :     case TRUTH_XOR_EXPR:
    3147                 :           0 :       if (flags & TFF_EXPR_IN_PARENS)
    3148                 :           0 :         pp_cxx_left_paren (pp);
    3149                 :           0 :       pp->expression (t);
    3150                 :           0 :       if (flags & TFF_EXPR_IN_PARENS)
    3151                 :           0 :         pp_cxx_right_paren (pp);
    3152                 :             :       break;
    3153                 :             : 
    3154                 :           6 :     case OBJ_TYPE_REF:
    3155                 :           6 :       dump_expr (pp, resolve_virtual_fun_from_obj_type_ref (t), flags);
    3156                 :           6 :       break;
    3157                 :             : 
    3158                 :          59 :     case LAMBDA_EXPR:
    3159                 :          59 :       pp_string (pp, M_("<lambda>"));
    3160                 :          59 :       break;
    3161                 :             : 
    3162                 :           8 :     case PAREN_EXPR:
    3163                 :           8 :       pp_cxx_left_paren (pp);
    3164                 :           8 :       dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
    3165                 :           8 :       pp_cxx_right_paren (pp);
    3166                 :           8 :       break;
    3167                 :             : 
    3168                 :           3 :     case REQUIRES_EXPR:
    3169                 :           3 :       pp_cxx_requires_expr (cxx_pp, t);
    3170                 :           3 :       break;
    3171                 :             : 
    3172                 :           0 :     case SIMPLE_REQ:
    3173                 :           0 :       pp_cxx_simple_requirement (cxx_pp, t);
    3174                 :           0 :       break;
    3175                 :             : 
    3176                 :           0 :     case TYPE_REQ:
    3177                 :           0 :       pp_cxx_type_requirement (cxx_pp, t);
    3178                 :           0 :       break;
    3179                 :             : 
    3180                 :           0 :     case COMPOUND_REQ:
    3181                 :           0 :       pp_cxx_compound_requirement (cxx_pp, t);
    3182                 :           0 :       break;
    3183                 :             : 
    3184                 :           0 :     case NESTED_REQ:
    3185                 :           0 :       pp_cxx_nested_requirement (cxx_pp, t);
    3186                 :           0 :       break;
    3187                 :             : 
    3188                 :         513 :     case ATOMIC_CONSTR:
    3189                 :         513 :     case CONJ_CONSTR:
    3190                 :         513 :     case DISJ_CONSTR:
    3191                 :         513 :       {
    3192                 :         513 :         pp_cxx_constraint (cxx_pp, t);
    3193                 :         513 :         break;
    3194                 :             :       }
    3195                 :             : 
    3196                 :          14 :     case PLACEHOLDER_EXPR:
    3197                 :          14 :       pp_string (pp, M_("*this"));
    3198                 :          14 :       break;
    3199                 :             : 
    3200                 :          33 :     case TREE_LIST:
    3201                 :          33 :       dump_expr_list (pp, t, flags);
    3202                 :          33 :       break;
    3203                 :             : 
    3204                 :           6 :     case NONTYPE_ARGUMENT_PACK:
    3205                 :           6 :       {
    3206                 :           6 :         tree args = ARGUMENT_PACK_ARGS (t);
    3207                 :           6 :         int len = TREE_VEC_LENGTH (args);
    3208                 :           6 :         pp_cxx_left_brace (pp);
    3209                 :          12 :         for (int i = 0; i < len; ++i)
    3210                 :             :           {
    3211                 :           6 :             if (i > 0)
    3212                 :           0 :               pp_separate_with_comma (pp);
    3213                 :           6 :             dump_expr (pp, TREE_VEC_ELT (args, i), flags);
    3214                 :             :           }
    3215                 :           6 :         pp_cxx_right_brace (pp);
    3216                 :           6 :         break;
    3217                 :             :       }
    3218                 :             : 
    3219                 :             :       /*  This list is incomplete, but should suffice for now.
    3220                 :             :           It is very important that `sorry' does not call
    3221                 :             :           `report_error_function'.  That could cause an infinite loop.  */
    3222                 :          20 :     default:
    3223                 :          20 :       pp_unsupported_tree (pp, t);
    3224                 :             :       /* Fall through.  */
    3225                 :          63 :     case ERROR_MARK:
    3226                 :          63 :       pp_string (pp, M_("<expression error>"));
    3227                 :          63 :       break;
    3228                 :             :     }
    3229                 :             : }
    3230                 :             : 
    3231                 :             : static void
    3232                 :        1932 : dump_binary_op (cxx_pretty_printer *pp, const char *opstring, tree t,
    3233                 :             :                 int flags)
    3234                 :             : {
    3235                 :        1932 :   pp_cxx_left_paren (pp);
    3236                 :        1932 :   dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
    3237                 :        1932 :   pp_cxx_whitespace (pp);
    3238                 :        1932 :   if (opstring)
    3239                 :        1930 :     pp_cxx_ws_string (pp, opstring);
    3240                 :             :   else
    3241                 :           2 :     pp_string (pp, M_("<unknown operator>"));
    3242                 :        1932 :   pp_cxx_whitespace (pp);
    3243                 :        1932 :   tree op1 = TREE_OPERAND (t, 1);
    3244                 :        1932 :   if (TREE_CODE (t) == POINTER_PLUS_EXPR
    3245                 :         281 :       && TREE_CODE (op1) == INTEGER_CST
    3246                 :        2096 :       && tree_int_cst_sign_bit (op1))
    3247                 :             :     /* A pointer minus an integer is represented internally as plus a very
    3248                 :             :        large number, don't expose that to users.  */
    3249                 :          25 :     op1 = convert (ssizetype, op1);
    3250                 :        1932 :   dump_expr (pp, op1, flags | TFF_EXPR_IN_PARENS);
    3251                 :        1932 :   pp_cxx_right_paren (pp);
    3252                 :        1932 : }
    3253                 :             : 
    3254                 :             : static void
    3255                 :        1400 : dump_unary_op (cxx_pretty_printer *pp, const char *opstring, tree t, int flags)
    3256                 :             : {
    3257                 :        1400 :   if (flags & TFF_EXPR_IN_PARENS)
    3258                 :         772 :     pp_cxx_left_paren (pp);
    3259                 :        1400 :   pp_cxx_ws_string (pp, opstring);
    3260                 :        1400 :   dump_expr (pp, TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
    3261                 :        1400 :   if (flags & TFF_EXPR_IN_PARENS)
    3262                 :         772 :     pp_cxx_right_paren (pp);
    3263                 :        1400 : }
    3264                 :             : 
    3265                 :             : static void
    3266                 :   178853954 : reinit_cxx_pp (void)
    3267                 :             : {
    3268                 :   178853954 :   pp_clear_output_area (cxx_pp);
    3269                 :   178853954 :   cxx_pp->set_padding (pp_none);
    3270                 :   178853954 :   pp_indentation (cxx_pp) = 0;
    3271                 :   178853954 :   pp_needs_newline (cxx_pp) = false;
    3272                 :   178853954 :   pp_show_color (cxx_pp) = false;
    3273                 :   178853954 :   cxx_pp->enclosing_scope = current_function_decl;
    3274                 :   178853954 : }
    3275                 :             : 
    3276                 :             : /* Same as pp_formatted_text, except the return string is a separate
    3277                 :             :    copy and has a GGC storage duration, e.g. an indefinite lifetime.  */
    3278                 :             : 
    3279                 :             : inline const char *
    3280                 :   178854370 : pp_ggc_formatted_text (pretty_printer *pp)
    3281                 :             : {
    3282                 :   178854370 :   return ggc_strdup (pp_formatted_text (pp));
    3283                 :             : }
    3284                 :             : 
    3285                 :             : /* Exported interface to stringifying types, exprs and decls under TFF_*
    3286                 :             :    control.  */
    3287                 :             : 
    3288                 :             : const char *
    3289                 :         213 : type_as_string (tree typ, int flags)
    3290                 :             : {
    3291                 :         213 :   reinit_cxx_pp ();
    3292                 :         213 :   pp_translate_identifiers (cxx_pp) = false;
    3293                 :         213 :   dump_type (cxx_pp, typ, flags);
    3294                 :         213 :   return pp_ggc_formatted_text (cxx_pp);
    3295                 :             : }
    3296                 :             : 
    3297                 :             : const char *
    3298                 :           0 : type_as_string_translate (tree typ, int flags)
    3299                 :             : {
    3300                 :           0 :   reinit_cxx_pp ();
    3301                 :           0 :   dump_type (cxx_pp, typ, flags);
    3302                 :           0 :   return pp_ggc_formatted_text (cxx_pp);
    3303                 :             : }
    3304                 :             : 
    3305                 :             : const char *
    3306                 :        1639 : expr_as_string (tree decl, int flags)
    3307                 :             : {
    3308                 :        1639 :   reinit_cxx_pp ();
    3309                 :        1639 :   pp_translate_identifiers (cxx_pp) = false;
    3310                 :        1639 :   dump_expr (cxx_pp, decl, flags);
    3311                 :        1639 :   return pp_ggc_formatted_text (cxx_pp);
    3312                 :             : }
    3313                 :             : 
    3314                 :             : /* Wrap decl_as_string with options appropriate for dwarf.  */
    3315                 :             : 
    3316                 :             : const char *
    3317                 :    34668886 : decl_as_dwarf_string (tree decl, int flags)
    3318                 :             : {
    3319                 :    34668886 :   const char *name;
    3320                 :             :   /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the flag
    3321                 :             :      here will be adequate to get the desired behavior.  */
    3322                 :    34668886 :   cxx_pp->flags |= pp_c_flag_gnu_v3;
    3323                 :    34668886 :   name = decl_as_string (decl, flags);
    3324                 :             :   /* Subsequent calls to the pretty printer shouldn't use this style.  */
    3325                 :    34668886 :   cxx_pp->flags &= ~pp_c_flag_gnu_v3;
    3326                 :    34668886 :   return name;
    3327                 :             : }
    3328                 :             : 
    3329                 :             : const char *
    3330                 :    34714127 : decl_as_string (tree decl, int flags)
    3331                 :             : {
    3332                 :    34714127 :   reinit_cxx_pp ();
    3333                 :    34714127 :   pp_translate_identifiers (cxx_pp) = false;
    3334                 :    34714127 :   dump_decl (cxx_pp, decl, flags);
    3335                 :    34714127 :   return pp_ggc_formatted_text (cxx_pp);
    3336                 :             : }
    3337                 :             : 
    3338                 :             : const char *
    3339                 :           0 : decl_as_string_translate (tree decl, int flags)
    3340                 :             : {
    3341                 :           0 :   reinit_cxx_pp ();
    3342                 :           0 :   dump_decl (cxx_pp, decl, flags);
    3343                 :           0 :   return pp_ggc_formatted_text (cxx_pp);
    3344                 :             : }
    3345                 :             : 
    3346                 :             : /* Wrap lang_decl_name with options appropriate for dwarf.  */
    3347                 :             : 
    3348                 :             : const char *
    3349                 :   143853143 : lang_decl_dwarf_name (tree decl, int v, bool translate)
    3350                 :             : {
    3351                 :   143853143 :   const char *name;
    3352                 :             :   /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the flag
    3353                 :             :      here will be adequate to get the desired behavior.  */
    3354                 :   143853143 :   cxx_pp->flags |= pp_c_flag_gnu_v3;
    3355                 :   143853143 :   name = lang_decl_name (decl, v, translate);
    3356                 :             :   /* Subsequent calls to the pretty printer shouldn't use this style.  */
    3357                 :   143853143 :   cxx_pp->flags &= ~pp_c_flag_gnu_v3;
    3358                 :   143853143 :   return name;
    3359                 :             : }
    3360                 :             : 
    3361                 :             : /* Generate the three forms of printable names for cxx_printable_name.  */
    3362                 :             : 
    3363                 :             : const char *
    3364                 :   143971618 : lang_decl_name (tree decl, int v, bool translate)
    3365                 :             : {
    3366                 :   143971618 :   if (v >= 2)
    3367                 :       45190 :     return (translate
    3368                 :       45190 :             ? decl_as_string_translate (decl, TFF_DECL_SPECIFIERS)
    3369                 :       45190 :             : decl_as_string (decl, TFF_DECL_SPECIFIERS));
    3370                 :             : 
    3371                 :   143926428 :   reinit_cxx_pp ();
    3372                 :   143926428 :   pp_translate_identifiers (cxx_pp) = translate;
    3373                 :   143926428 :   if (v == 1
    3374                 :   143926428 :       && (DECL_CLASS_SCOPE_P (decl)
    3375                 :       79012 :           || (DECL_NAMESPACE_SCOPE_P (decl)
    3376                 :       77766 :               && CP_DECL_CONTEXT (decl) != global_namespace)))
    3377                 :             :     {
    3378                 :       81650 :       dump_type (cxx_pp, CP_DECL_CONTEXT (decl), TFF_PLAIN_IDENTIFIER);
    3379                 :       81650 :       pp_cxx_colon_colon (cxx_pp);
    3380                 :             :     }
    3381                 :             : 
    3382                 :   143926428 :   if (TREE_CODE (decl) == FUNCTION_DECL)
    3383                 :    75716495 :     dump_function_name (cxx_pp, decl, TFF_PLAIN_IDENTIFIER);
    3384                 :    68209933 :   else if ((DECL_NAME (decl) == NULL_TREE)
    3385                 :    68209933 :            && TREE_CODE (decl) == NAMESPACE_DECL)
    3386                 :          21 :     dump_decl (cxx_pp, decl, TFF_PLAIN_IDENTIFIER | TFF_UNQUALIFIED_NAME);
    3387                 :             :   else
    3388                 :    68209912 :     dump_decl (cxx_pp, DECL_NAME (decl), TFF_PLAIN_IDENTIFIER);
    3389                 :             : 
    3390                 :   143926428 :   return pp_ggc_formatted_text (cxx_pp);
    3391                 :             : }
    3392                 :             : 
    3393                 :             : /* Return the location of a tree passed to %+ formats.  */
    3394                 :             : 
    3395                 :             : location_t
    3396                 :     1819785 : location_of (tree t)
    3397                 :             : {
    3398                 :     1819785 :   if (TYPE_P (t))
    3399                 :             :     {
    3400                 :        2904 :       t = TYPE_MAIN_DECL (t);
    3401                 :        2904 :       if (t == NULL_TREE)
    3402                 :          34 :         return input_location;
    3403                 :             :     }
    3404                 :     1816881 :   else if (TREE_CODE (t) == OVERLOAD)
    3405                 :          34 :     t = (OVL_FIRST (t) != conv_op_marker ? OVL_FIRST (t)
    3406                 :           0 :          : OVL_FIRST (OVL_CHAIN (t)));
    3407                 :             : 
    3408                 :     1819751 :   if (DECL_P (t))
    3409                 :     1392164 :     return DECL_SOURCE_LOCATION (t);
    3410                 :      427587 :   if (TREE_CODE (t) == DEFERRED_PARSE)
    3411                 :          22 :     return defparse_location (t);
    3412                 :      427565 :   return cp_expr_loc_or_input_loc (t);
    3413                 :             : }
    3414                 :             : 
    3415                 :             : /* Now the interfaces from error et al to dump_type et al. Each takes an
    3416                 :             :    on/off VERBOSE flag and supply the appropriate TFF_ flags to a dump_
    3417                 :             :    function.  */
    3418                 :             : 
    3419                 :             : static const char *
    3420                 :       94192 : decl_to_string (tree decl, int verbose, bool show_color)
    3421                 :             : {
    3422                 :       94192 :   int flags = 0;
    3423                 :             : 
    3424                 :       94192 :   if (TREE_CODE (decl) == TYPE_DECL || TREE_CODE (decl) == RECORD_TYPE
    3425                 :             :       || TREE_CODE (decl) == UNION_TYPE || TREE_CODE (decl) == ENUMERAL_TYPE)
    3426                 :        3389 :     flags = TFF_CLASS_KEY_OR_ENUM;
    3427                 :       94192 :   if (verbose)
    3428                 :       29564 :     flags |= TFF_DECL_SPECIFIERS;
    3429                 :       64628 :   else if (TREE_CODE (decl) == FUNCTION_DECL)
    3430                 :       41648 :     flags |= TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE;
    3431                 :       94192 :   flags |= TFF_TEMPLATE_HEADER;
    3432                 :             : 
    3433                 :       94192 :   reinit_cxx_pp ();
    3434                 :       94192 :   pp_show_color (cxx_pp) = show_color;
    3435                 :       94192 :   dump_decl (cxx_pp, decl, flags);
    3436                 :       94192 :   return pp_ggc_formatted_text (cxx_pp);
    3437                 :             : }
    3438                 :             : 
    3439                 :             : const char *
    3440                 :       48218 : expr_to_string (tree decl)
    3441                 :             : {
    3442                 :       48218 :   reinit_cxx_pp ();
    3443                 :       48218 :   dump_expr (cxx_pp, decl, 0);
    3444                 :       48218 :   return pp_ggc_formatted_text (cxx_pp);
    3445                 :             : }
    3446                 :             : 
    3447                 :             : static const char *
    3448                 :         349 : fndecl_to_string (tree fndecl, int verbose)
    3449                 :             : {
    3450                 :         349 :   int flags;
    3451                 :             : 
    3452                 :         349 :   flags = TFF_EXCEPTION_SPECIFICATION | TFF_DECL_SPECIFIERS
    3453                 :             :     | TFF_TEMPLATE_HEADER;
    3454                 :         349 :   if (verbose)
    3455                 :          90 :     flags |= TFF_FUNCTION_DEFAULT_ARGUMENTS;
    3456                 :         349 :   reinit_cxx_pp ();
    3457                 :         349 :   dump_decl (cxx_pp, fndecl, flags);
    3458                 :         349 :   return pp_ggc_formatted_text (cxx_pp);
    3459                 :             : }
    3460                 :             : 
    3461                 :             : 
    3462                 :             : static const char *
    3463                 :           2 : code_to_string (enum tree_code c)
    3464                 :             : {
    3465                 :           0 :   return get_tree_code_name (c);
    3466                 :             : }
    3467                 :             : 
    3468                 :             : const char *
    3469                 :       13980 : language_to_string (enum languages c)
    3470                 :             : {
    3471                 :       13980 :   switch (c)
    3472                 :             :     {
    3473                 :             :     case lang_c:
    3474                 :             :       return "C";
    3475                 :             : 
    3476                 :           6 :     case lang_cplusplus:
    3477                 :           6 :       return "C++";
    3478                 :             : 
    3479                 :           0 :     default:
    3480                 :           0 :       gcc_unreachable ();
    3481                 :             :     }
    3482                 :             :   return NULL;
    3483                 :             : }
    3484                 :             : 
    3485                 :             : /* Return the proper printed version of a parameter to a C++ function.  */
    3486                 :             : 
    3487                 :             : static const char *
    3488                 :        1488 : parm_to_string (int p)
    3489                 :             : {
    3490                 :        1488 :   reinit_cxx_pp ();
    3491                 :        1488 :   if (p < 0)
    3492                 :           7 :     pp_string (cxx_pp, "'this'");
    3493                 :             :   else
    3494                 :        1481 :     pp_decimal_int (cxx_pp, p + 1);
    3495                 :        1488 :   return pp_ggc_formatted_text (cxx_pp);
    3496                 :             : }
    3497                 :             : 
    3498                 :             : static const char *
    3499                 :         317 : op_to_string (bool assop, enum tree_code p)
    3500                 :             : {
    3501                 :         317 :   tree id = ovl_op_identifier (assop, p);
    3502                 :         631 :   return id ? IDENTIFIER_POINTER (id) : M_("<unknown>");
    3503                 :             : }
    3504                 :             : 
    3505                 :             : /* Return a GC-allocated representation of type TYP, with verbosity VERBOSE.
    3506                 :             : 
    3507                 :             :    If QUOTE is non-NULL and if *QUOTE is true, then quotes are added to the
    3508                 :             :    string in appropriate places, and *QUOTE is written to with false
    3509                 :             :    to suppress pp_format's trailing close quote so that e.g.
    3510                 :             :      foo_typedef {aka underlying_foo} {enum}
    3511                 :             :    can be printed by "%qT" as:
    3512                 :             :      `foo_typedef' {aka `underlying_foo'} {enum}
    3513                 :             :    rather than:
    3514                 :             :      `foo_typedef {aka underlying_foo} {enum}'
    3515                 :             :    When adding such quotes, if POSTPROCESSED is true (for handling %H and %I)
    3516                 :             :    then a leading open quote will be added, whereas if POSTPROCESSED is false
    3517                 :             :    (for handling %T) then any leading quote has already been added by
    3518                 :             :    pp_format, or is not needed due to QUOTE being NULL (for template arguments
    3519                 :             :    within %H and %I).
    3520                 :             : 
    3521                 :             :    SHOW_COLOR and HIGHLIGHT_COLOR are used to determine the colorization of
    3522                 :             :    any quotes that are added.  */
    3523                 :             : 
    3524                 :             : static const char *
    3525                 :       62195 : type_to_string (tree typ, int verbose, bool postprocessed, bool *quote,
    3526                 :             :                 bool show_color, const char *highlight_color)
    3527                 :             : {
    3528                 :       62195 :   int flags = 0;
    3529                 :       62195 :   if (verbose)
    3530                 :        9074 :     flags |= TFF_CLASS_KEY_OR_ENUM;
    3531                 :       62195 :   flags |= TFF_TEMPLATE_HEADER;
    3532                 :             : 
    3533                 :       62195 :   reinit_cxx_pp ();
    3534                 :       62195 :   pp_show_color (cxx_pp) = show_color;
    3535                 :             : 
    3536                 :       62195 :   if (postprocessed && quote && *quote)
    3537                 :             :     {
    3538                 :       20624 :       pp_begin_quote (cxx_pp, show_color);
    3539                 :       20624 :       if (show_color && highlight_color)
    3540                 :           0 :         pp_string (cxx_pp, colorize_start (show_color, highlight_color));
    3541                 :             :     }
    3542                 :             : 
    3543                 :       62195 :   struct obstack *ob = pp_buffer (cxx_pp)->m_obstack;
    3544                 :       62195 :   int type_start, type_len;
    3545                 :       62195 :   type_start = obstack_object_size (ob);
    3546                 :             : 
    3547                 :       62195 :   dump_type (cxx_pp, typ, flags);
    3548                 :             : 
    3549                 :             :   /* Remember the end of the initial dump.  */
    3550                 :       62195 :   type_len = obstack_object_size (ob) - type_start;
    3551                 :             : 
    3552                 :             :   /* If we're printing a type that involves typedefs, also print the
    3553                 :             :      stripped version.  But sometimes the stripped version looks
    3554                 :             :      exactly the same, so we don't want it after all.  To avoid printing
    3555                 :             :      it in that case, we play ugly obstack games.  */
    3556                 :       62182 :   if (typ && TYPE_P (typ) && typ != TYPE_CANONICAL (typ)
    3557                 :       68667 :       && !uses_template_parms (typ))
    3558                 :             :     {
    3559                 :        4506 :       int aka_start, aka_len; char *p;
    3560                 :        4506 :       tree aka = strip_typedefs (typ, NULL, STF_USER_VISIBLE);
    3561                 :        4506 :       if (quote && *quote)
    3562                 :        4011 :         pp_end_quote (cxx_pp, show_color);
    3563                 :        4506 :       pp_string (cxx_pp, " {aka");
    3564                 :        4506 :       pp_cxx_whitespace (cxx_pp);
    3565                 :        4506 :       if (quote && *quote)
    3566                 :        4011 :         pp_begin_quote (cxx_pp, show_color);
    3567                 :        4506 :       if (highlight_color)
    3568                 :        1263 :         pp_string (cxx_pp, colorize_start (show_color, highlight_color));
    3569                 :             :       /* And remember the start of the aka dump.  */
    3570                 :        4506 :       aka_start = obstack_object_size (ob);
    3571                 :        4506 :       dump_type (cxx_pp, aka, flags);
    3572                 :        4506 :       aka_len = obstack_object_size (ob) - aka_start;
    3573                 :        4506 :       if (quote && *quote)
    3574                 :        4011 :         pp_end_quote (cxx_pp, show_color);
    3575                 :        4506 :       pp_right_brace (cxx_pp);
    3576                 :        4506 :       p = (char*)obstack_base (ob);
    3577                 :             :       /* If they are identical, cut off the aka by unwinding the obstack.  */
    3578                 :        4506 :       if (type_len == aka_len
    3579                 :        1013 :           && memcmp (p + type_start, p+aka_start, type_len) == 0)
    3580                 :             :         {
    3581                 :             :           /* We can't add a '\0' here, since we may be adding a closing quote
    3582                 :             :              below, and it would be hidden by the '\0'.
    3583                 :             :              Instead, manually unwind the current object within the obstack
    3584                 :             :              so that the insertion point is at the end of the type, before
    3585                 :             :              the "' {aka".  */
    3586                 :         759 :           int delta = type_start + type_len - obstack_object_size (ob);
    3587                 :         759 :           gcc_assert (delta <= 0);
    3588                 :         759 :           obstack_blank_fast (ob, delta);
    3589                 :         759 :         }
    3590                 :             :       else
    3591                 :        3747 :         if (quote)
    3592                 :             :           /* No further closing quotes are needed.  */
    3593                 :        3676 :           *quote = false;
    3594                 :             :     }
    3595                 :             : 
    3596                 :       62124 :   if (quote && *quote)
    3597                 :             :     {
    3598                 :       54737 :       if (show_color && highlight_color)
    3599                 :           0 :         pp_string (cxx_pp, colorize_stop (show_color));
    3600                 :       54737 :       pp_end_quote (cxx_pp, show_color);
    3601                 :       54737 :       *quote = false;
    3602                 :             :     }
    3603                 :       62195 :   return pp_ggc_formatted_text (cxx_pp);
    3604                 :             : }
    3605                 :             : 
    3606                 :             : static const char *
    3607                 :        3755 : args_to_string (tree p, int verbose)
    3608                 :             : {
    3609                 :        3755 :   int flags = 0;
    3610                 :        3755 :   if (verbose)
    3611                 :           0 :     flags |= TFF_CLASS_KEY_OR_ENUM;
    3612                 :             : 
    3613                 :        3755 :   if (p == NULL_TREE)
    3614                 :             :     return "";
    3615                 :             : 
    3616                 :        3012 :   if (TYPE_P (TREE_VALUE (p)))
    3617                 :           0 :     return type_as_string_translate (p, flags);
    3618                 :             : 
    3619                 :        3012 :   reinit_cxx_pp ();
    3620                 :        9670 :   for (; p; p = TREE_CHAIN (p))
    3621                 :             :     {
    3622                 :        3646 :       if (null_node_p (TREE_VALUE (p)))
    3623                 :           3 :         pp_cxx_ws_string (cxx_pp, "NULL");
    3624                 :             :       else
    3625                 :        3643 :         dump_type (cxx_pp, error_type (TREE_VALUE (p)), flags);
    3626                 :        3646 :       if (TREE_CHAIN (p))
    3627                 :         634 :         pp_separate_with_comma (cxx_pp);
    3628                 :             :     }
    3629                 :        3012 :   return pp_ggc_formatted_text (cxx_pp);
    3630                 :             : }
    3631                 :             : 
    3632                 :             : /* Pretty-print a deduction substitution (from deduction_tsubst_fntype).  P
    3633                 :             :    is a TREE_LIST with purpose the TEMPLATE_DECL, value the template
    3634                 :             :    arguments.  */
    3635                 :             : 
    3636                 :             : static const char *
    3637                 :        1520 : subst_to_string (tree p, bool show_color)
    3638                 :             : {
    3639                 :        1520 :   tree decl = TREE_PURPOSE (p);
    3640                 :        1520 :   tree targs = TREE_VALUE (p);
    3641                 :        1520 :   tree tparms = DECL_TEMPLATE_PARMS (decl);
    3642                 :        1520 :   int flags = (TFF_DECL_SPECIFIERS|TFF_TEMPLATE_HEADER
    3643                 :             :                |TFF_NO_TEMPLATE_BINDINGS);
    3644                 :             : 
    3645                 :        1520 :   if (p == NULL_TREE)
    3646                 :             :     return "";
    3647                 :             : 
    3648                 :        1520 :   reinit_cxx_pp ();
    3649                 :        1520 :   pp_show_color (cxx_pp) = show_color;
    3650                 :        1520 :   dump_template_decl (cxx_pp, TREE_PURPOSE (p), flags);
    3651                 :        1520 :   dump_substitution (cxx_pp, NULL, tparms, targs, /*flags=*/0);
    3652                 :        1520 :   return pp_ggc_formatted_text (cxx_pp);
    3653                 :             : }
    3654                 :             : 
    3655                 :             : static const char *
    3656                 :         573 : cv_to_string (tree p, int v)
    3657                 :             : {
    3658                 :         573 :   reinit_cxx_pp ();
    3659                 :         573 :   cxx_pp->set_padding (v ? pp_before : pp_none);
    3660                 :         573 :   pp_cxx_cv_qualifier_seq (cxx_pp, p);
    3661                 :         573 :   return pp_ggc_formatted_text (cxx_pp);
    3662                 :             : }
    3663                 :             : 
    3664                 :             : static const char *
    3665                 :           0 : eh_spec_to_string (tree p, int /*v*/)
    3666                 :             : {
    3667                 :           0 :   int flags = 0;
    3668                 :           0 :   reinit_cxx_pp ();
    3669                 :           0 :   dump_exception_spec (cxx_pp, p, flags);
    3670                 :           0 :   return pp_ggc_formatted_text (cxx_pp);
    3671                 :             : }
    3672                 :             : 
    3673                 :             : /* Langhook for print_error_function.  */
    3674                 :             : void
    3675                 :         116 : cxx_print_error_function (diagnostic_text_output_format &text_output,
    3676                 :             :                           const char *file,
    3677                 :             :                           const diagnostic_info *diagnostic)
    3678                 :             : {
    3679                 :         116 :   char *prefix;
    3680                 :         116 :   if (file)
    3681                 :         116 :     prefix = xstrdup (file);
    3682                 :             :   else
    3683                 :             :     prefix = NULL;
    3684                 :         116 :   lhd_print_error_function (text_output, file, diagnostic);
    3685                 :             : 
    3686                 :         116 :   pp_set_prefix (text_output.get_printer (), prefix);
    3687                 :         116 :   maybe_print_instantiation_context (text_output);
    3688                 :         116 : }
    3689                 :             : 
    3690                 :             : static void
    3691                 :      208783 : cp_diagnostic_text_starter (diagnostic_text_output_format &text_output,
    3692                 :             :                             const diagnostic_info *diagnostic)
    3693                 :             : {
    3694                 :      208783 :   pp_set_prefix (text_output.get_printer (),
    3695                 :             :                  text_output.build_indent_prefix (true));
    3696                 :      208783 :   text_output.report_current_module (diagnostic_location (diagnostic));
    3697                 :      208783 :   cp_print_error_function (text_output, diagnostic);
    3698                 :      208783 :   maybe_print_instantiation_context (text_output);
    3699                 :      208783 :   maybe_print_constexpr_context (text_output);
    3700                 :      208783 :   maybe_print_constraint_context (text_output);
    3701                 :      208783 :   pp_set_prefix (text_output.get_printer (),
    3702                 :             :                  text_output.build_prefix (*diagnostic));
    3703                 :      208783 : }
    3704                 :             : 
    3705                 :             : /* Print current function onto BUFFER, in the process of reporting
    3706                 :             :    a diagnostic message.  Called from cp_diagnostic_starter.  */
    3707                 :             : static void
    3708                 :      208783 : cp_print_error_function (diagnostic_text_output_format &text_output,
    3709                 :             :                          const diagnostic_info *diagnostic)
    3710                 :             : {
    3711                 :             :   /* If we are in an instantiation context, current_function_decl is likely
    3712                 :             :      to be wrong, so just rely on print_instantiation_full_context.  */
    3713                 :      208783 :   if (current_instantiation ())
    3714                 :             :     return;
    3715                 :             :   /* The above is true for constraint satisfaction also.  */
    3716                 :      196133 :   if (current_failed_constraint)
    3717                 :             :     return;
    3718                 :      195895 :   diagnostic_context *const context = &text_output.get_context ();
    3719                 :      195895 :   if (diagnostic_last_function_changed (context, diagnostic))
    3720                 :             :     {
    3721                 :       24076 :       pretty_printer *const pp = text_output.get_printer ();
    3722                 :       24076 :       char *old_prefix = pp_take_prefix (pp);
    3723                 :       24076 :       const char *file = LOCATION_FILE (diagnostic_location (diagnostic));
    3724                 :       24076 :       tree abstract_origin = diagnostic_abstract_origin (diagnostic);
    3725                 :       24076 :       char *new_prefix = (file && abstract_origin == NULL)
    3726                 :       24076 :                          ? text_output.file_name_as_prefix (file) : NULL;
    3727                 :             : 
    3728                 :       24076 :       pp_set_prefix (pp, new_prefix);
    3729                 :             : 
    3730                 :       24076 :       if (current_function_decl == NULL)
    3731                 :         884 :         pp_string (pp, _("At global scope:"));
    3732                 :             :       else
    3733                 :             :         {
    3734                 :       23192 :           tree fndecl, ao;
    3735                 :             : 
    3736                 :       23192 :           if (abstract_origin)
    3737                 :             :             {
    3738                 :         397 :               ao = BLOCK_ABSTRACT_ORIGIN (abstract_origin);
    3739                 :         397 :               gcc_assert (TREE_CODE (ao) == FUNCTION_DECL);
    3740                 :             :               fndecl = ao;
    3741                 :             :             }
    3742                 :             :           else
    3743                 :             :             fndecl = current_function_decl;
    3744                 :             : 
    3745                 :       23192 :           pp_printf (pp, function_category (fndecl),
    3746                 :             :                      fndecl);
    3747                 :             : 
    3748                 :       46984 :           while (abstract_origin)
    3749                 :             :             {
    3750                 :         600 :               location_t *locus;
    3751                 :         600 :               tree block = abstract_origin;
    3752                 :             : 
    3753                 :         600 :               locus = &BLOCK_SOURCE_LOCATION (block);
    3754                 :         600 :               fndecl = NULL;
    3755                 :         600 :               block = BLOCK_SUPERCONTEXT (block);
    3756                 :        1329 :               while (block && TREE_CODE (block) == BLOCK
    3757                 :        1449 :                      && BLOCK_ABSTRACT_ORIGIN (block))
    3758                 :             :                 {
    3759                 :         332 :                   ao = BLOCK_ABSTRACT_ORIGIN (block);
    3760                 :         332 :                   if (TREE_CODE (ao) == FUNCTION_DECL)
    3761                 :             :                     {
    3762                 :             :                       fndecl = ao;
    3763                 :             :                       break;
    3764                 :             :                     }
    3765                 :         129 :                   else if (TREE_CODE (ao) != BLOCK)
    3766                 :             :                     break;
    3767                 :             : 
    3768                 :         129 :                   block = BLOCK_SUPERCONTEXT (block);
    3769                 :             :                 }
    3770                 :         600 :               if (fndecl)
    3771                 :             :                 abstract_origin = block;
    3772                 :             :               else
    3773                 :             :                 {
    3774                 :         852 :                   while (block && TREE_CODE (block) == BLOCK)
    3775                 :         455 :                     block = BLOCK_SUPERCONTEXT (block);
    3776                 :             : 
    3777                 :         397 :                   if (block && TREE_CODE (block) == FUNCTION_DECL)
    3778                 :             :                     fndecl = block;
    3779                 :             :                   abstract_origin = NULL;
    3780                 :             :                 }
    3781                 :             :               if (fndecl)
    3782                 :             :                 {
    3783                 :         600 :                   expanded_location s = expand_location (*locus);
    3784                 :         600 :                   pp_character (pp, ',');
    3785                 :         600 :                   pp_newline (pp);
    3786                 :         600 :                   if (s.file != NULL)
    3787                 :             :                     {
    3788                 :         600 :                       if (text_output.show_column_p () && s.column != 0)
    3789                 :         551 :                         pp_printf (pp,
    3790                 :         551 :                                    _("    inlined from %qD at %r%s:%d:%d%R"),
    3791                 :             :                                    fndecl,
    3792                 :             :                                    "locus", s.file, s.line, s.column);
    3793                 :             :                       else
    3794                 :          49 :                         pp_printf (pp,
    3795                 :          49 :                                    _("    inlined from %qD at %r%s:%d%R"),
    3796                 :             :                                    fndecl,
    3797                 :             :                                    "locus", s.file, s.line);
    3798                 :             : 
    3799                 :             :                     }
    3800                 :             :                   else
    3801                 :           0 :                     pp_printf (pp, _("    inlined from %qD"),
    3802                 :             :                                fndecl);
    3803                 :             :                 }
    3804                 :             :             }
    3805                 :       23192 :           pp_character (pp, ':');
    3806                 :             :         }
    3807                 :       24076 :       pp_newline (pp);
    3808                 :             : 
    3809                 :       24076 :       diagnostic_set_last_function (context, diagnostic);
    3810                 :       24076 :       pp->set_prefix (old_prefix);
    3811                 :             :     }
    3812                 :             : }
    3813                 :             : 
    3814                 :             : /* Returns a description of FUNCTION using standard terminology.  The
    3815                 :             :    result is a format string of the form "In CATEGORY %qD".  */
    3816                 :             : 
    3817                 :             : static const char *
    3818                 :       23192 : function_category (tree fn)
    3819                 :             : {
    3820                 :             :   /* We can get called from the middle-end for diagnostics of function
    3821                 :             :      clones.  Make sure we have language specific information before
    3822                 :             :      dereferencing it.  */
    3823                 :       23192 :   if (DECL_LANG_SPECIFIC (STRIP_TEMPLATE (fn))
    3824                 :       23192 :       && DECL_FUNCTION_MEMBER_P (fn))
    3825                 :             :     {
    3826                 :        2965 :       if (DECL_STATIC_FUNCTION_P (fn))
    3827                 :         109 :         return _("In static member function %qD");
    3828                 :        2856 :       else if (DECL_COPY_CONSTRUCTOR_P (fn))
    3829                 :          41 :         return _("In copy constructor %qD");
    3830                 :        5630 :       else if (DECL_CONSTRUCTOR_P (fn))
    3831                 :         973 :         return _("In constructor %qD");
    3832                 :        1842 :       else if (DECL_DESTRUCTOR_P (fn))
    3833                 :         122 :         return _("In destructor %qD");
    3834                 :        2160 :       else if (LAMBDA_FUNCTION_P (fn))
    3835                 :         431 :         return _("In lambda function");
    3836                 :        1289 :       else if (DECL_XOBJ_MEMBER_FUNCTION_P (fn))
    3837                 :          14 :         return _("In explicit object member function %qD");
    3838                 :             :       else
    3839                 :        1275 :         return _("In member function %qD");
    3840                 :             :     }
    3841                 :             :   else
    3842                 :       20227 :     return _("In function %qD");
    3843                 :             : }
    3844                 :             : 
    3845                 :             : /* Disable warnings about missing quoting in GCC diagnostics for
    3846                 :             :    the pp_verbatim calls.  Their format strings deliberately don't
    3847                 :             :    follow GCC diagnostic conventions.  */
    3848                 :             : #if __GNUC__ >= 10
    3849                 :             : #pragma GCC diagnostic push
    3850                 :             : #pragma GCC diagnostic ignored "-Wformat-diag"
    3851                 :             : #endif
    3852                 :             : 
    3853                 :             : /* Report the full context of a current template instantiation,
    3854                 :             :    onto BUFFER.  */
    3855                 :             : static void
    3856                 :        4981 : print_instantiation_full_context (diagnostic_text_output_format &text_output)
    3857                 :             : {
    3858                 :        4981 :   struct tinst_level *p = current_instantiation ();
    3859                 :        4981 :   location_t location = input_location;
    3860                 :             : 
    3861                 :        4981 :   if (p)
    3862                 :             :     {
    3863                 :        4981 :       bool show_file
    3864                 :        4981 :         = ((!text_output.show_nesting_p ())
    3865                 :        4981 :            || text_output.show_locations_in_nesting_p ());
    3866                 :        4981 :       char *indent = text_output.build_indent_prefix (true);
    3867                 :       19915 :       pp_verbatim (text_output.get_printer (),
    3868                 :        4981 :                    p->list_p ()
    3869                 :        1188 :                    ? _("%s%s%sIn substitution of %qS:\n")
    3870                 :        3793 :                    : _("%s%s%sIn instantiation of %q#D:\n"),
    3871                 :             :                    indent,
    3872                 :        4972 :                    show_file ? LOCATION_FILE (location) : "",
    3873                 :             :                    show_file ? ": " : "",
    3874                 :             :                    p->get_node ());
    3875                 :        4981 :       free (indent);
    3876                 :        4981 :       location = p->locus;
    3877                 :        4981 :       p = p->next;
    3878                 :             :     }
    3879                 :             : 
    3880                 :        4981 :   print_instantiation_partial_context (text_output, p, location);
    3881                 :        4981 : }
    3882                 :             : 
    3883                 :             : static void
    3884                 :        9329 : print_location (diagnostic_text_output_format &text_output,
    3885                 :             :                 location_t loc)
    3886                 :             : {
    3887                 :        9329 :   expanded_location xloc = expand_location (loc);
    3888                 :        9329 :   pretty_printer *const pp = text_output.get_printer ();
    3889                 :        9329 :   if (text_output.show_column_p ())
    3890                 :        6393 :     pp_verbatim (pp, _("%r%s:%d:%d:%R   "),
    3891                 :             :                  "locus", xloc.file, xloc.line, xloc.column);
    3892                 :             :   else
    3893                 :        2936 :     pp_verbatim (pp, _("%r%s:%d:%R   "),
    3894                 :             :                  "locus", xloc.file, xloc.line);
    3895                 :        9329 : }
    3896                 :             : 
    3897                 :             : /* A RAII class for use when emitting a line of contextual information
    3898                 :             :    via pp_verbatim to a diagnostic_text_output_format to add before/after
    3899                 :             :    behaviors to the pp_verbatim calls.
    3900                 :             : 
    3901                 :             :    If the text output has show_nesting_p (), then the ctor prints
    3902                 :             :    leading indentation and a bullet point, and the dtor prints
    3903                 :             :    the location on a new line, and calls diagnostic_show_locus, both
    3904                 :             :    with indentation (and no bullet point).
    3905                 :             : 
    3906                 :             :    Otherwise (when the text output has !show_nesting_p), the ctor prints
    3907                 :             :    the location as leading information on the same line, and the
    3908                 :             :    dtor optionally calls diagnostic_show_locus.  */
    3909                 :             : 
    3910                 :             : class auto_context_line
    3911                 :             : {
    3912                 :             : public:
    3913                 :        9365 :   auto_context_line (diagnostic_text_output_format &text_output,
    3914                 :             :                      location_t loc,
    3915                 :             :                      bool show_locus = false)
    3916                 :        9365 :   : m_text_output (text_output),
    3917                 :        9365 :     m_loc (loc),
    3918                 :        9365 :     m_show_locus (show_locus)
    3919                 :             :   {
    3920                 :        9365 :     char *indent = m_text_output.build_indent_prefix (true);
    3921                 :        9365 :     pp_verbatim (m_text_output.get_printer (), indent);
    3922                 :        9365 :     free (indent);
    3923                 :        9365 :     if (!m_text_output.show_nesting_p ())
    3924                 :        9329 :       print_location (m_text_output, m_loc);
    3925                 :        9365 :   }
    3926                 :        9365 :   ~auto_context_line ()
    3927                 :             :   {
    3928                 :        9365 :     pretty_printer *const pp = m_text_output.get_printer ();
    3929                 :        9365 :     if (m_text_output.show_nesting_p ())
    3930                 :             :       {
    3931                 :          36 :         if (m_text_output.show_locations_in_nesting_p ())
    3932                 :             :           {
    3933                 :           0 :             char *indent = m_text_output.build_indent_prefix (false);
    3934                 :           0 :             pp_verbatim (pp, indent);
    3935                 :           0 :             print_location (m_text_output, m_loc);
    3936                 :           0 :             pp_newline (pp);
    3937                 :             : 
    3938                 :           0 :             char *saved_prefix = pp_take_prefix (pp);
    3939                 :           0 :             pp_set_prefix (pp, indent);
    3940                 :           0 :             gcc_rich_location rich_loc (m_loc);
    3941                 :           0 :             diagnostic_show_locus (&m_text_output.get_context (),
    3942                 :           0 :                                    m_text_output.get_source_printing_options (),
    3943                 :             :                                    &rich_loc,
    3944                 :             :                                    DK_NOTE, pp);
    3945                 :           0 :             pp_set_prefix (pp, saved_prefix);
    3946                 :           0 :           }
    3947                 :             :       }
    3948                 :        9329 :     else if (m_show_locus)
    3949                 :             :       {
    3950                 :        6599 :         char *saved_prefix = pp_take_prefix (pp);
    3951                 :        6599 :         pp_set_prefix (pp, nullptr);
    3952                 :        6599 :         gcc_rich_location rich_loc (m_loc);
    3953                 :        6599 :         diagnostic_show_locus (&m_text_output.get_context (),
    3954                 :        6599 :                                m_text_output.get_source_printing_options (),
    3955                 :             :                                &rich_loc,
    3956                 :             :                                DK_NOTE, pp);
    3957                 :        6599 :         pp_set_prefix (pp, saved_prefix);
    3958                 :        6599 :       }
    3959                 :        9365 :   }
    3960                 :             : private:
    3961                 :             :   diagnostic_text_output_format &m_text_output;
    3962                 :             :   location_t m_loc;
    3963                 :             :   bool m_show_locus;
    3964                 :             : };
    3965                 :             : 
    3966                 :             : /* Helper function of print_instantiation_partial_context() that
    3967                 :             :    prints a single line of instantiation context.  */
    3968                 :             : 
    3969                 :             : static void
    3970                 :        6642 : print_instantiation_partial_context_line (diagnostic_text_output_format &text_output,
    3971                 :             :                                           struct tinst_level *t,
    3972                 :             :                                           location_t loc, bool recursive_p)
    3973                 :             : {
    3974                 :        6642 :   if (loc == UNKNOWN_LOCATION)
    3975                 :          34 :     return;
    3976                 :             : 
    3977                 :        6608 :   auto_context_line sentinel (text_output, loc, true);
    3978                 :             : 
    3979                 :        6608 :   pretty_printer *const pp = text_output.get_printer ();
    3980                 :             : 
    3981                 :        6608 :   if (t != NULL)
    3982                 :             :     {
    3983                 :        1661 :       if (t->list_p ())
    3984                 :         897 :         pp_verbatim (pp,
    3985                 :             :                      recursive_p
    3986                 :          21 :                      ? _("recursively required by substitution of %qS\n")
    3987                 :         278 :                      : _("required by substitution of %qS\n"),
    3988                 :             :                      t->get_node ());
    3989                 :             :       else
    3990                 :        2724 :         pp_verbatim (pp,
    3991                 :             :                      recursive_p
    3992                 :         100 :                      ? _("recursively required from %q#D\n")
    3993                 :        1262 :                      : _("required from %q#D\n"),
    3994                 :             :                      t->get_node ());
    3995                 :             :     }
    3996                 :             :   else
    3997                 :             :     {
    3998                 :        9894 :       pp_verbatim (pp,
    3999                 :             :                    recursive_p
    4000                 :           0 :                    ? _("recursively required from here\n")
    4001                 :        4947 :                    : _("required from here\n"));
    4002                 :             :     }
    4003                 :        6608 : }
    4004                 :             : 
    4005                 :             : /* Same as print_instantiation_full_context but less verbose.  */
    4006                 :             : 
    4007                 :             : static void
    4008                 :        4981 : print_instantiation_partial_context (diagnostic_text_output_format &text_output,
    4009                 :             :                                      struct tinst_level *t0, location_t loc)
    4010                 :             : {
    4011                 :        4981 :   struct tinst_level *t;
    4012                 :        4981 :   int n_total = 0;
    4013                 :        4981 :   int n;
    4014                 :        4981 :   location_t prev_loc = loc;
    4015                 :             : 
    4016                 :       39511 :   for (t = t0; t != NULL; t = t->next)
    4017                 :       34530 :     if (prev_loc != t->locus)
    4018                 :             :       {
    4019                 :        1597 :         prev_loc = t->locus;
    4020                 :        1597 :         n_total++;
    4021                 :             :       }
    4022                 :             : 
    4023                 :        4981 :   t = t0;
    4024                 :             : 
    4025                 :        4981 :   if (template_backtrace_limit
    4026                 :        4981 :       && n_total > template_backtrace_limit)
    4027                 :             :     {
    4028                 :           1 :       int skip = n_total - template_backtrace_limit;
    4029                 :           1 :       int head = template_backtrace_limit / 2;
    4030                 :             : 
    4031                 :             :       /* Avoid skipping just 1.  If so, skip 2.  */
    4032                 :           1 :       if (skip == 1)
    4033                 :             :        {
    4034                 :           0 :          skip = 2;
    4035                 :           0 :          head = (template_backtrace_limit - 1) / 2;
    4036                 :             :        }
    4037                 :             : 
    4038                 :           6 :       for (n = 0; n < head; n++)
    4039                 :             :         {
    4040                 :           5 :           gcc_assert (t != NULL);
    4041                 :           5 :           if (loc != t->locus)
    4042                 :           4 :             print_instantiation_partial_context_line (text_output, t, loc,
    4043                 :             :                                                       /*recursive_p=*/false);
    4044                 :           5 :           loc = t->locus;
    4045                 :           5 :           t = t->next;
    4046                 :             :         }
    4047                 :           1 :       if (t != NULL && skip > 0)
    4048                 :             :         {
    4049                 :           1 :           auto_context_line sentinel (text_output, loc);
    4050                 :           1 :           pp_verbatim (text_output.get_printer (),
    4051                 :           1 :                        _("[ skipping %d instantiation contexts,"
    4052                 :             :                          " use -ftemplate-backtrace-limit=0 to disable ]\n"),
    4053                 :             :                        skip);
    4054                 :           2 :           do {
    4055                 :           2 :             loc = t->locus;
    4056                 :           2 :             t = t->next;
    4057                 :           3 :           } while (t != NULL && --skip > 0);
    4058                 :           1 :         }
    4059                 :             :     }
    4060                 :             : 
    4061                 :        6638 :   while (t != NULL)
    4062                 :             :     {
    4063                 :       34523 :       while (t->next != NULL && t->locus == t->next->locus)
    4064                 :             :         {
    4065                 :             :           loc = t->locus;
    4066                 :             :           t = t->next;
    4067                 :             :         }
    4068                 :        1657 :       print_instantiation_partial_context_line (text_output, t, loc,
    4069                 :        1657 :                                                 t->locus == loc);
    4070                 :        1657 :       loc = t->locus;
    4071                 :        1657 :       t = t->next;
    4072                 :             :     }
    4073                 :        4981 :   print_instantiation_partial_context_line (text_output, NULL, loc,
    4074                 :             :                                             /*recursive_p=*/false);
    4075                 :        4981 : }
    4076                 :             : 
    4077                 :             : /* Called from cp_thing to print the template context for an error.  */
    4078                 :             : static void
    4079                 :      208899 : maybe_print_instantiation_context (diagnostic_text_output_format &text_output)
    4080                 :             : {
    4081                 :      208899 :   if (!problematic_instantiation_changed () || current_instantiation () == 0)
    4082                 :      203918 :     return;
    4083                 :             : 
    4084                 :        4981 :   record_last_problematic_instantiation ();
    4085                 :        4981 :   print_instantiation_full_context (text_output);
    4086                 :             : }
    4087                 :             : 
    4088                 :             : /* Report what constexpr call(s) we're trying to expand, if any.  */
    4089                 :             : 
    4090                 :             : void
    4091                 :      208783 : maybe_print_constexpr_context (diagnostic_text_output_format &text_output)
    4092                 :             : {
    4093                 :      208783 :   vec<tree> call_stack = cx_error_context ();
    4094                 :      208783 :   unsigned ix;
    4095                 :      208783 :   tree t;
    4096                 :             : 
    4097                 :      209849 :   FOR_EACH_VEC_ELT (call_stack, ix, t)
    4098                 :             :     {
    4099                 :        1066 :       const char *s = expr_as_string (t, 0);
    4100                 :        1066 :       pretty_printer *const pp = text_output.get_printer ();
    4101                 :        1066 :       auto_context_line sentinel (text_output, EXPR_LOCATION (t));
    4102                 :        1066 :       pp_verbatim (pp,
    4103                 :        1066 :                    _("in %<constexpr%> expansion of %qs"),
    4104                 :             :                    s);
    4105                 :        1066 :       pp_newline (pp);
    4106                 :        1066 :     }
    4107                 :      208783 : }
    4108                 :             : 
    4109                 :             : 
    4110                 :             : static void
    4111                 :         504 : print_constrained_decl_info (diagnostic_text_output_format &text_output,
    4112                 :             :                              tree decl)
    4113                 :             : {
    4114                 :         504 :   auto_context_line sentinel (text_output, DECL_SOURCE_LOCATION (decl));
    4115                 :         504 :   pretty_printer *const pp = text_output.get_printer ();
    4116                 :         504 :   pp_verbatim (pp, "required by the constraints of %q#D\n", decl);
    4117                 :         504 : }
    4118                 :             : 
    4119                 :             : static void
    4120                 :         856 : print_concept_check_info (diagnostic_text_output_format &text_output,
    4121                 :             :                           tree expr, tree map, tree args)
    4122                 :             : {
    4123                 :         856 :   gcc_assert (concept_check_p (expr));
    4124                 :             : 
    4125                 :         856 :   tree tmpl = TREE_OPERAND (expr, 0);
    4126                 :             : 
    4127                 :         856 :   auto_context_line sentinel (text_output, DECL_SOURCE_LOCATION (tmpl));
    4128                 :             : 
    4129                 :         856 :   cxx_pretty_printer *const pp
    4130                 :         856 :     = (cxx_pretty_printer *)text_output.get_printer ();
    4131                 :         856 :   pp_verbatim (pp, "required for the satisfaction of %qE", expr);
    4132                 :         856 :   if (map && map != error_mark_node)
    4133                 :             :     {
    4134                 :         856 :       tree subst_map = tsubst_parameter_mapping (map, args, tf_none, NULL_TREE);
    4135                 :         857 :       pp_cxx_parameter_mapping (pp, (subst_map != error_mark_node
    4136                 :             :                                      ? subst_map : map));
    4137                 :             :     }
    4138                 :         856 :   pp_newline (pp);
    4139                 :         856 : }
    4140                 :             : 
    4141                 :             : /* Diagnose the entry point into the satisfaction error. Returns the next
    4142                 :             :    context, if any.  */
    4143                 :             : 
    4144                 :             : static tree
    4145                 :        1245 : print_constraint_context_head (diagnostic_text_output_format &text_output,
    4146                 :             :                                tree cxt, tree args)
    4147                 :             : {
    4148                 :        1245 :   tree src = TREE_VALUE (cxt);
    4149                 :        1245 :   if (!src)
    4150                 :             :     {
    4151                 :           0 :       auto_context_line sentinel (text_output, input_location);
    4152                 :           0 :       pretty_printer *const pp = text_output.get_printer ();
    4153                 :           0 :       pp_verbatim (pp, "required for constraint satisfaction\n");
    4154                 :           0 :       return NULL_TREE;
    4155                 :           0 :     }
    4156                 :        1245 :   if (DECL_P (src))
    4157                 :             :     {
    4158                 :         504 :       print_constrained_decl_info (text_output, src);
    4159                 :         504 :       return NULL_TREE;
    4160                 :             :     }
    4161                 :             :   else
    4162                 :             :     {
    4163                 :         741 :       print_concept_check_info (text_output, src, TREE_PURPOSE (cxt), args);
    4164                 :         741 :       return TREE_CHAIN (cxt);
    4165                 :             :     }
    4166                 :             : }
    4167                 :             : 
    4168                 :             : static void
    4169                 :         331 : print_requires_expression_info (diagnostic_text_output_format &text_output,
    4170                 :             :                                 tree constr, tree args)
    4171                 :             : {
    4172                 :             : 
    4173                 :         331 :   tree expr = ATOMIC_CONSTR_EXPR (constr);
    4174                 :         331 :   tree map = ATOMIC_CONSTR_MAP (constr);
    4175                 :         331 :   map = tsubst_parameter_mapping (map, args, tf_none, NULL_TREE);
    4176                 :         331 :   if (map == error_mark_node)
    4177                 :           1 :     return;
    4178                 :             : 
    4179                 :         330 :   auto_context_line sentinel (text_output, cp_expr_loc_or_input_loc (expr));
    4180                 :         330 :   cxx_pretty_printer *const pp
    4181                 :         330 :     = static_cast <cxx_pretty_printer *> (text_output.get_printer ());
    4182                 :         330 :   pp_verbatim (pp, "in requirements ");
    4183                 :             : 
    4184                 :         330 :   tree parms = TREE_OPERAND (expr, 0);
    4185                 :         330 :   if (parms)
    4186                 :         196 :     pp_verbatim (pp, "with ");
    4187                 :         630 :   while (parms)
    4188                 :             :     {
    4189                 :         300 :       pp_verbatim (pp, "%q#D", parms);
    4190                 :         300 :       if (TREE_CHAIN (parms))
    4191                 :         104 :         pp_separate_with_comma (pp);
    4192                 :         300 :       parms = TREE_CHAIN (parms);
    4193                 :             :     }
    4194                 :         330 :   pp_cxx_parameter_mapping (pp, map);
    4195                 :             : 
    4196                 :         330 :   pp_verbatim (pp, "\n");
    4197                 :         330 : }
    4198                 :             : 
    4199                 :             : void
    4200                 :        1269 : maybe_print_single_constraint_context (diagnostic_text_output_format &text_output,
    4201                 :             :                                        tree failed)
    4202                 :             : {
    4203                 :        1269 :   if (!failed)
    4204                 :             :     return;
    4205                 :             : 
    4206                 :        1269 :   tree constr = TREE_VALUE (failed);
    4207                 :        1269 :   if (!constr || constr == error_mark_node)
    4208                 :             :     return;
    4209                 :        1269 :   tree cxt = CONSTR_CONTEXT (constr);
    4210                 :        1269 :   if (!cxt)
    4211                 :             :     return;
    4212                 :        1245 :   tree args = TREE_PURPOSE (failed);
    4213                 :             : 
    4214                 :             :   /* Print the stack of requirements.  */
    4215                 :        1245 :   cxt = print_constraint_context_head (text_output, cxt, args);
    4216                 :        3328 :   while (cxt && !DECL_P (TREE_VALUE (cxt)))
    4217                 :             :     {
    4218                 :         115 :       tree expr = TREE_VALUE (cxt);
    4219                 :         115 :       tree map = TREE_PURPOSE (cxt);
    4220                 :         115 :       print_concept_check_info (text_output, expr, map, args);
    4221                 :         115 :       cxt = TREE_CHAIN (cxt);
    4222                 :             :     }
    4223                 :             : 
    4224                 :             :   /* For certain constraints, we can provide additional context.  */
    4225                 :        1245 :   if (TREE_CODE (constr) == ATOMIC_CONSTR
    4226                 :        1245 :       && TREE_CODE (ATOMIC_CONSTR_EXPR (constr)) == REQUIRES_EXPR)
    4227                 :         331 :     print_requires_expression_info (text_output, constr, args);
    4228                 :             : }
    4229                 :             : 
    4230                 :             : void
    4231                 :      208786 : maybe_print_constraint_context (diagnostic_text_output_format &text_output)
    4232                 :             : {
    4233                 :      208786 :   if (!current_failed_constraint)
    4234                 :             :     return;
    4235                 :             : 
    4236                 :        1269 :   tree cur = current_failed_constraint;
    4237                 :             : 
    4238                 :             :   /* Recursively print nested contexts.  */
    4239                 :        1269 :   current_failed_constraint = TREE_CHAIN (current_failed_constraint);
    4240                 :        1269 :   if (current_failed_constraint)
    4241                 :           3 :     maybe_print_constraint_context (text_output);
    4242                 :             : 
    4243                 :             :   /* Print this context.  */
    4244                 :        1269 :   maybe_print_single_constraint_context (text_output, cur);
    4245                 :             : }
    4246                 :             : 
    4247                 :             : /* Return true iff TYPE_A and TYPE_B are template types that are
    4248                 :             :    meaningful to compare.  */
    4249                 :             : 
    4250                 :             : static bool
    4251                 :       11655 : comparable_template_types_p (tree type_a, tree type_b)
    4252                 :             : {
    4253                 :       11655 :   if (!CLASS_TYPE_P (type_a))
    4254                 :             :     return false;
    4255                 :        1301 :   if (!CLASS_TYPE_P (type_b))
    4256                 :             :     return false;
    4257                 :             : 
    4258                 :         388 :   tree tinfo_a = TYPE_TEMPLATE_INFO (type_a);
    4259                 :         388 :   tree tinfo_b = TYPE_TEMPLATE_INFO (type_b);
    4260                 :         388 :   if (!tinfo_a || !tinfo_b)
    4261                 :             :     return false;
    4262                 :             : 
    4263                 :         241 :   return TI_TEMPLATE (tinfo_a) == TI_TEMPLATE (tinfo_b);
    4264                 :             : }
    4265                 :             : 
    4266                 :             : /* Start a new line indented by SPC spaces on PP.  */
    4267                 :             : 
    4268                 :             : static void
    4269                 :         228 : newline_and_indent (pretty_printer *pp, int spc)
    4270                 :             : {
    4271                 :         228 :   pp_newline (pp);
    4272                 :        1020 :   for (int i = 0; i < spc; i++)
    4273                 :         792 :     pp_space (pp);
    4274                 :         228 : }
    4275                 :             : 
    4276                 :             : /* Generate a GC-allocated string for ARG, an expression or type.  */
    4277                 :             : 
    4278                 :             : static const char *
    4279                 :         636 : arg_to_string (tree arg, bool verbose)
    4280                 :             : {
    4281                 :         636 :   if (TYPE_P (arg))
    4282                 :         370 :     return type_to_string (arg, verbose, true, NULL, false);
    4283                 :             :   else
    4284                 :         266 :     return expr_to_string (arg);
    4285                 :             : }
    4286                 :             : 
    4287                 :             : /* Subroutine to type_to_string_with_compare and
    4288                 :             :    print_template_tree_comparison.
    4289                 :             : 
    4290                 :             :    Print a representation of ARG (an expression or type) to PP,
    4291                 :             :    colorizing it if PP->show_color, using HIGHLIGHT_COLOR,
    4292                 :             :    or "type-diff" if the latter is NULL.  */
    4293                 :             : 
    4294                 :             : static void
    4295                 :         624 : print_nonequal_arg (pretty_printer *pp, tree arg, bool verbose,
    4296                 :             :                     const char *highlight_color)
    4297                 :             : {
    4298                 :         624 :   if (!highlight_color)
    4299                 :          10 :     highlight_color = "type-diff";
    4300                 :        1248 :   pp_printf (pp, "%r%s%R",
    4301                 :             :              highlight_color,
    4302                 :             :              (arg
    4303                 :         624 :               ? arg_to_string (arg, verbose)
    4304                 :             :               : G_("(no argument)")));
    4305                 :         624 : }
    4306                 :             : 
    4307                 :             : /* Recursively print template TYPE_A to PP, as compared to template TYPE_B.
    4308                 :             : 
    4309                 :             :    The types must satisfy comparable_template_types_p.
    4310                 :             : 
    4311                 :             :    If INDENT is 0, then this is equivalent to type_to_string (TYPE_A), but
    4312                 :             :    potentially colorizing/eliding in comparison with TYPE_B.
    4313                 :             : 
    4314                 :             :    For example given types:
    4315                 :             :      vector<map<int,double>>
    4316                 :             :    and
    4317                 :             :      vector<map<int,float>>
    4318                 :             :    then the result on PP would be:
    4319                 :             :      vector<map<[...],double>>
    4320                 :             :    with type elision, and:
    4321                 :             :      vector<map<int,double>>
    4322                 :             :    without type elision.
    4323                 :             : 
    4324                 :             :    In both cases the parts of TYPE that differ from PEER will be colorized
    4325                 :             :    if pp_show_color (pp) is true.  In the above example, this would be
    4326                 :             :    "double".
    4327                 :             : 
    4328                 :             :    If INDENT is non-zero, then the types are printed in a tree-like form
    4329                 :             :    which shows both types.  In the above example, the result on PP would be:
    4330                 :             : 
    4331                 :             :      vector<
    4332                 :             :        map<
    4333                 :             :          [...],
    4334                 :             :          [double != float]>>
    4335                 :             : 
    4336                 :             :    and without type-elision would be:
    4337                 :             : 
    4338                 :             :      vector<
    4339                 :             :        map<
    4340                 :             :          int,
    4341                 :             :          [double != float]>>
    4342                 :             : 
    4343                 :             :    As before, the differing parts of the types are colorized if
    4344                 :             :    pp_show_color (pp) is true ("double" and "float" in this example).
    4345                 :             : 
    4346                 :             :    Template arguments in which both types are using the default arguments
    4347                 :             :    are not printed; if at least one of the two types is using a non-default
    4348                 :             :    argument, then that argument is printed (or both arguments for the
    4349                 :             :    tree-like print format).  */
    4350                 :             : 
    4351                 :             : static void
    4352                 :         449 : print_template_differences (pretty_printer *pp, tree type_a, tree type_b,
    4353                 :             :                             bool verbose, int indent,
    4354                 :             :                             const char *highlight_color_a,
    4355                 :             :                             const char *highlight_color_b)
    4356                 :             : {
    4357                 :         449 :   if (indent)
    4358                 :          85 :     newline_and_indent (pp, indent);
    4359                 :             : 
    4360                 :         449 :   tree tinfo_a = TYPE_TEMPLATE_INFO (type_a);
    4361                 :         449 :   tree tinfo_b = TYPE_TEMPLATE_INFO (type_b);
    4362                 :             : 
    4363                 :         449 :   pp_printf (pp, "%s<",
    4364                 :         449 :              IDENTIFIER_POINTER (DECL_NAME (TI_TEMPLATE (tinfo_a))));
    4365                 :             : 
    4366                 :         449 :   tree args_a = TI_ARGS (tinfo_a);
    4367                 :         449 :   tree args_b = TI_ARGS (tinfo_b);
    4368                 :         449 :   gcc_assert (TREE_CODE (args_a) == TREE_VEC);
    4369                 :         449 :   gcc_assert (TREE_CODE (args_b) == TREE_VEC);
    4370                 :         449 :   int flags = 0;
    4371                 :         449 :   int len_a = get_non_default_template_args_count (args_a, flags);
    4372                 :         449 :   args_a = INNERMOST_TEMPLATE_ARGS (args_a);
    4373                 :         449 :   int len_b = get_non_default_template_args_count (args_b, flags);
    4374                 :         449 :   args_b = INNERMOST_TEMPLATE_ARGS (args_b);
    4375                 :             :   /* Determine the maximum range of args for which non-default template args
    4376                 :             :      were used; beyond this, only default args (if any) were used, and so
    4377                 :             :      they will be equal from this point onwards.
    4378                 :             :      One of the two peers might have used default arguments within this
    4379                 :             :      range, but the other will be using non-default arguments, and so
    4380                 :             :      it's more readable to print both within this range, to highlight
    4381                 :             :      the differences.  */
    4382                 :         449 :   int len_max = MAX (len_a, len_b);
    4383                 :         449 :   gcc_assert (TREE_CODE (args_a) == TREE_VEC);
    4384                 :         449 :   gcc_assert (TREE_CODE (args_b) == TREE_VEC);
    4385                 :        1132 :   for (int idx = 0; idx < len_max; idx++)
    4386                 :             :     {
    4387                 :         683 :       if (idx)
    4388                 :         234 :         pp_character (pp, ',');
    4389                 :             : 
    4390                 :         683 :       tree arg_a = TREE_VEC_ELT (args_a, idx);
    4391                 :         683 :       tree arg_b = TREE_VEC_ELT (args_b, idx);
    4392                 :         683 :       if (arg_a == arg_b)
    4393                 :             :         {
    4394                 :         130 :           if (indent)
    4395                 :          39 :             newline_and_indent (pp, indent + 2);
    4396                 :             :           /* Can do elision here, printing "[...]".  */
    4397                 :         130 :           if (flag_elide_type)
    4398                 :         118 :             pp_string (pp, G_("[...]"));
    4399                 :             :           else
    4400                 :          12 :             pp_string (pp, arg_to_string (arg_a, verbose));
    4401                 :             :         }
    4402                 :             :       else
    4403                 :             :         {
    4404                 :         553 :           int new_indent = indent ? indent + 2 : 0;
    4405                 :         553 :           if (comparable_template_types_p (arg_a, arg_b))
    4406                 :          33 :             print_template_differences (pp, arg_a, arg_b, verbose, new_indent,
    4407                 :             :                                         highlight_color_a, highlight_color_b);
    4408                 :             :           else
    4409                 :         520 :             if (indent)
    4410                 :             :               {
    4411                 :         104 :                 newline_and_indent (pp, indent + 2);
    4412                 :         104 :                 pp_character (pp, '[');
    4413                 :         104 :                 print_nonequal_arg (pp, arg_a, verbose, highlight_color_a);
    4414                 :         104 :                 pp_string (pp, " != ");
    4415                 :         104 :                 print_nonequal_arg (pp, arg_b, verbose, highlight_color_b);
    4416                 :         104 :                 pp_character (pp, ']');
    4417                 :             :               }
    4418                 :             :             else
    4419                 :         416 :               print_nonequal_arg (pp, arg_a, verbose, highlight_color_a);
    4420                 :             :         }
    4421                 :             :     }
    4422                 :         449 :   pp_printf (pp, ">");
    4423                 :         449 : }
    4424                 :             : 
    4425                 :             : /* As type_to_string, but for a template, potentially colorizing/eliding
    4426                 :             :    in comparison with PEER.
    4427                 :             :    For example, if TYPE is map<int,double> and PEER is map<int,int>,
    4428                 :             :    then the resulting string would be:
    4429                 :             :      map<[...],double>
    4430                 :             :    with type elision, and:
    4431                 :             :      map<int,double>
    4432                 :             :    without type elision.
    4433                 :             : 
    4434                 :             :    In both cases the parts of TYPE that differ from PEER will be colorized
    4435                 :             :    if SHOW_COLOR is true.  In the above example, this would be "double".
    4436                 :             : 
    4437                 :             :    Template arguments in which both types are using the default arguments
    4438                 :             :    are not printed; if at least one of the two types is using a non-default
    4439                 :             :    argument, then both arguments are printed.
    4440                 :             : 
    4441                 :             :    The resulting string is in a GC-allocated buffer.  */
    4442                 :             : 
    4443                 :             : static const char *
    4444                 :         342 : type_to_string_with_compare (tree type, tree peer, bool verbose,
    4445                 :             :                              bool show_color,
    4446                 :             :                              const char *this_highlight_color,
    4447                 :             :                              const char *peer_highlight_color)
    4448                 :             : {
    4449                 :         342 :   pretty_printer inner_pp;
    4450                 :         342 :   pretty_printer *pp = &inner_pp;
    4451                 :         342 :   pp_show_color (pp) = show_color;
    4452                 :             : 
    4453                 :         342 :   print_template_differences (pp, type, peer, verbose, 0,
    4454                 :             :                               this_highlight_color, peer_highlight_color);
    4455                 :         342 :   return pp_ggc_formatted_text (pp);
    4456                 :         342 : }
    4457                 :             : 
    4458                 :             : /* Recursively print a tree-like comparison of TYPE_A and TYPE_B to PP,
    4459                 :             :    indented by INDENT spaces.
    4460                 :             : 
    4461                 :             :    For example given types:
    4462                 :             : 
    4463                 :             :      vector<map<int,double>>
    4464                 :             : 
    4465                 :             :    and
    4466                 :             : 
    4467                 :             :      vector<map<double,float>>
    4468                 :             : 
    4469                 :             :    the output with type elision would be:
    4470                 :             : 
    4471                 :             :      vector<
    4472                 :             :        map<
    4473                 :             :          [...],
    4474                 :             :          [double != float]>>
    4475                 :             : 
    4476                 :             :    and without type-elision would be:
    4477                 :             : 
    4478                 :             :      vector<
    4479                 :             :        map<
    4480                 :             :          int,
    4481                 :             :          [double != float]>>
    4482                 :             : 
    4483                 :             :    TYPE_A and TYPE_B must both be comparable template types
    4484                 :             :    (as per comparable_template_types_p).
    4485                 :             : 
    4486                 :             :    Template arguments in which both types are using the default arguments
    4487                 :             :    are not printed; if at least one of the two types is using a non-default
    4488                 :             :    argument, then both arguments are printed.  */
    4489                 :             : 
    4490                 :             : static void
    4491                 :          74 : print_template_tree_comparison (pretty_printer *pp, tree type_a, tree type_b,
    4492                 :             :                                 bool verbose, int indent,
    4493                 :             :                                 const char *highlight_color_a,
    4494                 :             :                                 const char *highlight_color_b)
    4495                 :             : {
    4496                 :           0 :   print_template_differences (pp, type_a, type_b, verbose, indent,
    4497                 :             :                               highlight_color_a,
    4498                 :             :                               highlight_color_b);
    4499                 :           0 : }
    4500                 :             : 
    4501                 :             : /* Subroutine for use in a format_postprocessor::handle
    4502                 :             :    implementation.  Adds a chunk to the end of
    4503                 :             :    formatted output, so that it will be printed
    4504                 :             :    by pp_output_formatted_text.  */
    4505                 :             : 
    4506                 :             : static void
    4507                 :          74 : append_formatted_chunk (pretty_printer *pp, const char *content)
    4508                 :             : {
    4509                 :          74 :   output_buffer *buffer = pp_buffer (pp);
    4510                 :          74 :   pp_formatted_chunks *chunk_array = buffer->m_cur_formatted_chunks;
    4511                 :           0 :   chunk_array->append_formatted_chunk (buffer->m_chunk_obstack, content);
    4512                 :           0 : }
    4513                 :             : 
    4514                 :             : #if __GNUC__ >= 10
    4515                 :             : #pragma GCC diagnostic pop
    4516                 :             : #endif
    4517                 :             : 
    4518                 :             : /* If we had %H and %I, and hence deferred printing them,
    4519                 :             :    print them now, storing the result into custom_token_value
    4520                 :             :    for the custom pp_token.  Quote them if 'q' was provided.
    4521                 :             :    Also print the difference in tree form, adding it as
    4522                 :             :    an additional chunk.  */
    4523                 :             : 
    4524                 :             : void
    4525                 :      311998 : cxx_format_postprocessor::handle (pretty_printer *pp)
    4526                 :             : {
    4527                 :             :   /* If we have one of %H and %I, the other should have
    4528                 :             :      been present.  */
    4529                 :      311998 :   if (m_type_a.m_tree || m_type_b.m_tree)
    4530                 :             :     {
    4531                 :       10482 :       const bool show_highlight_colors = pp_show_highlight_colors (pp);
    4532                 :       20966 :       const char *percent_h
    4533                 :       10482 :         = show_highlight_colors ? highlight_colors::percent_h : nullptr;
    4534                 :           2 :       const char *percent_i
    4535                 :             :         = show_highlight_colors ? highlight_colors::percent_i : nullptr;
    4536                 :             :       /* Avoid reentrancy issues by working with a copy of
    4537                 :             :          m_type_a and m_type_b, resetting them now.  */
    4538                 :       10482 :       deferred_printed_type type_a = std::move (m_type_a);
    4539                 :       10482 :       deferred_printed_type type_b = std::move (m_type_b);
    4540                 :       10482 :       m_type_a = deferred_printed_type ();
    4541                 :       10482 :       m_type_b = deferred_printed_type ();
    4542                 :             : 
    4543                 :       10482 :       gcc_assert (type_a.m_token_list);
    4544                 :       10482 :       gcc_assert (type_b.m_token_list);
    4545                 :             : 
    4546                 :       10482 :       bool show_color = pp_show_color (pp);
    4547                 :             : 
    4548                 :       10482 :       const char *type_a_text;
    4549                 :       10482 :       const char *type_b_text;
    4550                 :             : 
    4551                 :       10482 :       if (comparable_template_types_p (type_a.m_tree, type_b.m_tree))
    4552                 :             :         {
    4553                 :         170 :           type_a_text = type_to_string_with_compare
    4554                 :         170 :             (type_a.m_tree, type_b.m_tree,
    4555                 :             :              type_a.m_verbose, show_color,
    4556                 :             :              percent_h, percent_i);
    4557                 :         170 :           type_b_text = type_to_string_with_compare
    4558                 :         170 :             (type_b.m_tree, type_a.m_tree,
    4559                 :             :              type_b.m_verbose, show_color,
    4560                 :             :              percent_i, percent_h);
    4561                 :             : 
    4562                 :         170 :           if (flag_diagnostics_show_template_tree)
    4563                 :             :             {
    4564                 :          74 :               pretty_printer inner_pp;
    4565                 :          74 :               pp_show_color (&inner_pp) = pp_show_color (pp);
    4566                 :          74 :               print_template_tree_comparison
    4567                 :          74 :                 (&inner_pp, type_a.m_tree, type_b.m_tree, type_a.m_verbose, 2,
    4568                 :             :                  percent_h, percent_i);
    4569                 :          74 :               append_formatted_chunk (pp, pp_ggc_formatted_text (&inner_pp));
    4570                 :          74 :             }
    4571                 :             :         }
    4572                 :             :       else
    4573                 :             :         {
    4574                 :             :           /* If the types were not comparable (or if only one of %H/%I was
    4575                 :             :              provided), they are printed normally, and no difference tree
    4576                 :             :              is printed.  */
    4577                 :       10312 :           type_a_text = type_to_string (type_a.m_tree, type_a.m_verbose,
    4578                 :             :                                         true, &type_a.m_quote, show_color,
    4579                 :             :                                         percent_h);
    4580                 :       10312 :           type_b_text = type_to_string (type_b.m_tree, type_b.m_verbose,
    4581                 :             :                                         true, &type_b.m_quote, show_color,
    4582                 :             :                                         percent_i);
    4583                 :             :         }
    4584                 :             : 
    4585                 :       10482 :       type_a.set_text_for_token_list (type_a_text, type_a.m_quote);
    4586                 :       10482 :       type_b.set_text_for_token_list (type_b_text, type_b.m_quote);
    4587                 :       10482 :    }
    4588                 :      311998 : }
    4589                 :             : 
    4590                 :             : /* Subroutine for handling %H and %I, to support i18n of messages like:
    4591                 :             : 
    4592                 :             :     error_at (loc, "could not convert %qE from %qH to %qI",
    4593                 :             :                expr, type_a, type_b);
    4594                 :             : 
    4595                 :             :    so that we can print things like:
    4596                 :             : 
    4597                 :             :      could not convert 'foo' from 'map<int,double>' to 'map<int,int>'
    4598                 :             : 
    4599                 :             :    and, with type-elision:
    4600                 :             : 
    4601                 :             :      could not convert 'foo' from 'map<[...],double>' to 'map<[...],int>'
    4602                 :             : 
    4603                 :             :    (with color-coding of the differences between the types).
    4604                 :             : 
    4605                 :             :    The %H and %I format codes are peers: both must be present,
    4606                 :             :    and they affect each other.  Hence to handle them, we must
    4607                 :             :    delay printing until we have both, deferring the printing to
    4608                 :             :    pretty_printer's m_format_postprocessor hook.
    4609                 :             : 
    4610                 :             :    This is called in phase 2 of pp_format, when it is accumulating
    4611                 :             :    a series of pp_token lists.  Since we have to interact with the
    4612                 :             :    fiddly quoting logic for "aka", we store the pp_token_list *
    4613                 :             :    and in the m_format_postprocessor hook we generate text for the type
    4614                 :             :    (possibly with quotes and colors), then replace all tokens in that token list
    4615                 :             :    (such as [BEGIN_QUOTE, END_QUOTE]) with a text token containing the
    4616                 :             :    freshly generated text.
    4617                 :             : 
    4618                 :             :    We also need to stash whether a 'q' prefix was provided (the QUOTE
    4619                 :             :    param)  so that we can add the quotes when writing out the delayed
    4620                 :             :    chunk.  */
    4621                 :             : 
    4622                 :             : static void
    4623                 :       20964 : defer_phase_2_of_type_diff (deferred_printed_type *deferred,
    4624                 :             :                             tree type,
    4625                 :             :                             pp_token_list &formatted_token_list,
    4626                 :             :                             bool verbose, bool quote)
    4627                 :             : {
    4628                 :       20964 :   gcc_assert (deferred->m_tree == NULL_TREE);
    4629                 :       41928 :   *deferred = deferred_printed_type (type, formatted_token_list,
    4630                 :       20964 :                                      verbose, quote);
    4631                 :       20964 : }
    4632                 :             : 
    4633                 :             : /* Implementation of pp_markup::element_quoted_type::print_type
    4634                 :             :    for C++/ObjC++.  */
    4635                 :             : 
    4636                 :             : void
    4637                 :         818 : pp_markup::element_quoted_type::print_type (pp_markup::context &ctxt)
    4638                 :             : {
    4639                 :         818 :   const char *highlight_color
    4640                 :         818 :     = pp_show_highlight_colors (&ctxt.m_pp) ? m_highlight_color : nullptr;
    4641                 :         818 :   const char *result
    4642                 :        1636 :     = type_to_string (m_type, false, false, &ctxt.m_quoted,
    4643                 :         818 :                       pp_show_color (&ctxt.m_pp), highlight_color);
    4644                 :         818 :   pp_string (&ctxt.m_pp, result);
    4645                 :         818 : }
    4646                 :             : 
    4647                 :             : /* Called from output_format -- during diagnostic message processing --
    4648                 :             :    to handle C++ specific format specifier with the following meanings:
    4649                 :             :    %A   function argument-list.
    4650                 :             :    %C   tree code.
    4651                 :             :    %D   declaration.
    4652                 :             :    %E   expression.
    4653                 :             :    %F   function declaration.
    4654                 :             :    %H   type difference (from).
    4655                 :             :    %I   type difference (to).
    4656                 :             :    %L   language as used in extern "lang".
    4657                 :             :    %O   binary operator.
    4658                 :             :    %P   function parameter whose position is indicated by an integer.
    4659                 :             :    %Q   assignment operator.
    4660                 :             :    %S   substitution (template + args)
    4661                 :             :    %T   type.
    4662                 :             :    %V   cv-qualifier.
    4663                 :             :    %X   exception-specification.  */
    4664                 :             : static bool
    4665                 :      210755 : cp_printer (pretty_printer *pp, text_info *text, const char *spec,
    4666                 :             :             int precision, bool wide, bool set_locus, bool verbose,
    4667                 :             :             bool *quoted, pp_token_list &formatted_token_list)
    4668                 :             : {
    4669                 :      210755 :   gcc_assert (pp_format_postprocessor (pp));
    4670                 :      210755 :   cxx_format_postprocessor *postprocessor
    4671                 :      210755 :     = static_cast <cxx_format_postprocessor *> (pp_format_postprocessor (pp));
    4672                 :             : 
    4673                 :      210755 :   const char *result;
    4674                 :      210755 :   tree t = NULL;
    4675                 :             : #define next_tree    (t = va_arg (*text->m_args_ptr, tree))
    4676                 :             : #define next_tcode   ((enum tree_code) va_arg (*text->m_args_ptr, int))
    4677                 :             : #define next_lang    ((enum languages) va_arg (*text->m_args_ptr, int))
    4678                 :             : #define next_int     va_arg (*text->m_args_ptr, int)
    4679                 :             : 
    4680                 :      210755 :   if (precision != 0 || wide)
    4681                 :             :     return false;
    4682                 :             : 
    4683                 :      210755 :   switch (*spec)
    4684                 :             :     {
    4685                 :        3755 :     case 'A': result = args_to_string (next_tree, verbose);     break;
    4686                 :           2 :     case 'C': result = code_to_string (next_tcode);             break;
    4687                 :       94224 :     case 'D':
    4688                 :       94224 :       {
    4689                 :       94224 :         tree temp = next_tree;
    4690                 :       94224 :         if (VAR_P (temp)
    4691                 :       94224 :             && DECL_HAS_DEBUG_EXPR_P (temp))
    4692                 :             :           {
    4693                 :          32 :             temp = DECL_DEBUG_EXPR (temp);
    4694                 :          32 :             if (!DECL_P (temp))
    4695                 :             :               {
    4696                 :          32 :                 result = expr_to_string (temp);
    4697                 :          32 :                 break;
    4698                 :             :               }
    4699                 :             :           }
    4700                 :       94192 :         result = decl_to_string (temp, verbose, pp_show_color (pp));
    4701                 :             :       }
    4702                 :       94192 :       break;
    4703                 :       47789 :     case 'E': result = expr_to_string (next_tree);              break;
    4704                 :         349 :     case 'F': result = fndecl_to_string (next_tree, verbose);   break;
    4705                 :       10482 :     case 'H':
    4706                 :       20964 :       defer_phase_2_of_type_diff (&postprocessor->m_type_a, next_tree,
    4707                 :       10482 :                                   formatted_token_list, verbose, *quoted);
    4708                 :       10482 :       return true;
    4709                 :       10482 :     case 'I':
    4710                 :       20964 :       defer_phase_2_of_type_diff (&postprocessor->m_type_b, next_tree,
    4711                 :       10482 :                                   formatted_token_list, verbose, *quoted);
    4712                 :       10482 :       return true;
    4713                 :          12 :     case 'L': result = language_to_string (next_lang);          break;
    4714                 :         293 :     case 'O': result = op_to_string (false, next_tcode);        break;
    4715                 :        1488 :     case 'P': result = parm_to_string (next_int);               break;
    4716                 :          24 :     case 'Q': result = op_to_string (true, next_tcode);         break;
    4717                 :        1520 :     case 'S': result = subst_to_string (next_tree, pp_show_color (pp)); break;
    4718                 :       39762 :     case 'T':
    4719                 :       39762 :       {
    4720                 :       79524 :         result = type_to_string (next_tree, verbose, false, quoted,
    4721                 :       39762 :                                  pp_show_color (pp));
    4722                 :             :       }
    4723                 :       39762 :       break;
    4724                 :         573 :     case 'V': result = cv_to_string (next_tree, verbose);       break;
    4725                 :           0 :     case 'X': result = eh_spec_to_string (next_tree, verbose);  break;
    4726                 :             : 
    4727                 :             :     default:
    4728                 :             :       return false;
    4729                 :             :     }
    4730                 :             : 
    4731                 :      189791 :   pp_string (pp, result);
    4732                 :      189791 :   if (set_locus && t != NULL)
    4733                 :        1668 :     text->set_location (0, location_of (t), SHOW_RANGE_WITH_CARET);
    4734                 :             :   return true;
    4735                 :             : #undef next_tree
    4736                 :             : #undef next_tcode
    4737                 :             : #undef next_lang
    4738                 :             : #undef next_int
    4739                 :             : }
    4740                 :             : 
    4741                 :             : /* Warn about the use of C++0x features when appropriate.  */
    4742                 :             : void
    4743                 :    57196083 : maybe_warn_cpp0x (cpp0x_warn_str str, location_t loc/*=input_location*/)
    4744                 :             : {
    4745                 :    57196083 :   if (cxx_dialect == cxx98)
    4746                 :        4030 :     switch (str)
    4747                 :             :       {
    4748                 :         174 :       case CPP0X_INITIALIZER_LISTS:
    4749                 :         174 :         pedwarn (loc, OPT_Wc__11_extensions,
    4750                 :             :                  "extended initializer lists "
    4751                 :             :                  "only available with %<-std=c++11%> or %<-std=gnu++11%>");
    4752                 :         174 :         break;
    4753                 :           0 :       case CPP0X_EXPLICIT_CONVERSION:
    4754                 :           0 :         pedwarn (loc, OPT_Wc__11_extensions,
    4755                 :             :                  "explicit conversion operators "
    4756                 :             :                  "only available with %<-std=c++11%> or %<-std=gnu++11%>");
    4757                 :           0 :         break;
    4758                 :        1390 :       case CPP0X_VARIADIC_TEMPLATES:
    4759                 :        1390 :         pedwarn (loc, OPT_Wc__11_extensions,
    4760                 :             :                  "variadic templates "
    4761                 :             :                  "only available with %<-std=c++11%> or %<-std=gnu++11%>");
    4762                 :        1390 :         break;
    4763                 :           6 :       case CPP0X_LAMBDA_EXPR:
    4764                 :           6 :         pedwarn (loc, OPT_Wc__11_extensions,
    4765                 :             :                  "lambda expressions "
    4766                 :             :                   "only available with %<-std=c++11%> or %<-std=gnu++11%>");
    4767                 :           6 :         break;
    4768                 :           0 :       case CPP0X_AUTO:
    4769                 :           0 :         pedwarn (loc, OPT_Wc__11_extensions,
    4770                 :             :                  "C++11 auto only available with %<-std=c++11%> or "
    4771                 :             :                  "%<-std=gnu++11%>");
    4772                 :           0 :         break;
    4773                 :          15 :       case CPP0X_SCOPED_ENUMS:
    4774                 :          15 :         pedwarn (loc, OPT_Wc__11_extensions,
    4775                 :             :                  "scoped enums only available with %<-std=c++11%> or "
    4776                 :             :                  "%<-std=gnu++11%>");
    4777                 :          15 :         break;
    4778                 :         431 :       case CPP0X_DEFAULTED_DELETED:
    4779                 :         431 :         pedwarn (loc, OPT_Wc__11_extensions,
    4780                 :             :                  "defaulted and deleted functions "
    4781                 :             :                  "only available with %<-std=c++11%> or %<-std=gnu++11%>");
    4782                 :         431 :         break;
    4783                 :        1777 :       case CPP0X_INLINE_NAMESPACES:
    4784                 :        1777 :         if (pedantic)
    4785                 :         573 :           pedwarn (loc, OPT_Wc__11_extensions,
    4786                 :             :                    "inline namespaces "
    4787                 :             :                    "only available with %<-std=c++11%> or %<-std=gnu++11%>");
    4788                 :             :         break;
    4789                 :           3 :       case CPP0X_OVERRIDE_CONTROLS:
    4790                 :           3 :         pedwarn (loc, OPT_Wc__11_extensions,
    4791                 :             :                  "override controls (override/final) "
    4792                 :             :                  "only available with %<-std=c++11%> or %<-std=gnu++11%>");
    4793                 :           3 :         break;
    4794                 :         129 :       case CPP0X_NSDMI:
    4795                 :         129 :         pedwarn (loc, OPT_Wc__11_extensions,
    4796                 :             :                  "non-static data member initializers "
    4797                 :             :                  "only available with %<-std=c++11%> or %<-std=gnu++11%>");
    4798                 :         129 :         break;
    4799                 :           4 :       case CPP0X_USER_DEFINED_LITERALS:
    4800                 :           4 :         pedwarn (loc, OPT_Wc__11_extensions,
    4801                 :             :                  "user-defined literals "
    4802                 :             :                  "only available with %<-std=c++11%> or %<-std=gnu++11%>");
    4803                 :           4 :         break;
    4804                 :           3 :       case CPP0X_DELEGATING_CTORS:
    4805                 :           3 :         pedwarn (loc, OPT_Wc__11_extensions,
    4806                 :             :                  "delegating constructors "
    4807                 :             :                  "only available with %<-std=c++11%> or %<-std=gnu++11%>");
    4808                 :           3 :         break;
    4809                 :           3 :       case CPP0X_INHERITING_CTORS:
    4810                 :           3 :         pedwarn (loc, OPT_Wc__11_extensions,
    4811                 :             :                  "inheriting constructors "
    4812                 :             :                  "only available with %<-std=c++11%> or %<-std=gnu++11%>");
    4813                 :           3 :         break;
    4814                 :          95 :       case CPP0X_ATTRIBUTES:
    4815                 :          95 :         if (pedantic)
    4816                 :          24 :           pedwarn (loc, OPT_Wc__11_extensions,
    4817                 :             :                    "C++11 attributes "
    4818                 :             :                    "only available with %<-std=c++11%> or %<-std=gnu++11%>");
    4819                 :             :         break;
    4820                 :           0 :       case CPP0X_REF_QUALIFIER:
    4821                 :           0 :         pedwarn (loc, OPT_Wc__11_extensions,
    4822                 :             :                  "ref-qualifiers "
    4823                 :             :                  "only available with %<-std=c++11%> or %<-std=gnu++11%>");
    4824                 :           0 :         break;
    4825                 :           0 :       default:
    4826                 :           0 :         gcc_unreachable ();
    4827                 :             :       }
    4828                 :    57196083 : }
    4829                 :             : 
    4830                 :             : /* Warn about the use of variadic templates when appropriate.  */
    4831                 :             : void
    4832                 :    13381037 : maybe_warn_variadic_templates (void)
    4833                 :             : {
    4834                 :    13381037 :   maybe_warn_cpp0x (CPP0X_VARIADIC_TEMPLATES);
    4835                 :    13381037 : }
    4836                 :             : 
    4837                 :             : 
    4838                 :             : /* Issue an ISO C++98 pedantic warning at LOCATION, conditional on
    4839                 :             :    option OPTION_ID with text GMSGID.  Use this function to report
    4840                 :             :    diagnostics for constructs that are invalid C++98, but valid
    4841                 :             :    C++0x.  */
    4842                 :             : bool
    4843                 :     2951040 : pedwarn_cxx98 (location_t location,
    4844                 :             :                diagnostic_option_id option_id,
    4845                 :             :                const char *gmsgid, ...)
    4846                 :             : {
    4847                 :     2951040 :   diagnostic_info diagnostic;
    4848                 :     2951040 :   va_list ap;
    4849                 :     2951040 :   bool ret;
    4850                 :     2951040 :   rich_location richloc (line_table, location);
    4851                 :             : 
    4852                 :     2951040 :   va_start (ap, gmsgid);
    4853                 :     2951040 :   diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc,
    4854                 :     2951040 :                        (cxx_dialect == cxx98) ? DK_PEDWARN : DK_WARNING);
    4855                 :     2951040 :   diagnostic.option_id = option_id;
    4856                 :     2951040 :   ret = diagnostic_report_diagnostic (global_dc, &diagnostic);
    4857                 :     2951040 :   va_end (ap);
    4858                 :     5902080 :   return ret;
    4859                 :     2951040 : }
    4860                 :             : 
    4861                 :             : /* Issue a diagnostic that NAME cannot be found in SCOPE.  DECL is what
    4862                 :             :    we found when we tried to do the lookup.  LOCATION is the location of
    4863                 :             :    the NAME identifier.  */
    4864                 :             : 
    4865                 :             : void
    4866                 :         519 : qualified_name_lookup_error (tree scope, tree name,
    4867                 :             :                              tree decl, location_t location)
    4868                 :             : {
    4869                 :         519 :   if (scope == error_mark_node)
    4870                 :             :     ; /* We already complained.  */
    4871                 :         408 :   else if (TYPE_P (scope))
    4872                 :             :     {
    4873                 :         219 :       if (!COMPLETE_TYPE_P (scope)
    4874                 :         219 :           && !currently_open_class (scope))
    4875                 :          41 :         error_at (location, "incomplete type %qT used in nested name specifier",
    4876                 :             :                   scope);
    4877                 :         178 :       else if (TREE_CODE (decl) == TREE_LIST)
    4878                 :             :         {
    4879                 :           0 :           auto_diagnostic_group d;
    4880                 :           0 :           error_at (location, "reference to %<%T::%D%> is ambiguous",
    4881                 :             :                     scope, name);
    4882                 :           0 :           print_candidates (decl);
    4883                 :           0 :         }
    4884                 :             :       else
    4885                 :             :         {
    4886                 :         178 :           auto_diagnostic_group d;
    4887                 :         178 :           name_hint hint;
    4888                 :         178 :           if (SCOPED_ENUM_P (scope) && TREE_CODE (name) == IDENTIFIER_NODE)
    4889                 :          15 :             hint = suggest_alternative_in_scoped_enum (name, scope);
    4890                 :         178 :           if (const char *suggestion = hint.suggestion ())
    4891                 :             :             {
    4892                 :           9 :               gcc_rich_location richloc (location);
    4893                 :           9 :               richloc.add_fixit_replace (suggestion);
    4894                 :           9 :               error_at (&richloc,
    4895                 :             :                         "%qD is not a member of %qT; did you mean %qs?",
    4896                 :             :                         name, scope, suggestion);
    4897                 :           9 :             }
    4898                 :             :           else
    4899                 :         169 :             error_at (location, "%qD is not a member of %qT", name, scope);
    4900                 :         178 :         }
    4901                 :             :     }
    4902                 :         189 :   else if (scope != global_namespace)
    4903                 :             :     {
    4904                 :         169 :       auto_diagnostic_group d;
    4905                 :         169 :       bool emit_fixit = true;
    4906                 :         169 :       name_hint hint
    4907                 :         169 :         = suggest_alternative_in_explicit_scope (location, name, scope);
    4908                 :         169 :       if (!hint)
    4909                 :             :         {
    4910                 :          54 :           hint = suggest_alternatives_in_other_namespaces (location, name);
    4911                 :             :           /* "location" is just the location of the name, not of the explicit
    4912                 :             :              scope, and it's not easy to get at the latter, so we can't issue
    4913                 :             :              fix-it hints for the suggestion.  */
    4914                 :          54 :           emit_fixit = false;
    4915                 :             :         }
    4916                 :         169 :       if (const char *suggestion = hint.suggestion ())
    4917                 :             :         {
    4918                 :          54 :           gcc_rich_location richloc (location);
    4919                 :          54 :           if (emit_fixit)
    4920                 :          33 :             richloc.add_fixit_replace (suggestion);
    4921                 :          54 :           error_at (&richloc, "%qD is not a member of %qD; did you mean %qs?",
    4922                 :             :                     name, scope, suggestion);
    4923                 :          54 :         }
    4924                 :             :       else
    4925                 :         115 :         error_at (location, "%qD is not a member of %qD", name, scope);
    4926                 :         169 :     }
    4927                 :             :   else
    4928                 :             :     {
    4929                 :          20 :       auto_diagnostic_group d;
    4930                 :          20 :       name_hint hint = suggest_alternatives_for (location, name, true);
    4931                 :          20 :       if (const char *suggestion = hint.suggestion ())
    4932                 :             :         {
    4933                 :          11 :           gcc_rich_location richloc (location);
    4934                 :          11 :           richloc.add_fixit_replace (suggestion);
    4935                 :          11 :           error_at (&richloc,
    4936                 :             :                     "%<::%D%> has not been declared; did you mean %qs?",
    4937                 :             :                     name, suggestion);
    4938                 :          11 :         }
    4939                 :             :       else
    4940                 :           9 :         error_at (location, "%<::%D%> has not been declared", name);
    4941                 :          20 :     }
    4942                 :         519 : }
    4943                 :             : 
    4944                 :             : /* C++-specific implementation of range_label::get_text () vfunc for
    4945                 :             :    range_label_for_type_mismatch.
    4946                 :             : 
    4947                 :             :    Compare with print_template_differences above.  */
    4948                 :             : 
    4949                 :             : label_text
    4950                 :         623 : range_label_for_type_mismatch::get_text (unsigned /*range_idx*/) const
    4951                 :             : {
    4952                 :         623 :   if (m_labelled_type == NULL_TREE)
    4953                 :           0 :     return label_text::borrow (NULL);
    4954                 :             : 
    4955                 :         623 :   const bool verbose = false;
    4956                 :         623 :   const bool show_color = false;
    4957                 :             : 
    4958                 :         623 :   const char *result;
    4959                 :         623 :   if (m_other_type
    4960                 :         623 :       && comparable_template_types_p (m_labelled_type, m_other_type))
    4961                 :           2 :     result = type_to_string_with_compare (m_labelled_type, m_other_type,
    4962                 :             :                                           verbose, show_color,
    4963                 :             :                                           nullptr, nullptr);
    4964                 :             :   else
    4965                 :         621 :     result = type_to_string (m_labelled_type, verbose, true, NULL, show_color);
    4966                 :             : 
    4967                 :             :   /* Both of the above return GC-allocated buffers, so the caller mustn't
    4968                 :             :      free them.  */
    4969                 :         623 :   return label_text::borrow (result);
    4970                 :             : }
        

Generated by: LCOV version 2.1-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.