LCOV - code coverage report
Current view: top level - gcc/c-family - c-pretty-print.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 77.9 % 1680 1308
Test Date: 2026-11-14 16:39:50 Functions: 88.4 % 86 76
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Subroutines common to both C and C++ pretty-printers.
       2              :    Copyright (C) 2002-2026 Free Software Foundation, Inc.
       3              :    Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
       4              : 
       5              : This file is part of GCC.
       6              : 
       7              : GCC is free software; you can redistribute it and/or modify it under
       8              : the terms of the GNU General Public License as published by the Free
       9              : Software Foundation; either version 3, or (at your option) any later
      10              : version.
      11              : 
      12              : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      13              : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      14              : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      15              : for more details.
      16              : 
      17              : You should have received a copy of the GNU General Public License
      18              : along with GCC; see the file COPYING3.  If not see
      19              : <http://www.gnu.org/licenses/>.  */
      20              : 
      21              : #include "config.h"
      22              : #include "system.h"
      23              : #include "coretypes.h"
      24              : #include "c-pretty-print.h"
      25              : #include "gimple-pretty-print.h"
      26              : #include "diagnostic.h"
      27              : #include "stor-layout.h"
      28              : #include "stringpool.h"
      29              : #include "attribs.h"
      30              : #include "intl.h"
      31              : #include "tree-pretty-print.h"
      32              : #include "selftest.h"
      33              : #include "langhooks.h"
      34              : #include "options.h"
      35              : #include "internal-fn.h"
      36              : #include "function.h"
      37              : #include "basic-block.h"
      38              : #include "gimple.h"
      39              : #include "tm.h"
      40              : 
      41              : /* The pretty-printer code is primarily designed to closely follow
      42              :    (GNU) C and C++ grammars.  That is to be contrasted with spaghetti
      43              :    codes we used to have in the past.  Following a structured
      44              :    approach (preferably the official grammars) is believed to make it
      45              :    much easier to add extensions and nifty pretty-printing effects that
      46              :    takes expression or declaration contexts into account.  */
      47              : 
      48              : 
      49              : /* literal  */
      50              : static void pp_c_char (c_pretty_printer *, int);
      51              : 
      52              : /* postfix-expression  */
      53              : static void pp_c_initializer_list (c_pretty_printer *, tree);
      54              : static void pp_c_brace_enclosed_initializer_list (c_pretty_printer *, tree);
      55              : 
      56              : static void pp_c_additive_expression (c_pretty_printer *, tree);
      57              : static void pp_c_shift_expression (c_pretty_printer *, tree);
      58              : static void pp_c_relational_expression (c_pretty_printer *, tree);
      59              : static void pp_c_equality_expression (c_pretty_printer *, tree);
      60              : static void pp_c_and_expression (c_pretty_printer *, tree);
      61              : static void pp_c_exclusive_or_expression (c_pretty_printer *, tree);
      62              : static void pp_c_inclusive_or_expression (c_pretty_printer *, tree);
      63              : static void pp_c_logical_and_expression (c_pretty_printer *, tree);
      64              : 
      65              : /* declarations.  */
      66              : 
      67              : 
      68              : /* Helper functions.  */
      69              : 
      70              : void
      71     51823467 : pp_c_whitespace (c_pretty_printer *pp)
      72              : {
      73     51823467 :   pp_space (pp);
      74     51823467 :   pp->set_padding (pp_none);
      75     51823467 : }
      76              : 
      77              : void
      78      3505741 : pp_c_left_paren (c_pretty_printer *pp)
      79              : {
      80      3505741 :   pp_left_paren (pp);
      81      3505741 :   pp->set_padding (pp_none);
      82      3505741 : }
      83              : 
      84              : void
      85      3505741 : pp_c_right_paren (c_pretty_printer *pp)
      86              : {
      87      3505741 :   pp_right_paren (pp);
      88      3505741 :   pp->set_padding (pp_none);
      89      3505741 : }
      90              : 
      91              : void
      92        11557 : pp_c_left_brace (c_pretty_printer *pp)
      93              : {
      94        11557 :   pp_left_brace (pp);
      95        11557 :   pp->set_padding (pp_none);
      96        11557 : }
      97              : 
      98              : void
      99        11557 : pp_c_right_brace (c_pretty_printer *pp)
     100              : {
     101        11557 :   pp_right_brace (pp);
     102        11557 :   pp->set_padding (pp_none);
     103        11557 : }
     104              : 
     105              : void
     106       861211 : pp_c_left_bracket (c_pretty_printer *pp)
     107              : {
     108       861211 :   pp_left_bracket (pp);
     109       861211 :   pp->set_padding (pp_none);
     110       861211 : }
     111              : 
     112              : void
     113       861211 : pp_c_right_bracket (c_pretty_printer *pp)
     114              : {
     115       861211 :   pp_right_bracket (pp);
     116       861211 :   pp->set_padding (pp_none);
     117       861211 : }
     118              : 
     119              : void
     120         3478 : pp_c_dot (c_pretty_printer *pp)
     121              : {
     122         3478 :   pp_dot (pp);
     123         3478 :   pp->set_padding (pp_none);
     124         3478 : }
     125              : 
     126              : void
     127         5288 : pp_c_ampersand (c_pretty_printer *pp)
     128              : {
     129         5288 :   pp_ampersand (pp);
     130         5288 :   pp->set_padding (pp_none);
     131         5288 : }
     132              : 
     133              : void
     134       197792 : pp_c_star (c_pretty_printer *pp)
     135              : {
     136       197792 :   pp_star (pp);
     137       197792 :   pp->set_padding (pp_none);
     138       197792 : }
     139              : 
     140              : void
     141         1433 : pp_c_arrow (c_pretty_printer *pp)
     142              : {
     143         1433 :   pp_arrow (pp);
     144         1433 :   pp->set_padding (pp_none);
     145         1433 : }
     146              : 
     147              : void
     148          414 : pp_c_semicolon (c_pretty_printer *pp)
     149              : {
     150          414 :   pp_semicolon (pp);
     151          414 :   pp->set_padding (pp_none);
     152          414 : }
     153              : 
     154              : void
     155      2331311 : pp_c_complement (c_pretty_printer *pp)
     156              : {
     157      2331311 :   pp_complement (pp);
     158      2331311 :   pp->set_padding (pp_none);
     159      2331311 : }
     160              : 
     161              : void
     162            0 : pp_c_exclamation (c_pretty_printer *pp)
     163              : {
     164            0 :   pp_exclamation (pp);
     165            0 :   pp->set_padding (pp_none);
     166            0 : }
     167              : 
     168              : /* Print out the external representation of QUALIFIERS.  */
     169              : 
     170              : void
     171    229026261 : pp_c_cv_qualifiers (c_pretty_printer *pp, cv_qualifier qualifiers,
     172              :                     bool func_type)
     173              : {
     174    229026261 :   const char *p = pp_last_position_in_text (pp);
     175              : 
     176    229026261 :   if (!qualifiers)
     177              :     return;
     178              : 
     179              :   /* The C programming language does not have references, but it is much
     180              :      simpler to handle those here rather than going through the same
     181              :      logic in the C++ pretty-printer.  */
     182     20372559 :   if (p != NULL && (*p == '*' || *p == '&'))
     183      2687952 :     pp_c_whitespace (pp);
     184              : 
     185     20372559 :   if (qualifiers & TYPE_QUAL_ATOMIC)
     186          135 :     pp_c_ws_string (pp, "_Atomic");
     187     20372559 :   if (qualifiers & TYPE_QUAL_CONST)
     188     40657720 :     pp_c_ws_string (pp, func_type ? "__attribute__((const))" : "const");
     189     20372559 :   if (qualifiers & TYPE_QUAL_VOLATILE)
     190       301243 :     pp_c_ws_string (pp, func_type ? "__attribute__((noreturn))" : "volatile");
     191     20372559 :   if (qualifiers & TYPE_QUAL_RESTRICT)
     192          997 :     pp_c_ws_string (pp, (flag_isoc99 && !c_dialect_cxx ()
     193              :                          ? "restrict" : "__restrict__"));
     194              : }
     195              : 
     196              : /* Pretty-print T using the type-cast notation '( type-name )'.  */
     197              : 
     198              : void
     199       768446 : pp_c_type_cast (c_pretty_printer *pp, tree t)
     200              : {
     201       768446 :   pp_c_left_paren (pp);
     202       768446 :   pp->type_id (t);
     203       768446 :   pp_c_right_paren (pp);
     204       768446 : }
     205              : 
     206              : /* We're about to pretty-print a pointer type as indicated by T.
     207              :    Output a whitespace, if needed, preparing for subsequent output.  */
     208              : 
     209              : void
     210          217 : pp_c_space_for_pointer_operator (c_pretty_printer *pp, tree t)
     211              : {
     212          217 :   if (POINTER_TYPE_P (t))
     213              :     {
     214           77 :       tree pointee = strip_pointer_operator (TREE_TYPE (t));
     215           77 :       if (TREE_CODE (pointee) != ARRAY_TYPE
     216           77 :           && TREE_CODE (pointee) != FUNCTION_TYPE)
     217           77 :         pp_c_whitespace (pp);
     218              :     }
     219          217 : }
     220              : 
     221              : 
     222              : /* Declarations.  */
     223              : 
     224              : /* C++ cv-qualifiers are called type-qualifiers in C.  Print out the
     225              :    cv-qualifiers of T.  If T is a declaration then it is the cv-qualifier
     226              :    of its type.  Take care of possible extensions.
     227              : 
     228              :    type-qualifier-list:
     229              :        type-qualifier
     230              :        type-qualifier-list type-qualifier
     231              : 
     232              :    type-qualifier:
     233              :        const
     234              :        restrict                              -- C99
     235              :        __restrict__                          -- GNU C
     236              :        address-space-qualifier               -- GNU C
     237              :        volatile
     238              :        _Atomic                               -- C11
     239              : 
     240              :    address-space-qualifier:
     241              :        identifier                            -- GNU C  */
     242              : 
     243              : void
     244    228366236 : pp_c_type_qualifier_list (c_pretty_printer *pp, tree t)
     245              : {
     246    228366236 :   cv_qualifier qualifiers;
     247              : 
     248    228366236 :   if (!t || t == error_mark_node)
     249              :     return;
     250              : 
     251    228366221 :   if (!TYPE_P (t))
     252            0 :     t = TREE_TYPE (t);
     253              : 
     254    228366221 :   if (TREE_CODE (t) != ARRAY_TYPE)
     255              :     {
     256    228329992 :       qualifiers = TYPE_QUALS_NO_ADDR_SPACE (t);
     257    228329992 :       pp_c_cv_qualifiers (pp, qualifiers,
     258              :                           TREE_CODE (t) == FUNCTION_TYPE);
     259              :     }
     260              : 
     261    228366221 :   if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (t)))
     262              :     {
     263            3 :       const char *as = c_addr_space_name (TYPE_ADDR_SPACE (t));
     264            3 :       pp_c_identifier (pp, as);
     265              :     }
     266              : }
     267              : 
     268              : /* pointer:
     269              :       * type-qualifier-list(opt)
     270              :       * type-qualifier-list(opt) pointer  */
     271              : 
     272              : static void
     273        13717 : pp_c_pointer (c_pretty_printer *pp, tree t)
     274              : {
     275        13717 :   if (!TYPE_P (t) && TREE_CODE (t) != TYPE_DECL)
     276            0 :     t = TREE_TYPE (t);
     277        13717 :   switch (TREE_CODE (t))
     278              :     {
     279        13717 :     case POINTER_TYPE:
     280              :       /* It is easier to handle C++ reference types here.  */
     281        13717 :     case REFERENCE_TYPE:
     282        13717 :       if (TREE_CODE (TREE_TYPE (t)) == POINTER_TYPE)
     283          362 :         pp_c_pointer (pp, TREE_TYPE (t));
     284        13717 :       if (TREE_CODE (t) == POINTER_TYPE)
     285         8517 :         pp_c_star (pp);
     286              :       else
     287              :         {
     288         5200 :           pp_c_ampersand (pp);
     289         5200 :           if (TYPE_REF_IS_RVALUE (t))
     290           76 :             pp_c_ampersand (pp);
     291              :         }
     292        13717 :       pp_c_type_qualifier_list (pp, t);
     293        13717 :       break;
     294              : 
     295              :       /* ??? This node is now in GENERIC and so shouldn't be here.  But
     296              :          we'll fix that later.  */
     297            0 :     case DECL_EXPR:
     298            0 :       pp->declaration (DECL_EXPR_DECL (t));
     299            0 :       pp_needs_newline (pp) = true;
     300            0 :       break;
     301              : 
     302            0 :     default:
     303            0 :       pp_unsupported_tree (pp, t);
     304              :     }
     305        13717 : }
     306              : 
     307              : /* simple-type-specifier:
     308              :      type-specifier
     309              : 
     310              :    type-specifier:
     311              :       void
     312              :       char
     313              :       short
     314              :       int
     315              :       long
     316              :       float
     317              :       double
     318              :       signed
     319              :       unsigned
     320              :       _Bool                          -- C99
     321              :       _Complex                       -- C99
     322              :       _Imaginary                     -- C99
     323              :       nullptr_t                      -- C23
     324              :       struct-or-union-specifier
     325              :       enum-specifier
     326              :       typedef-name.
     327              : 
     328              :   GNU extensions.
     329              :   simple-type-specifier:
     330              :       __complex__
     331              :       __vector__   */
     332              : 
     333              : void
     334    117183380 : c_pretty_printer::simple_type_specifier (tree t)
     335              : {
     336    117183380 :   const enum tree_code code = TREE_CODE (t);
     337    117183380 :   switch (code)
     338              :     {
     339           15 :     case ERROR_MARK:
     340           15 :       translate_string ("<type-error>");
     341           15 :       break;
     342              : 
     343          118 :     case IDENTIFIER_NODE:
     344          118 :       pp_c_identifier (this, IDENTIFIER_POINTER (t));
     345          118 :       break;
     346              : 
     347     58590269 :     case VOID_TYPE:
     348     58590269 :     case OPAQUE_TYPE:
     349     58590269 :     case BOOLEAN_TYPE:
     350     58590269 :     case INTEGER_TYPE:
     351     58590269 :     case REAL_TYPE:
     352     58590269 :     case FIXED_POINT_TYPE:
     353     58590269 :       if (TYPE_NAME (t))
     354              :         {
     355     58589969 :           t = TYPE_NAME (t);
     356     58589969 :           simple_type_specifier (t);
     357              :         }
     358              :       else
     359              :         {
     360          300 :           int prec = TYPE_PRECISION (t);
     361          300 :           tree common_t;
     362          300 :           if (ALL_FIXED_POINT_MODE_P (TYPE_MODE (t)))
     363            0 :             common_t = c_common_type_for_mode (TYPE_MODE (t),
     364            0 :                                                TYPE_SATURATING (t));
     365              :           else
     366          300 :             common_t = c_common_type_for_mode (TYPE_MODE (t),
     367          300 :                                                TYPE_UNSIGNED (t));
     368          300 :           if (common_t && TYPE_NAME (common_t))
     369              :             {
     370          264 :               simple_type_specifier (common_t);
     371          264 :               if (TYPE_PRECISION (common_t) != prec)
     372              :                 {
     373          151 :                   pp_colon (this);
     374          151 :                   pp_decimal_int (this, prec);
     375              :                 }
     376              :             }
     377              :           else
     378              :             {
     379           36 :               switch (code)
     380              :                 {
     381            0 :                 case INTEGER_TYPE:
     382            0 :                   translate_string (TYPE_UNSIGNED (t)
     383              :                                     ? "<unnamed-unsigned:"
     384              :                                     : "<unnamed-signed:");
     385            0 :                   break;
     386           36 :                 case REAL_TYPE:
     387           36 :                   translate_string ("<unnamed-float:");
     388           36 :                   break;
     389            0 :                 case FIXED_POINT_TYPE:
     390            0 :                   translate_string ("<unnamed-fixed:");
     391            0 :                   break;
     392            0 :                 default:
     393            0 :                   gcc_unreachable ();
     394              :                 }
     395           36 :               pp_decimal_int (this, prec);
     396           36 :               pp_greater (this);
     397              :             }
     398              :         }
     399              :       break;
     400              : 
     401           43 :     case BITINT_TYPE:
     402           43 :       if (TYPE_NAME (t))
     403              :         {
     404            0 :           t = TYPE_NAME (t);
     405            0 :           simple_type_specifier (t);
     406              :         }
     407              :       else
     408              :         {
     409           43 :           int prec = TYPE_PRECISION (t);
     410           43 :           if (TYPE_UNSIGNED (t))
     411           13 :             pp_c_ws_string (this, "unsigned");
     412           43 :           pp_c_ws_string (this, "_BitInt(");;
     413           43 :           pp_decimal_int (this, prec);
     414           43 :           pp_right_paren (this);
     415              :         }
     416              :       break;
     417              : 
     418     58589851 :     case TYPE_DECL:
     419     58589851 :       if (DECL_NAME (t))
     420     58589851 :         id_expression (t);
     421              :       else
     422            0 :         translate_string ("<typedef-error>");
     423              :       break;
     424              : 
     425         3077 :     case UNION_TYPE:
     426         3077 :     case RECORD_TYPE:
     427         3077 :     case ENUMERAL_TYPE:
     428         3077 :       if (TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL)
     429              :         /* Don't decorate the type if this is a typedef name.  */;
     430         2195 :       else if (code == UNION_TYPE)
     431          169 :         pp_c_ws_string (this, "union");
     432         2026 :       else if (code == RECORD_TYPE)
     433         1691 :         pp_c_ws_string (this, "struct");
     434          335 :       else if (code == ENUMERAL_TYPE)
     435          335 :         pp_c_ws_string (this, "enum");
     436              :       else
     437              :         translate_string ("<tag-error>");
     438              : 
     439         3077 :       if (TYPE_NAME (t))
     440         3028 :         id_expression (TYPE_NAME (t));
     441              :       else
     442           49 :         translate_string ("<anonymous>");
     443              :       break;
     444            7 :     case NULLPTR_TYPE:
     445            7 :       pp_c_ws_string (this, "nullptr_t");
     446            7 :       break;
     447              : 
     448            0 :     default:
     449            0 :       pp_unsupported_tree (this, t);
     450            0 :       break;
     451              :     }
     452    117183380 : }
     453              : 
     454              : /* specifier-qualifier-list:
     455              :       type-specifier specifier-qualifier-list-opt
     456              :       type-qualifier specifier-qualifier-list-opt
     457              : 
     458              : 
     459              :   Implementation note:  Because of the non-linearities in array or
     460              :   function declarations, this routine prints not just the
     461              :   specifier-qualifier-list of such entities or types of such entities,
     462              :   but also the 'pointer' production part of their declarators.  The
     463              :   remaining part is done by declarator() or abstract_declarator().  */
     464              : 
     465              : void
     466     59435392 : pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t)
     467              : {
     468     59435392 :   const enum tree_code code = TREE_CODE (t);
     469              : 
     470     59435392 :   if (!(pp->flags & pp_c_flag_gnu_v3) && code != POINTER_TYPE)
     471       481174 :     pp_c_type_qualifier_list (pp, t);
     472     59427237 :   switch (code)
     473              :     {
     474        13355 :     case REFERENCE_TYPE:
     475        13355 :     case POINTER_TYPE:
     476        13355 :       {
     477              :         /* Get the types-specifier of this type.  */
     478        13355 :         tree pointee = strip_pointer_operator (TREE_TYPE (t));
     479        13355 :         pp_c_specifier_qualifier_list (pp, pointee);
     480        13355 :         if (TREE_CODE (pointee) == ARRAY_TYPE
     481        12882 :             || TREE_CODE (pointee) == FUNCTION_TYPE)
     482              :           {
     483         2361 :             pp_c_whitespace (pp);
     484         2361 :             pp_c_left_paren (pp);
     485              :             /* If we're dealing with the GNU form of attributes, print this:
     486              :                  void (__attribute__((noreturn)) *f) ();
     487              :                If it is the standard [[]] attribute, we'll print the attribute
     488              :                in c_pretty_printer::direct_abstract_declarator/FUNCTION_TYPE.  */
     489         2361 :             if (!cxx11_attribute_p (TYPE_ATTRIBUTES (pointee)))
     490         2357 :               pp_c_attributes_display (pp, TYPE_ATTRIBUTES (pointee));
     491              :           }
     492        10994 :         else if (!c_dialect_cxx ())
     493         5436 :           pp_c_whitespace (pp);
     494        13355 :         pp_ptr_operator (pp, t);
     495              :       }
     496        13355 :       break;
     497              : 
     498        38838 :     case FUNCTION_TYPE:
     499        38838 :     case ARRAY_TYPE:
     500        38838 :       pp_c_specifier_qualifier_list (pp, TREE_TYPE (t));
     501        38838 :       break;
     502              : 
     503        10028 :     case VECTOR_TYPE:
     504        10028 :     case COMPLEX_TYPE:
     505        10028 :       if (code == COMPLEX_TYPE)
     506          661 :         pp_c_ws_string (pp, (flag_isoc99 && !c_dialect_cxx ()
     507              :                              ? "_Complex" : "__complex__"));
     508         9645 :       else if (code == VECTOR_TYPE)
     509              :         {
     510              :           /* The syntax we print for vector types isn't real C or C++ syntax,
     511              :              so it's better to print the type name if we have one.  */
     512         9645 :           tree name = TYPE_NAME (t);
     513         9645 :           if (!(pp->flags & pp_c_flag_gnu_v3)
     514         1340 :               && name
     515           23 :               && TREE_CODE (name) == TYPE_DECL)
     516              :             {
     517           23 :               pp->id_expression (name);
     518           23 :               break;
     519              :             }
     520         9622 :           pp_c_ws_string (pp, "__vector");
     521         9622 :           pp_c_left_paren (pp);
     522         9622 :           pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (t));
     523         9622 :           pp_c_right_paren (pp);
     524         9622 :           pp_c_whitespace (pp);
     525              :         }
     526        10005 :       pp_c_specifier_qualifier_list (pp, TREE_TYPE (t));
     527        10005 :       break;
     528              : 
     529     59373171 :     default:
     530     59373171 :       pp->simple_type_specifier (t);
     531     59373171 :       break;
     532              :     }
     533     59435392 :   if ((pp->flags & pp_c_flag_gnu_v3) && code != POINTER_TYPE)
     534     58946063 :     pp_c_type_qualifier_list (pp, t);
     535     59435392 : }
     536              : 
     537              : /* parameter-type-list:
     538              :       parameter-list
     539              :       parameter-list , ...
     540              : 
     541              :    parameter-list:
     542              :       parameter-declaration
     543              :       parameter-list , parameter-declaration
     544              : 
     545              :    parameter-declaration:
     546              :       declaration-specifiers declarator
     547              :       declaration-specifiers abstract-declarator(opt)   */
     548              : 
     549              : void
     550         2589 : pp_c_parameter_type_list (c_pretty_printer *pp, tree t)
     551              : {
     552         2589 :   bool want_parm_decl = DECL_P (t) && !(pp->flags & pp_c_flag_abstract);
     553         2589 :   tree parms = want_parm_decl ? DECL_ARGUMENTS (t) :  TYPE_ARG_TYPES (t);
     554         2589 :   pp_c_left_paren (pp);
     555         2589 :   if (parms == void_list_node)
     556          891 :     pp_c_ws_string (pp, "void");
     557              :   else
     558              :     {
     559              :       bool first = true;
     560         4322 :       for ( ; parms && parms != void_list_node; parms = TREE_CHAIN (parms))
     561              :         {
     562         2624 :           if (!first)
     563         1053 :             pp_separate_with (pp, ',');
     564         2624 :           first = false;
     565         2624 :           pp->declaration_specifiers
     566         5248 :             (want_parm_decl ? parms : TREE_VALUE (parms));
     567         2624 :           if (want_parm_decl)
     568            0 :             pp->declarator (parms);
     569              :           else
     570         2624 :             pp->abstract_declarator (TREE_VALUE (parms));
     571              :         }
     572         1698 :       if (!first && !parms)
     573              :         {
     574           68 :           pp_separate_with (pp, ',');
     575           68 :           pp_string (pp, "...");
     576              :         }
     577              :     }
     578         2589 :   pp_c_right_paren (pp);
     579         2589 : }
     580              : 
     581              : /* abstract-declarator:
     582              :       pointer
     583              :       pointer(opt) direct-abstract-declarator  */
     584              : 
     585              : void
     586        32415 : c_pretty_printer::abstract_declarator (tree t)
     587              : {
     588        32415 :   if (TREE_CODE (t) == POINTER_TYPE)
     589              :     {
     590         8076 :       if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE
     591         8076 :           || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
     592         2286 :         pp_c_right_paren (this);
     593         8076 :       t = TREE_TYPE (t);
     594              :     }
     595              : 
     596        32415 :   direct_abstract_declarator (t);
     597        32415 : }
     598              : 
     599              : /* direct-abstract-declarator:
     600              :       ( abstract-declarator )
     601              :       direct-abstract-declarator(opt) [ assignment-expression(opt) ]
     602              :       direct-abstract-declarator(opt) [ * ]
     603              :       direct-abstract-declarator(opt) ( parameter-type-list(opt) )  */
     604              : 
     605              : void
     606        74208 : c_pretty_printer::direct_abstract_declarator (tree t)
     607              : {
     608        74208 :   bool add_space = false;
     609              : 
     610        74208 :   switch (TREE_CODE (t))
     611              :     {
     612         1074 :     case POINTER_TYPE:
     613         1074 :       abstract_declarator (t);
     614         1074 :       break;
     615              : 
     616         2589 :     case FUNCTION_TYPE:
     617         2589 :       pp_c_parameter_type_list (this, t);
     618         2589 :       direct_abstract_declarator (TREE_TYPE (t));
     619              :       /* If this is the standard [[]] attribute, print
     620              :          void (*)() [[noreturn]];  */
     621         2589 :       if (cxx11_attribute_p (TYPE_ATTRIBUTES (t)))
     622              :         {
     623            4 :           pp_space (this);
     624            4 :           pp_c_attributes_display (this, TYPE_ATTRIBUTES (t));
     625              :         }
     626              :       break;
     627              : 
     628        36227 :     case ARRAY_TYPE:
     629        36227 :       pp_c_left_bracket (this);
     630              : 
     631        36227 :       if (auto quals = TYPE_QUALS_NO_ADDR_SPACE (t))
     632              :         {
     633              :           /* Print the array qualifiers such as in "T[const restrict 3]".  */
     634           40 :           pp_c_cv_qualifiers (this, quals, false);
     635           40 :           add_space = true;
     636              :         }
     637              : 
     638        36227 :       if (tree arr = lookup_attribute ("array ", TYPE_ATTRIBUTES (t)))
     639              :         {
     640          812 :           if (TREE_VALUE (arr))
     641              :             {
     642              :               /* Print the specifier as in "T[static 3]" that's not actually
     643              :                  part of the type but may be added by the front end.  */
     644           48 :               pp_c_ws_string (this, "static");
     645           48 :               add_space = true;
     646              :             }
     647          764 :           else if (!TYPE_DOMAIN (t))
     648              :             /* For arrays of unspecified bound using the [*] notation. */
     649           78 :             pp_character (this, '*');
     650              :         }
     651              : 
     652        36227 :       if (tree dom = TYPE_DOMAIN (t))
     653              :         {
     654        34989 :           if (tree maxval = TYPE_MAX_VALUE (dom))
     655              :             {
     656        34609 :               if (add_space)
     657           67 :                 pp_space (this);
     658              : 
     659        34609 :               tree type = TREE_TYPE (maxval);
     660              : 
     661        34609 :               if (tree_fits_shwi_p (maxval))
     662        25294 :                 pp_wide_integer (this, tree_to_shwi (maxval) + 1);
     663         9315 :               else if (TREE_CODE (maxval) == INTEGER_CST)
     664            0 :                 expression (fold_build2 (PLUS_EXPR, type, maxval,
     665              :                                          build_int_cst (type, 1)));
     666              :               else
     667              :                 {
     668              :                   /* Strip the expressions from around a VLA bound added
     669              :                      internally to make it fit the domain mold, including
     670              :                      any casts.  */
     671         9315 :                   if (TREE_CODE (maxval) == NOP_EXPR)
     672         9198 :                     maxval = TREE_OPERAND (maxval, 0);
     673         9315 :                   if (TREE_CODE (maxval) == PLUS_EXPR
     674         9315 :                       && integer_all_onesp (TREE_OPERAND (maxval, 1)))
     675              :                     {
     676         8506 :                       maxval = TREE_OPERAND (maxval, 0);
     677         8506 :                       if (TREE_CODE (maxval) == NOP_EXPR)
     678         8506 :                         maxval = TREE_OPERAND (maxval, 0);
     679              :                     }
     680         9315 :                   if (TREE_CODE (maxval) == SAVE_EXPR)
     681              :                     {
     682         8506 :                       maxval = TREE_OPERAND (maxval, 0);
     683         8506 :                       if (TREE_CODE (maxval) == NOP_EXPR)
     684            0 :                         maxval = TREE_OPERAND (maxval, 0);
     685              :                     }
     686              : 
     687              :                   /* This covers unspecified bounds.  */
     688         9315 :                   if (TREE_CODE (maxval) == COMPOUND_EXPR)
     689           44 :                     pp_string (this, "*");
     690              :                   else
     691         9271 :                     expression (maxval);
     692              :                 }
     693              :             }
     694          380 :           else if (TYPE_SIZE (t))
     695              :             /* Print zero for zero-length arrays but not for flexible
     696              :                array members whose TYPE_SIZE is null.  */
     697          244 :             pp_string (this, "0");
     698              :         }
     699        36227 :       pp_c_right_bracket (this);
     700        36227 :       direct_abstract_declarator (TREE_TYPE (t));
     701        36227 :       break;
     702              : 
     703              :     case IDENTIFIER_NODE:
     704              :     case VOID_TYPE:
     705              :     case OPAQUE_TYPE:
     706              :     case BOOLEAN_TYPE:
     707              :     case INTEGER_TYPE:
     708              :     case REAL_TYPE:
     709              :     case FIXED_POINT_TYPE:
     710              :     case ENUMERAL_TYPE:
     711              :     case BITINT_TYPE:
     712              :     case RECORD_TYPE:
     713              :     case UNION_TYPE:
     714              :     case VECTOR_TYPE:
     715              :     case COMPLEX_TYPE:
     716              :     case TYPE_DECL:
     717              :     case ERROR_MARK:
     718              :     case NULLPTR_TYPE:
     719              :       break;
     720              : 
     721            0 :     default:
     722            0 :       pp_unsupported_tree (this, t);
     723            0 :       break;
     724              :     }
     725        74208 : }
     726              : 
     727              : /* type-name:
     728              :       specifier-qualifier-list  abstract-declarator(opt)  */
     729              : 
     730              : void
     731        36863 : c_pretty_printer::type_id (tree t)
     732              : {
     733        36863 :   pp_c_specifier_qualifier_list (this, t);
     734        36863 :   abstract_declarator (t);
     735        36863 : }
     736              : 
     737              : /* storage-class-specifier:
     738              :       typedef
     739              :       extern
     740              :       static
     741              :       auto
     742              :       register  */
     743              : 
     744              : void
     745         3091 : c_pretty_printer::storage_class_specifier (tree t)
     746              : {
     747         3091 :   if (TREE_CODE (t) == TYPE_DECL)
     748            0 :     pp_c_ws_string (this, "typedef");
     749         3091 :   else if (DECL_P (t))
     750              :     {
     751          217 :       if ((TREE_CODE (t) == PARM_DECL || VAR_P (t))
     752          217 :           && DECL_REGISTER (t))
     753            0 :         pp_c_ws_string (this, "register");
     754          217 :       else if (TREE_STATIC (t) && VAR_P (t))
     755            0 :         pp_c_ws_string (this, "static");
     756              :     }
     757         3091 : }
     758              : 
     759              : /* function-specifier:
     760              :       inline   */
     761              : 
     762              : void
     763         2624 : c_pretty_printer::function_specifier (tree t)
     764              : {
     765         2624 :   if (TREE_CODE (t) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (t))
     766            0 :     pp_c_ws_string (this, "inline");
     767         2624 : }
     768              : 
     769              : /* declaration-specifiers:
     770              :       storage-class-specifier declaration-specifiers(opt)
     771              :       type-specifier declaration-specifiers(opt)
     772              :       type-qualifier declaration-specifiers(opt)
     773              :       function-specifier declaration-specifiers(opt)  */
     774              : 
     775              : void
     776         2874 : c_pretty_printer::declaration_specifiers (tree t)
     777              : {
     778         2874 :   storage_class_specifier (t);
     779         2874 :   function_specifier (t);
     780         2874 :   pp_c_specifier_qualifier_list (this, DECL_P (t) ?  TREE_TYPE (t) : t);
     781         2874 : }
     782              : 
     783              : /* direct-declarator
     784              :       identifier
     785              :       ( declarator )
     786              :       direct-declarator [ type-qualifier-list(opt) assignment-expression(opt) ]
     787              :       direct-declarator [ static type-qualifier-list(opt) assignment-expression(opt)]
     788              :       direct-declarator [ type-qualifier-list static assignment-expression ]
     789              :       direct-declarator [ type-qualifier-list * ]
     790              :       direct-declarator ( parameter-type-list )
     791              :       direct-declarator ( identifier-list(opt) )  */
     792              : 
     793              : void
     794            0 : c_pretty_printer::direct_declarator (tree t)
     795              : {
     796            0 :   switch (TREE_CODE (t))
     797              :     {
     798            0 :     case VAR_DECL:
     799            0 :     case PARM_DECL:
     800            0 :     case TYPE_DECL:
     801            0 :     case FIELD_DECL:
     802            0 :     case LABEL_DECL:
     803            0 :       pp_c_space_for_pointer_operator (this, TREE_TYPE (t));
     804            0 :       pp_c_tree_decl_identifier (this, t);
     805            0 :       break;
     806              : 
     807            0 :     case ARRAY_TYPE:
     808            0 :     case POINTER_TYPE:
     809            0 :       abstract_declarator (TREE_TYPE (t));
     810            0 :       break;
     811              : 
     812            0 :     case FUNCTION_TYPE:
     813            0 :       pp_parameter_list (this, t);
     814            0 :       abstract_declarator (TREE_TYPE (t));
     815            0 :       break;
     816              : 
     817            0 :     case FUNCTION_DECL:
     818            0 :       pp_c_space_for_pointer_operator (this, TREE_TYPE (TREE_TYPE (t)));
     819            0 :       pp_c_tree_decl_identifier (this, t);
     820            0 :       if (flags & pp_c_flag_abstract)
     821            0 :         abstract_declarator (TREE_TYPE (t));
     822              :       else
     823              :         {
     824            0 :           pp_parameter_list (this, t);
     825            0 :           abstract_declarator (TREE_TYPE (TREE_TYPE (t)));
     826              :         }
     827              :       break;
     828              : 
     829              :     case INTEGER_TYPE:
     830              :     case REAL_TYPE:
     831              :     case FIXED_POINT_TYPE:
     832              :     case ENUMERAL_TYPE:
     833              :     case BITINT_TYPE:
     834              :     case UNION_TYPE:
     835              :     case RECORD_TYPE:
     836              :       break;
     837              : 
     838            0 :     default:
     839            0 :       pp_unsupported_tree (this, t);
     840            0 :       break;
     841              :     }
     842            0 : }
     843              : 
     844              : 
     845              : /* declarator:
     846              :       pointer(opt)  direct-declarator   */
     847              : 
     848              : void
     849            0 : c_pretty_printer::declarator (tree t)
     850              : {
     851            0 :   switch (TREE_CODE (t))
     852              :     {
     853              :     case INTEGER_TYPE:
     854              :     case REAL_TYPE:
     855              :     case FIXED_POINT_TYPE:
     856              :     case ENUMERAL_TYPE:
     857              :     case BITINT_TYPE:
     858              :     case UNION_TYPE:
     859              :     case RECORD_TYPE:
     860              :       break;
     861              : 
     862            0 :     case VAR_DECL:
     863            0 :     case PARM_DECL:
     864            0 :     case FIELD_DECL:
     865            0 :     case ARRAY_TYPE:
     866            0 :     case FUNCTION_TYPE:
     867            0 :     case FUNCTION_DECL:
     868            0 :     case TYPE_DECL:
     869            0 :       direct_declarator (t);
     870            0 :     break;
     871              : 
     872              : 
     873            0 :     default:
     874            0 :       pp_unsupported_tree (this, t);
     875            0 :       break;
     876              :     }
     877            0 : }
     878              : 
     879              : /* declaration:
     880              :       declaration-specifiers init-declarator-list(opt) ;  */
     881              : 
     882              : void
     883            0 : c_pretty_printer::declaration (tree t)
     884              : {
     885            0 :   declaration_specifiers (t);
     886            0 :   pp_c_init_declarator (this, t);
     887            0 : }
     888              : 
     889              : /* Pretty-print ATTRIBUTES marked to be displayed on diagnostic.  */
     890              : 
     891              : void
     892       455245 : pp_c_attributes_display (c_pretty_printer *pp, tree a)
     893              : {
     894       455245 :   bool is_first = true;
     895              : 
     896       455245 :   if (a == NULL_TREE)
     897              :     return;
     898              : 
     899          991 :   const bool std_p = cxx11_attribute_p (a);
     900              : 
     901         3226 :   for (; a != NULL_TREE; a = TREE_CHAIN (a))
     902              :     {
     903         1244 :       const struct attribute_spec *as
     904         1244 :         = lookup_attribute_spec (get_attribute_name (a));
     905         1244 :       if (!as || as->affects_type_identity == false)
     906          489 :         continue;
     907          755 :       if (c_dialect_cxx ()
     908          486 :           && !strcmp ("transaction_safe", as->name))
     909              :         /* In C++ transaction_safe is printed at the end of the declarator.  */
     910           19 :         continue;
     911          736 :       if (is_first)
     912              :         {
     913          736 :           if (std_p)
     914              :             {
     915            6 :               pp_c_left_bracket (pp);
     916            6 :               pp_c_left_bracket (pp);
     917              :             }
     918              :           else
     919              :             {
     920          730 :               pp_c_ws_string (pp, "__attribute__");
     921          730 :               pp_c_left_paren (pp);
     922          730 :               pp_c_left_paren (pp);
     923              :             }
     924              :           is_first = false;
     925              :         }
     926              :       else
     927            0 :         pp_separate_with (pp, ',');
     928          736 :       tree ns;
     929          736 :       if (std_p && (ns = get_attribute_namespace (a)))
     930              :         {
     931            6 :           pp_tree_identifier (pp, ns);
     932            6 :           pp_colon (pp);
     933            6 :           pp_colon (pp);
     934              :         }
     935          736 :       pp_tree_identifier (pp, get_attribute_name (a));
     936          736 :       if (TREE_VALUE (a))
     937          546 :         pp_c_call_argument_list (pp, TREE_VALUE (a));
     938              :     }
     939              : 
     940          991 :   if (!is_first)
     941              :     {
     942          736 :       if (std_p)
     943              :         {
     944            6 :           pp_c_right_bracket (pp);
     945            6 :           pp_c_right_bracket (pp);
     946              :         }
     947              :       else
     948              :         {
     949          730 :           pp_c_right_paren (pp);
     950          730 :           pp_c_right_paren (pp);
     951          730 :           pp_c_whitespace (pp);
     952              :         }
     953              :     }
     954              : }
     955              : 
     956              : /* function-definition:
     957              :       declaration-specifiers declarator compound-statement  */
     958              : 
     959              : void
     960            0 : pp_c_function_definition (c_pretty_printer *pp, tree t)
     961              : {
     962            0 :   pp->declaration_specifiers (t);
     963            0 :   pp->declarator (t);
     964            0 :   pp_needs_newline (pp) = true;
     965            0 :   pp->statement (DECL_SAVED_TREE (t));
     966            0 :   pp_newline_and_flush (pp);
     967            0 : }
     968              : 
     969              : 
     970              : /* Expressions.  */
     971              : 
     972              : /* Print out a c-char.  This is called solely for characters which are
     973              :    in the *target* execution character set.  We ought to convert them
     974              :    back to the *host* execution character set before printing, but we
     975              :    have no way to do this at present.  A decent compromise is to print
     976              :    all characters as if they were in the host execution character set,
     977              :    and not attempt to recover any named escape characters, but render
     978              :    all unprintables as octal escapes.  If the host and target character
     979              :    sets are the same, this produces relatively readable output.  If they
     980              :    are not the same, strings may appear as gibberish, but that's okay
     981              :    (in fact, it may well be what the reader wants, e.g. if they are looking
     982              :    to see if conversion to the target character set happened correctly).
     983              : 
     984              :    A special case: we need to prefix \, ", and ' with backslashes.  It is
     985              :    correct to do so for the *host*'s \, ", and ', because the rest of the
     986              :    file appears in the host character set.  */
     987              : 
     988              : static void
     989      1736969 : pp_c_char (c_pretty_printer *pp, int c)
     990              : {
     991      1736969 :   if (ISPRINT (c))
     992              :     {
     993      1734612 :       switch (c)
     994              :         {
     995            0 :         case '\\': pp_string (pp, "\\\\"); break;
     996          226 :         case '\'': pp_string (pp, "\\\'"); break;
     997            0 :         case '\"': pp_string (pp, "\\\""); break;
     998      1734386 :         default:   pp_character (pp, c);
     999              :         }
    1000              :     }
    1001              :   else
    1002         2357 :     pp_scalar (pp, "\\%03o", (unsigned) c);
    1003      1736969 : }
    1004              : 
    1005              : /* Print out a STRING literal.  */
    1006              : 
    1007              : void
    1008         1264 : pp_c_string_literal (c_pretty_printer *pp, tree s)
    1009              : {
    1010         1264 :   const char *p = TREE_STRING_POINTER (s);
    1011         1264 :   int n = TREE_STRING_LENGTH (s) - 1;
    1012         1264 :   int i;
    1013         1264 :   pp_doublequote (pp);
    1014        13353 :   for (i = 0; i < n; ++i)
    1015        10825 :     pp_c_char (pp, p[i]);
    1016         1264 :   pp_doublequote (pp);
    1017         1264 : }
    1018              : 
    1019              : /* Pretty-print a VOID_CST (void_node).  */
    1020              : 
    1021              : static void
    1022           18 : pp_c_void_constant (c_pretty_printer *pp)
    1023              : {
    1024           18 :   pp_c_type_cast (pp, void_type_node);
    1025           18 :   pp_string (pp, "0");
    1026           18 : }
    1027              : 
    1028              : /* Pretty-print an INTEGER literal.  */
    1029              : 
    1030              : void
    1031     13413109 : pp_c_integer_constant (c_pretty_printer *pp, tree i)
    1032              : {
    1033     13413109 :   if (tree_fits_shwi_p (i))
    1034     12751312 :     pp_wide_integer (pp, tree_to_shwi (i));
    1035       661797 :   else if (tree_fits_uhwi_p (i))
    1036       661773 :     pp_unsigned_wide_integer (pp, tree_to_uhwi (i));
    1037              :   else
    1038              :     {
    1039           24 :       wide_int wi = wi::to_wide (i);
    1040              : 
    1041           24 :       if (wi::lt_p (wi::to_wide (i), 0, TYPE_SIGN (TREE_TYPE (i))))
    1042              :         {
    1043            5 :           pp_minus (pp);
    1044            5 :           wi = -wi;
    1045              :         }
    1046           24 :       unsigned int prec = wi.get_precision ();
    1047           24 :       if ((prec + 3) / 4 > sizeof (pp_buffer (pp)->m_digit_buffer) - 3)
    1048              :         {
    1049            1 :           char *buf = XALLOCAVEC (char, (prec + 3) / 4 + 3);
    1050            1 :           print_hex (wi, buf);
    1051            1 :           pp_string (pp, buf);
    1052              :         }
    1053              :       else
    1054              :         {
    1055           23 :           print_hex (wi, pp_buffer (pp)->m_digit_buffer);
    1056           23 :           pp_string (pp, pp_buffer (pp)->m_digit_buffer);
    1057              :         }
    1058           24 :     }
    1059     13413109 : }
    1060              : 
    1061              : /* Print out a CHARACTER literal.  */
    1062              : 
    1063              : static void
    1064      1726144 : pp_c_character_constant (c_pretty_printer *pp, tree c)
    1065              : {
    1066      1726144 :   pp_quote (pp);
    1067      1726144 :   pp_c_char (pp, (unsigned) TREE_INT_CST_LOW (c));
    1068      1726144 :   pp_quote (pp);
    1069      1726144 : }
    1070              : 
    1071              : /* Print out a BOOLEAN literal.  */
    1072              : 
    1073              : static void
    1074      7995735 : pp_c_bool_constant (c_pretty_printer *pp, tree b)
    1075              : {
    1076      7995735 :   if (b == boolean_false_node)
    1077              :     {
    1078      4607187 :       if (c_dialect_cxx ())
    1079      4607187 :         pp_c_ws_string (pp, "false");
    1080            0 :       else if (flag_isoc99)
    1081            0 :         pp_c_ws_string (pp, "_False");
    1082              :       else
    1083            0 :         pp_unsupported_tree (pp, b);
    1084              :     }
    1085      3388548 :   else if (b == boolean_true_node)
    1086              :     {
    1087      3388548 :       if (c_dialect_cxx ())
    1088      3388548 :         pp_c_ws_string (pp, "true");
    1089            0 :       else if (flag_isoc99)
    1090            0 :         pp_c_ws_string (pp, "_True");
    1091              :       else
    1092            0 :         pp_unsupported_tree (pp, b);
    1093              :     }
    1094            0 :   else if (TREE_CODE (b) == INTEGER_CST)
    1095            0 :     pp_c_integer_constant (pp, b);
    1096              :   else
    1097            0 :     pp_unsupported_tree (pp, b);
    1098      7995735 : }
    1099              : 
    1100              : /* Given a value e of ENUMERAL_TYPE:
    1101              :    Print out the first ENUMERATOR id with value e, if one is found,
    1102              :    else print out the value as a C-style cast (type-id)value.  */
    1103              : 
    1104              : static void
    1105            0 : pp_c_enumeration_constant (c_pretty_printer *pp, tree e)
    1106              : {
    1107            0 :   tree type = TREE_TYPE (e);
    1108            0 :   tree value = NULL_TREE;
    1109              : 
    1110              :   /* Find the name of this constant.  */
    1111            0 :   if ((pp->flags & pp_c_flag_gnu_v3) == 0)
    1112            0 :     for (value = TYPE_VALUES (type); value != NULL_TREE;
    1113            0 :          value = TREE_CHAIN (value))
    1114            0 :       if (tree_int_cst_equal (DECL_INITIAL (TREE_VALUE (value)), e))
    1115              :         break;
    1116              : 
    1117            0 :   if (value != NULL_TREE)
    1118            0 :     pp->id_expression (TREE_PURPOSE (value));
    1119              :   else
    1120              :     {
    1121              :       /* Value must have been cast.  */
    1122            0 :       pp_c_type_cast (pp, type);
    1123            0 :       pp_c_integer_constant (pp, e);
    1124              :     }
    1125            0 : }
    1126              : 
    1127              : /* Print out a REAL value as a decimal-floating-constant.  */
    1128              : 
    1129              : static void
    1130         1480 : pp_c_floating_constant (c_pretty_printer *pp, tree r)
    1131              : {
    1132         1480 :   const struct real_format *fmt
    1133         1480 :     = REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (r)));
    1134              : 
    1135         1480 :   REAL_VALUE_TYPE floating_cst = TREE_REAL_CST (r);
    1136         1480 :   bool is_decimal = floating_cst.decimal;
    1137              : 
    1138              :   /* See ISO C++ WG N1822.  Note: The fraction 643/2136 approximates
    1139              :      log10(2) to 7 significant digits.  */
    1140         1480 :   int max_digits10 = 2 + (is_decimal ? fmt->p : fmt->p * 643L / 2136);
    1141              : 
    1142         1480 :   real_to_decimal (pp_buffer (pp)->m_digit_buffer, &TREE_REAL_CST (r),
    1143              :                    sizeof (pp_buffer (pp)->m_digit_buffer),
    1144              :                    max_digits10, 1);
    1145              : 
    1146         1480 :   pp_string (pp, pp_buffer(pp)->m_digit_buffer);
    1147         1480 :   if (TREE_TYPE (r) == float_type_node)
    1148          422 :     pp_character (pp, 'f');
    1149         1058 :   else if (TREE_TYPE (r) == long_double_type_node)
    1150           62 :     pp_character (pp, 'l');
    1151          996 :   else if (TREE_TYPE (r) == dfloat128_type_node)
    1152           12 :     pp_string (pp, "dl");
    1153          984 :   else if (TREE_TYPE (r) == dfloat64_type_node)
    1154           12 :     pp_string (pp, "dd");
    1155          972 :   else if (TREE_TYPE (r) == dfloat32_type_node)
    1156           12 :     pp_string (pp, "df");
    1157          960 :   else if (TREE_TYPE (r) == dfloat64x_type_node)
    1158            0 :     pp_string (pp, "d64x");
    1159          960 :   else if (TREE_TYPE (r) != double_type_node)
    1160          618 :     for (int i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    1161          588 :       if (TREE_TYPE (r) == FLOATN_NX_TYPE_NODE (i))
    1162              :         {
    1163          196 :           pp_character (pp, 'f');
    1164          196 :           pp_decimal_int (pp, floatn_nx_types[i].n);
    1165          196 :           if (floatn_nx_types[i].extended)
    1166            0 :             pp_character (pp, 'x');
    1167              :           break;
    1168              :         }
    1169         1480 : }
    1170              : 
    1171              : /* Print out a FIXED value as a decimal-floating-constant.  */
    1172              : 
    1173              : static void
    1174            0 : pp_c_fixed_constant (c_pretty_printer *pp, tree r)
    1175              : {
    1176            0 :   fixed_to_decimal (pp_buffer (pp)->m_digit_buffer, &TREE_FIXED_CST (r),
    1177              :                    sizeof (pp_buffer (pp)->m_digit_buffer));
    1178            0 :   pp_string (pp, pp_buffer(pp)->m_digit_buffer);
    1179            0 : }
    1180              : 
    1181              : /* Pretty-print a compound literal expression.  GNU extensions include
    1182              :    vector constants.  */
    1183              : 
    1184              : static void
    1185           66 : pp_c_compound_literal (c_pretty_printer *pp, tree e)
    1186              : {
    1187           66 :   tree type = TREE_TYPE (e);
    1188           66 :   pp_c_type_cast (pp, type);
    1189              : 
    1190           66 :   switch (TREE_CODE (type))
    1191              :     {
    1192           66 :     case RECORD_TYPE:
    1193           66 :     case UNION_TYPE:
    1194           66 :     case ARRAY_TYPE:
    1195           66 :     case VECTOR_TYPE:
    1196           66 :     case COMPLEX_TYPE:
    1197           66 :       pp_c_brace_enclosed_initializer_list (pp, e);
    1198           66 :       break;
    1199              : 
    1200            0 :     default:
    1201            0 :       pp_unsupported_tree (pp, e);
    1202            0 :       break;
    1203              :     }
    1204           66 : }
    1205              : 
    1206              : /* Pretty-print a COMPLEX_EXPR expression.  */
    1207              : 
    1208              : static void
    1209           24 : pp_c_complex_expr (c_pretty_printer *pp, tree e)
    1210              : {
    1211              :   /* Handle a few common special cases, otherwise fallback
    1212              :      to printing it as compound literal.  */
    1213           24 :   tree type = TREE_TYPE (e);
    1214           24 :   tree realexpr = TREE_OPERAND (e, 0);
    1215           24 :   tree imagexpr = TREE_OPERAND (e, 1);
    1216              : 
    1217              :   /* Cast of an COMPLEX_TYPE expression to a different COMPLEX_TYPE.  */
    1218           24 :   if (TREE_CODE (realexpr) == NOP_EXPR
    1219           20 :       && TREE_CODE (imagexpr) == NOP_EXPR
    1220            8 :       && TREE_TYPE (realexpr) == TREE_TYPE (type)
    1221            8 :       && TREE_TYPE (imagexpr) == TREE_TYPE (type)
    1222            8 :       && TREE_CODE (TREE_OPERAND (realexpr, 0)) == REALPART_EXPR
    1223            8 :       && TREE_CODE (TREE_OPERAND (imagexpr, 0)) == IMAGPART_EXPR
    1224           32 :       && TREE_OPERAND (TREE_OPERAND (realexpr, 0), 0)
    1225            8 :          == TREE_OPERAND (TREE_OPERAND (imagexpr, 0), 0))
    1226              :     {
    1227            8 :       pp_c_type_cast (pp, type);
    1228            8 :       pp->expression (TREE_OPERAND (TREE_OPERAND (realexpr, 0), 0));
    1229            8 :       return;
    1230              :     }
    1231              : 
    1232              :   /* Cast of an scalar expression to COMPLEX_TYPE.  */
    1233           24 :   if ((integer_zerop (imagexpr) || real_zerop (imagexpr))
    1234           18 :       && TREE_TYPE (realexpr) == TREE_TYPE (type))
    1235              :     {
    1236           10 :       pp_c_type_cast (pp, type);
    1237           10 :       if (TREE_CODE (realexpr) == NOP_EXPR)
    1238            6 :         realexpr = TREE_OPERAND (realexpr, 0);
    1239           10 :       pp->expression (realexpr);
    1240           10 :       return;
    1241              :     }
    1242              : 
    1243            6 :   pp_c_compound_literal (pp, e);
    1244              : }
    1245              : 
    1246              : /* constant:
    1247              :       integer-constant
    1248              :       floating-constant
    1249              :       fixed-point-constant
    1250              :       enumeration-constant
    1251              :       character-constant   */
    1252              : 
    1253              : void
    1254     22361692 : c_pretty_printer::constant (tree e)
    1255              : {
    1256     22361692 :   const enum tree_code code = TREE_CODE (e);
    1257              : 
    1258     22361692 :   switch (code)
    1259              :     {
    1260           18 :     case VOID_CST:
    1261           18 :       pp_c_void_constant (this);
    1262           18 :       break;
    1263              : 
    1264     22359381 :     case INTEGER_CST:
    1265     22359381 :       {
    1266     22359381 :         tree type = TREE_TYPE (e);
    1267     22359381 :         if (type == boolean_type_node)
    1268      7995735 :           pp_c_bool_constant (this, e);
    1269     14363646 :         else if (type == char_type_node)
    1270      1726144 :           pp_c_character_constant (this, e);
    1271     12637502 :         else if (TREE_CODE (type) == ENUMERAL_TYPE)
    1272            0 :           pp_c_enumeration_constant (this, e);
    1273     12637502 :         else if (NULLPTR_TYPE_P (type))
    1274            0 :           pp_string (this, "nullptr");
    1275              :         else
    1276     12637502 :           pp_c_integer_constant (this, e);
    1277              :       }
    1278              :       break;
    1279              : 
    1280         1309 :     case REAL_CST:
    1281         1309 :       pp_c_floating_constant (this, e);
    1282         1309 :       break;
    1283              : 
    1284            0 :     case FIXED_CST:
    1285            0 :       pp_c_fixed_constant (this, e);
    1286            0 :       break;
    1287              : 
    1288          984 :     case STRING_CST:
    1289          984 :       pp_c_string_literal (this, e);
    1290          984 :       break;
    1291              : 
    1292            0 :     case COMPLEX_CST:
    1293              :       /* Sometimes, we are confused and we think a complex literal
    1294              :          is a constant.  Such thing is a compound literal which
    1295              :          grammatically belongs to postfix-expr production.  */
    1296            0 :       pp_c_compound_literal (this, e);
    1297            0 :       break;
    1298              : 
    1299            0 :     default:
    1300            0 :       pp_unsupported_tree (this, e);
    1301            0 :       break;
    1302              :     }
    1303     22361692 : }
    1304              : 
    1305              : /* Pretty-print a string such as an identifier, without changing its
    1306              :    encoding, preceded by whitespace is necessary.  */
    1307              : 
    1308              : void
    1309     30459499 : pp_c_ws_string (c_pretty_printer *pp, const char *str)
    1310              : {
    1311     30459499 :   pp_c_maybe_whitespace (pp);
    1312     30459499 :   pp_string (pp, str);
    1313     30459499 :   pp->set_padding (pp_before);
    1314     30459499 : }
    1315              : 
    1316              : void
    1317        55416 : c_pretty_printer::translate_string (const char *gmsgid)
    1318              : {
    1319        55416 :   if (pp_translate_identifiers (this))
    1320        10135 :     pp_c_ws_string (this, _(gmsgid));
    1321              :   else
    1322        45281 :     pp_c_ws_string (this, gmsgid);
    1323        55416 : }
    1324              : 
    1325              : /* Pretty-print an IDENTIFIER_NODE, which may contain UTF-8 sequences
    1326              :    that need converting to the locale encoding, preceded by whitespace
    1327              :    is necessary.  */
    1328              : 
    1329              : void
    1330    480425441 : pp_c_identifier (c_pretty_printer *pp, const char *id)
    1331              : {
    1332    480425441 :   pp_c_maybe_whitespace (pp);
    1333    480425441 :   pp_identifier (pp, id);
    1334    480425441 :   pp->set_padding (pp_before);
    1335    480425441 : }
    1336              : 
    1337              : /* Pretty-print a C primary-expression.
    1338              :    primary-expression:
    1339              :       identifier
    1340              :       constant
    1341              :       string-literal
    1342              :       ( expression )   */
    1343              : 
    1344              : void
    1345        38333 : c_pretty_printer::primary_expression (tree e)
    1346              : {
    1347        38333 :   switch (TREE_CODE (e))
    1348              :     {
    1349        29462 :     case VAR_DECL:
    1350        29462 :     case PARM_DECL:
    1351        29462 :     case FIELD_DECL:
    1352        29462 :     case CONST_DECL:
    1353        29462 :     case FUNCTION_DECL:
    1354        29462 :     case LABEL_DECL:
    1355        29462 :       pp_c_tree_decl_identifier (this, e);
    1356        29462 :       break;
    1357              : 
    1358          196 :     case IDENTIFIER_NODE:
    1359          196 :       pp_c_tree_identifier (this, e);
    1360          196 :       break;
    1361              : 
    1362           24 :     case ERROR_MARK:
    1363           24 :       translate_string ("<erroneous-expression>");
    1364           24 :       break;
    1365              : 
    1366           30 :     case RESULT_DECL:
    1367           30 :       translate_string ("<return-value>");
    1368           30 :       break;
    1369              : 
    1370         1134 :     case VOID_CST:
    1371         1134 :     case INTEGER_CST:
    1372         1134 :     case REAL_CST:
    1373         1134 :     case FIXED_CST:
    1374         1134 :     case STRING_CST:
    1375         1134 :       constant (e);
    1376         1134 :       break;
    1377              : 
    1378            1 :     case TARGET_EXPR:
    1379            1 :       pp_c_ws_string (this, "__builtin_memcpy");
    1380            1 :       pp_c_left_paren (this);
    1381            1 :       pp_ampersand (this);
    1382            1 :       primary_expression (TARGET_EXPR_SLOT (e));
    1383            1 :       pp_separate_with (this, ',');
    1384            1 :       pp_ampersand (this);
    1385            1 :       initializer (TARGET_EXPR_INITIAL (e));
    1386            1 :       if (TARGET_EXPR_CLEANUP (e))
    1387              :         {
    1388            0 :           pp_separate_with (this, ',');
    1389            0 :           expression (TARGET_EXPR_CLEANUP (e));
    1390              :         }
    1391            1 :       pp_c_right_paren (this);
    1392            1 :       break;
    1393              : 
    1394          838 :     case SSA_NAME:
    1395          838 :       if (SSA_NAME_VAR (e))
    1396          789 :         primary_expression (SSA_NAME_VAR (e));
    1397           49 :       else if (gimple_assign_single_p (SSA_NAME_DEF_STMT (e)))
    1398              :         {
    1399              :           /* Print only the right side of the GIMPLE assignment.  */
    1400            6 :           gimple *def_stmt = SSA_NAME_DEF_STMT (e);
    1401            6 :           pp_gimple_stmt_1 (this, def_stmt, 0, TDF_RHS_ONLY);
    1402              :         }
    1403              :       else
    1404           43 :         expression (e);
    1405              :       break;
    1406              : 
    1407         6648 :     default:
    1408              :       /* FIXME:  Make sure we won't get into an infinite loop.  */
    1409         6648 :       if (location_wrapper_p (e))
    1410          341 :         expression (e);
    1411              :       else
    1412              :         {
    1413         6307 :           pp_c_left_paren (this);
    1414         6307 :           expression (e);
    1415         6307 :           pp_c_right_paren (this);
    1416              :         }
    1417              :       break;
    1418              :     }
    1419        38333 : }
    1420              : 
    1421              : /* Print out a C initializer -- also support C compound-literals.
    1422              :    initializer:
    1423              :       assignment-expression:
    1424              :       { initializer-list }
    1425              :       { initializer-list , }   */
    1426              : 
    1427              : void
    1428           28 : c_pretty_printer::initializer (tree e)
    1429              : {
    1430           28 :   if (TREE_CODE (e) == CONSTRUCTOR)
    1431           27 :     pp_c_brace_enclosed_initializer_list (this, e);
    1432              :   else
    1433            1 :     expression (e);
    1434           28 : }
    1435              : 
    1436              : /* init-declarator:
    1437              :       declarator:
    1438              :       declarator = initializer   */
    1439              : 
    1440              : void
    1441            0 : pp_c_init_declarator (c_pretty_printer *pp, tree t)
    1442              : {
    1443            0 :   pp->declarator (t);
    1444              :   /* We don't want to output function definitions here.  There are handled
    1445              :      elsewhere (and the syntactic form is bogus anyway).  */
    1446            0 :   if (TREE_CODE (t) != FUNCTION_DECL && DECL_INITIAL (t))
    1447              :     {
    1448            0 :       tree init = DECL_INITIAL (t);
    1449              :       /* This C++ bit is handled here because it is easier to do so.
    1450              :          In templates, the C++ parser builds a TREE_LIST for a
    1451              :          direct-initialization; the TREE_PURPOSE is the variable to
    1452              :          initialize and the TREE_VALUE is the initializer.  */
    1453            0 :       if (TREE_CODE (init) == TREE_LIST)
    1454              :         {
    1455            0 :           pp_c_left_paren (pp);
    1456            0 :           pp->expression (TREE_VALUE (init));
    1457            0 :           pp_right_paren (pp);
    1458              :         }
    1459              :       else
    1460              :         {
    1461            0 :           pp_space (pp);
    1462            0 :           pp_equal (pp);
    1463            0 :           pp_space (pp);
    1464            0 :           pp->initializer (init);
    1465              :         }
    1466              :     }
    1467            0 : }
    1468              : 
    1469              : /* initializer-list:
    1470              :       designation(opt) initializer
    1471              :       initializer-list , designation(opt) initializer
    1472              : 
    1473              :    designation:
    1474              :       designator-list =
    1475              : 
    1476              :    designator-list:
    1477              :       designator
    1478              :       designator-list designator
    1479              : 
    1480              :    designator:
    1481              :       [ constant-expression ]
    1482              :       identifier   */
    1483              : 
    1484              : static void
    1485           93 : pp_c_initializer_list (c_pretty_printer *pp, tree e)
    1486              : {
    1487           93 :   tree type = TREE_TYPE (e);
    1488           93 :   const enum tree_code code = TREE_CODE (type);
    1489              : 
    1490           93 :   if (TREE_CODE (e) == CONSTRUCTOR)
    1491              :     {
    1492           27 :       pp_c_constructor_elts (pp, CONSTRUCTOR_ELTS (e));
    1493           27 :       return;
    1494              :     }
    1495              : 
    1496           66 :   switch (code)
    1497              :     {
    1498            0 :     case RECORD_TYPE:
    1499            0 :     case UNION_TYPE:
    1500            0 :     case ARRAY_TYPE:
    1501            0 :       {
    1502            0 :         tree init = TREE_OPERAND (e, 0);
    1503            0 :         for (; init != NULL_TREE; init = TREE_CHAIN (init))
    1504              :           {
    1505            0 :             if (code == RECORD_TYPE || code == UNION_TYPE)
    1506              :               {
    1507            0 :                 pp_c_dot (pp);
    1508            0 :                 pp->primary_expression (TREE_PURPOSE (init));
    1509              :               }
    1510              :             else
    1511              :               {
    1512            0 :                 pp_c_left_bracket (pp);
    1513            0 :                 if (TREE_PURPOSE (init))
    1514            0 :                   pp->constant (TREE_PURPOSE (init));
    1515            0 :                 pp_c_right_bracket (pp);
    1516              :               }
    1517            0 :             pp_c_whitespace (pp);
    1518            0 :             pp_equal (pp);
    1519            0 :             pp_c_whitespace (pp);
    1520            0 :             pp->initializer (TREE_VALUE (init));
    1521            0 :             if (TREE_CHAIN (init))
    1522            0 :               pp_separate_with (pp, ',');
    1523              :           }
    1524              :       }
    1525              :       return;
    1526              : 
    1527            6 :     case VECTOR_TYPE:
    1528            6 :       if (TREE_CODE (e) == VECTOR_CST)
    1529              :         {
    1530              :           /* We don't create variable-length VECTOR_CSTs.  */
    1531            6 :           unsigned int nunits = VECTOR_CST_NELTS (e).to_constant ();
    1532           30 :           for (unsigned int i = 0; i < nunits; ++i)
    1533              :             {
    1534           24 :               if (i > 0)
    1535           18 :                 pp_separate_with (pp, ',');
    1536           24 :               pp->expression (VECTOR_CST_ELT (e, i));
    1537              :             }
    1538              :         }
    1539              :       else
    1540              :         break;
    1541              :       return;
    1542              : 
    1543           60 :     case COMPLEX_TYPE:
    1544           60 :       if (TREE_CODE (e) == COMPLEX_CST || TREE_CODE (e) == COMPLEX_EXPR)
    1545              :         {
    1546           60 :           const bool cst = TREE_CODE (e) == COMPLEX_CST;
    1547           60 :           pp->expression (cst ? TREE_REALPART (e) : TREE_OPERAND (e, 0));
    1548           60 :           pp_separate_with (pp, ',');
    1549          114 :           pp->expression (cst ? TREE_IMAGPART (e) : TREE_OPERAND (e, 1));
    1550              :         }
    1551              :       else
    1552              :         break;
    1553           60 :       return;
    1554              : 
    1555              :     default:
    1556              :       break;
    1557              :     }
    1558              : 
    1559            0 :   pp_unsupported_tree (pp, type);
    1560              : }
    1561              : 
    1562              : /* Pretty-print a brace-enclosed initializer-list.  */
    1563              : 
    1564              : static void
    1565           93 : pp_c_brace_enclosed_initializer_list (c_pretty_printer *pp, tree l)
    1566              : {
    1567           93 :   pp_c_left_brace (pp);
    1568           93 :   pp_c_initializer_list (pp, l);
    1569           93 :   pp_c_right_brace (pp);
    1570           93 : }
    1571              : 
    1572              : 
    1573              : /*  This is a convenient function, used to bridge gap between C and C++
    1574              :     grammars.
    1575              : 
    1576              :     id-expression:
    1577              :        identifier  */
    1578              : 
    1579              : void
    1580        31348 : c_pretty_printer::id_expression (tree t)
    1581              : {
    1582        31348 :   switch (TREE_CODE (t))
    1583              :     {
    1584        29202 :     case VAR_DECL:
    1585        29202 :     case PARM_DECL:
    1586        29202 :     case CONST_DECL:
    1587        29202 :     case TYPE_DECL:
    1588        29202 :     case FUNCTION_DECL:
    1589        29202 :     case FIELD_DECL:
    1590        29202 :     case LABEL_DECL:
    1591        29202 :       pp_c_tree_decl_identifier (this, t);
    1592        29202 :       break;
    1593              : 
    1594         2146 :     case IDENTIFIER_NODE:
    1595         2146 :       pp_c_tree_identifier (this, t);
    1596         2146 :       break;
    1597              : 
    1598            0 :     default:
    1599            0 :       pp_unsupported_tree (this, t);
    1600            0 :       break;
    1601              :     }
    1602        31348 : }
    1603              : 
    1604              : /* postfix-expression:
    1605              :       primary-expression
    1606              :       postfix-expression [ expression ]
    1607              :       postfix-expression ( argument-expression-list(opt) )
    1608              :       postfix-expression . identifier
    1609              :       postfix-expression -> identifier
    1610              :       postfix-expression ++
    1611              :       postfix-expression --
    1612              :       ( type-name ) { initializer-list }
    1613              :       ( type-name ) { initializer-list , }  */
    1614              : 
    1615              : void
    1616        13780 : c_pretty_printer::postfix_expression (tree e)
    1617              : {
    1618        13780 :   enum tree_code code = TREE_CODE (e);
    1619        13780 :   switch (code)
    1620              :     {
    1621            0 :     case POSTINCREMENT_EXPR:
    1622            0 :     case POSTDECREMENT_EXPR:
    1623            0 :       postfix_expression (TREE_OPERAND (e, 0));
    1624            0 :       pp_string (this, code == POSTINCREMENT_EXPR ? "++" : "--");
    1625            0 :       break;
    1626              : 
    1627          691 :     case ARRAY_REF:
    1628          691 :       postfix_expression (TREE_OPERAND (e, 0));
    1629          691 :       pp_c_left_bracket (this);
    1630          691 :       expression (TREE_OPERAND (e, 1));
    1631          691 :       pp_c_right_bracket (this);
    1632          691 :       break;
    1633              : 
    1634            6 :     case OMP_ARRAY_SECTION:
    1635            6 :       postfix_expression (TREE_OPERAND (e, 0));
    1636            6 :       pp_c_left_bracket (this);
    1637            6 :       if (TREE_OPERAND (e, 1))
    1638            4 :         expression (TREE_OPERAND (e, 1));
    1639            6 :       pp_colon (this);
    1640            6 :       if (TREE_OPERAND (e, 2))
    1641            6 :         expression (TREE_OPERAND (e, 2));
    1642            6 :       pp_c_right_bracket (this);
    1643            6 :       break;
    1644              : 
    1645          146 :     case CALL_EXPR:
    1646          146 :       {
    1647          146 :         call_expr_arg_iterator iter;
    1648          146 :         tree arg;
    1649          146 :         if (CALL_EXPR_FN (e) != NULL_TREE)
    1650          145 :           postfix_expression (CALL_EXPR_FN (e));
    1651              :         else
    1652            1 :           pp_string (this, internal_fn_name (CALL_EXPR_IFN (e)));
    1653          146 :         pp_c_left_paren (this);
    1654          413 :         FOR_EACH_CALL_EXPR_ARG (arg, iter, e)
    1655              :           {
    1656          121 :             expression (arg);
    1657          121 :             if (more_call_expr_args_p (&iter))
    1658            0 :               pp_separate_with (this, ',');
    1659              :           }
    1660          146 :         pp_c_right_paren (this);
    1661          146 :         break;
    1662              :       }
    1663              : 
    1664            0 :     case UNORDERED_EXPR:
    1665            0 :       pp_c_ws_string (this, flag_isoc99
    1666              :                            ? "isunordered"
    1667              :                            : "__builtin_isunordered");
    1668            0 :       goto two_args_fun;
    1669              : 
    1670            0 :     case ORDERED_EXPR:
    1671            0 :       pp_c_ws_string (this, flag_isoc99
    1672              :                            ? "!isunordered"
    1673              :                            : "!__builtin_isunordered");
    1674            0 :       goto two_args_fun;
    1675              : 
    1676            0 :     case UNLT_EXPR:
    1677            0 :       pp_c_ws_string (this, flag_isoc99
    1678              :                            ? "!isgreaterequal"
    1679              :                            : "!__builtin_isgreaterequal");
    1680            0 :       goto two_args_fun;
    1681              : 
    1682            0 :     case UNLE_EXPR:
    1683            0 :       pp_c_ws_string (this, flag_isoc99
    1684              :                            ? "!isgreater"
    1685              :                            : "!__builtin_isgreater");
    1686            0 :       goto two_args_fun;
    1687              : 
    1688            0 :     case UNGT_EXPR:
    1689            0 :       pp_c_ws_string (this, flag_isoc99
    1690              :                            ? "!islessequal"
    1691              :                            : "!__builtin_islessequal");
    1692            0 :       goto two_args_fun;
    1693              : 
    1694            0 :     case UNGE_EXPR:
    1695            0 :       pp_c_ws_string (this, flag_isoc99
    1696              :                            ? "!isless"
    1697              :                            : "!__builtin_isless");
    1698            0 :       goto two_args_fun;
    1699              : 
    1700            0 :     case UNEQ_EXPR:
    1701            0 :       pp_c_ws_string (this, flag_isoc99
    1702              :                            ? "!islessgreater"
    1703              :                            : "!__builtin_islessgreater");
    1704            0 :       goto two_args_fun;
    1705              : 
    1706            0 :     case LTGT_EXPR:
    1707            0 :       pp_c_ws_string (this, flag_isoc99
    1708              :                            ? "islessgreater"
    1709              :                            : "__builtin_islessgreater");
    1710            0 :       goto two_args_fun;
    1711              : 
    1712            1 :     case MAX_EXPR:
    1713            1 :       pp_c_ws_string (this, "max");
    1714            1 :       goto two_args_fun;
    1715              : 
    1716            1 :     case MIN_EXPR:
    1717            1 :       pp_c_ws_string (this, "min");
    1718            1 :       goto two_args_fun;
    1719              : 
    1720            2 :     two_args_fun:
    1721            2 :       pp_c_left_paren (this);
    1722            2 :       expression (TREE_OPERAND (e, 0));
    1723            2 :       pp_separate_with (this, ',');
    1724            2 :       expression (TREE_OPERAND (e, 1));
    1725            2 :       pp_c_right_paren (this);
    1726            2 :       break;
    1727              : 
    1728            0 :     case ABS_EXPR:
    1729            0 :       pp_c_ws_string (this, "__builtin_abs");
    1730            0 :       pp_c_left_paren (this);
    1731            0 :       expression (TREE_OPERAND (e, 0));
    1732            0 :       pp_c_right_paren (this);
    1733            0 :       break;
    1734              : 
    1735          935 :     case COMPONENT_REF:
    1736          935 :       {
    1737          935 :         tree object = TREE_OPERAND (e, 0);
    1738          935 :         if (INDIRECT_REF_P (object))
    1739              :           {
    1740          157 :             postfix_expression (TREE_OPERAND (object, 0));
    1741          157 :             pp_c_arrow (this);
    1742              :           }
    1743              :         else
    1744              :           {
    1745          778 :             postfix_expression (object);
    1746          778 :             pp_c_dot (this);
    1747              :           }
    1748          935 :         expression (TREE_OPERAND (e, 1));
    1749              :       }
    1750          935 :       break;
    1751              : 
    1752           12 :     case BIT_FIELD_REF:
    1753           12 :       {
    1754           12 :         tree type = TREE_TYPE (e);
    1755              : 
    1756           12 :         type = signed_or_unsigned_type_for (TYPE_UNSIGNED (type), type);
    1757           12 :         if (type
    1758           12 :             && tree_int_cst_equal (TYPE_SIZE (type), TREE_OPERAND (e, 1)))
    1759              :           {
    1760           12 :             HOST_WIDE_INT bitpos = tree_to_shwi (TREE_OPERAND (e, 2));
    1761           12 :             HOST_WIDE_INT size = tree_to_shwi (TYPE_SIZE (type));
    1762           12 :             if ((bitpos % size) == 0)
    1763              :               {
    1764           12 :                 pp_c_left_paren (this);
    1765           12 :                 pp_c_left_paren (this);
    1766           12 :                 type_id (type);
    1767           12 :                 pp_c_star (this);
    1768           12 :                 pp_c_right_paren (this);
    1769           12 :                 pp_c_ampersand (this);
    1770           12 :                 expression (TREE_OPERAND (e, 0));
    1771           12 :                 pp_c_right_paren (this);
    1772           12 :                 pp_c_left_bracket (this);
    1773           12 :                 pp_wide_integer (this, bitpos / size);
    1774           12 :                 pp_c_right_bracket (this);
    1775           12 :                 break;
    1776              :               }
    1777              :           }
    1778            0 :         pp_unsupported_tree (this, e);
    1779              :       }
    1780            0 :       break;
    1781              : 
    1782          127 :     case MEM_REF:
    1783          127 :     case TARGET_MEM_REF:
    1784          127 :       expression (e);
    1785          127 :       break;
    1786              : 
    1787           60 :     case COMPLEX_CST:
    1788           60 :     case VECTOR_CST:
    1789           60 :       pp_c_compound_literal (this, e);
    1790           60 :       break;
    1791              : 
    1792           24 :     case COMPLEX_EXPR:
    1793           24 :       pp_c_complex_expr (this, e);
    1794           24 :       break;
    1795              : 
    1796            4 :     case COMPOUND_LITERAL_EXPR:
    1797            4 :       e = DECL_INITIAL (COMPOUND_LITERAL_EXPR_DECL (e));
    1798              :       /* Fall through.  */
    1799           27 :     case CONSTRUCTOR:
    1800           27 :       initializer (e);
    1801           27 :       break;
    1802              : 
    1803            0 :     case VA_ARG_EXPR:
    1804            0 :       pp_c_ws_string (this, "__builtin_va_arg");
    1805            0 :       pp_c_left_paren (this);
    1806            0 :       assignment_expression (TREE_OPERAND (e, 0));
    1807            0 :       pp_separate_with (this, ',');
    1808            0 :       type_id (TREE_TYPE (e));
    1809            0 :       pp_c_right_paren (this);
    1810            0 :       break;
    1811              : 
    1812          139 :     case ADDR_EXPR:
    1813          139 :       if (TREE_CODE (TREE_OPERAND (e, 0)) == FUNCTION_DECL)
    1814              :         {
    1815          139 :           id_expression (TREE_OPERAND (e, 0));
    1816          139 :           break;
    1817              :         }
    1818              :       /* fall through.  */
    1819              : 
    1820        11611 :     default:
    1821        11611 :       primary_expression (e);
    1822        11611 :       break;
    1823              :     }
    1824        13780 : }
    1825              : 
    1826              : /* Print out an expression-list; E is expected to be a TREE_LIST.  */
    1827              : 
    1828              : void
    1829          669 : pp_c_expression_list (c_pretty_printer *pp, tree e)
    1830              : {
    1831         1338 :   for (; e != NULL_TREE; e = TREE_CHAIN (e))
    1832              :     {
    1833          669 :       pp->expression (TREE_VALUE (e));
    1834          669 :       if (TREE_CHAIN (e))
    1835            0 :         pp_separate_with (pp, ',');
    1836              :     }
    1837          669 : }
    1838              : 
    1839              : /* Print out V, which contains the elements of a constructor.  */
    1840              : 
    1841              : void
    1842           27 : pp_c_constructor_elts (c_pretty_printer *pp, vec<constructor_elt, va_gc> *v)
    1843              : {
    1844           27 :   unsigned HOST_WIDE_INT ix;
    1845           27 :   tree value;
    1846              : 
    1847           38 :   FOR_EACH_CONSTRUCTOR_VALUE (v, ix, value)
    1848              :     {
    1849           11 :       pp->expression (value);
    1850           11 :       if (ix != vec_safe_length (v) - 1)
    1851            1 :         pp_separate_with (pp, ',');
    1852              :     }
    1853           27 : }
    1854              : 
    1855              : /* Print out an expression-list in parens, as if it were the argument
    1856              :    list to a function.  */
    1857              : 
    1858              : void
    1859          696 : pp_c_call_argument_list (c_pretty_printer *pp, tree t)
    1860              : {
    1861          696 :   pp_c_left_paren (pp);
    1862          696 :   if (t && TREE_CODE (t) == TREE_LIST)
    1863          669 :     pp_c_expression_list (pp, t);
    1864          696 :   pp_c_right_paren (pp);
    1865          696 : }
    1866              : 
    1867              : /* Try to fold *(type *)&op into op.fld.fld2[1] if possible.
    1868              :    Only used for printing expressions.  Should punt if ambiguous
    1869              :    (e.g. in unions).  */
    1870              : 
    1871              : static tree
    1872          725 : c_fold_indirect_ref_for_warn (location_t loc, tree type, tree op,
    1873              :                               offset_int &off)
    1874              : {
    1875          725 :   tree optype = TREE_TYPE (op);
    1876          725 :   if (off == 0)
    1877              :     {
    1878          653 :       if (lang_hooks.types_compatible_p (optype, type))
    1879              :         return op;
    1880              :       /* *(foo *)&complexfoo => __real__ complexfoo */
    1881          364 :       else if (TREE_CODE (optype) == COMPLEX_TYPE
    1882          364 :                && lang_hooks.types_compatible_p (type, TREE_TYPE (optype)))
    1883            0 :         return build1_loc (loc, REALPART_EXPR, type, op);
    1884              :     }
    1885              :   /* ((foo*)&complexfoo)[1] => __imag__ complexfoo */
    1886           72 :   else if (TREE_CODE (optype) == COMPLEX_TYPE
    1887            0 :            && lang_hooks.types_compatible_p (type, TREE_TYPE (optype))
    1888           72 :            && tree_to_uhwi (TYPE_SIZE_UNIT (type)) == off)
    1889              :     {
    1890            0 :       off = 0;
    1891            0 :       return build1_loc (loc, IMAGPART_EXPR, type, op);
    1892              :     }
    1893              :   /* ((foo *)&fooarray)[x] => fooarray[x] */
    1894          436 :   if (TREE_CODE (optype) == ARRAY_TYPE
    1895          303 :       && TYPE_SIZE_UNIT (TREE_TYPE (optype))
    1896          303 :       && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (optype))) == INTEGER_CST
    1897          739 :       && !integer_zerop (TYPE_SIZE_UNIT (TREE_TYPE (optype))))
    1898              :     {
    1899          303 :       tree type_domain = TYPE_DOMAIN (optype);
    1900          303 :       tree min_val = size_zero_node;
    1901          303 :       if (type_domain && TYPE_MIN_VALUE (type_domain))
    1902          303 :         min_val = TYPE_MIN_VALUE (type_domain);
    1903          303 :       offset_int el_sz = wi::to_offset (TYPE_SIZE_UNIT (TREE_TYPE (optype)));
    1904          303 :       offset_int idx = off / el_sz;
    1905          303 :       offset_int rem = off % el_sz;
    1906          303 :       if (TREE_CODE (min_val) == INTEGER_CST)
    1907              :         {
    1908          303 :           tree index
    1909          303 :             = wide_int_to_tree (sizetype, idx + wi::to_offset (min_val));
    1910          303 :           op = build4_loc (loc, ARRAY_REF, TREE_TYPE (optype), op, index,
    1911              :                            NULL_TREE, NULL_TREE);
    1912          303 :           off = rem;
    1913          303 :           if (tree ret = c_fold_indirect_ref_for_warn (loc, type, op, off))
    1914          303 :             return ret;
    1915           22 :           return op;
    1916              :         }
    1917              :     }
    1918              :   /* ((foo *)&struct_with_foo_field)[x] => COMPONENT_REF */
    1919          133 :   else if (TREE_CODE (optype) == RECORD_TYPE)
    1920              :     {
    1921           79 :       for (tree field = TYPE_FIELDS (optype);
    1922          691 :            field; field = DECL_CHAIN (field))
    1923          686 :         if (TREE_CODE (field) == FIELD_DECL
    1924          138 :             && TREE_TYPE (field) != error_mark_node
    1925          138 :             && TYPE_SIZE_UNIT (TREE_TYPE (field))
    1926          824 :             && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (field))) == INTEGER_CST)
    1927              :           {
    1928          138 :             tree pos = byte_position (field);
    1929          138 :             if (TREE_CODE (pos) != INTEGER_CST)
    1930            0 :               continue;
    1931          138 :             offset_int upos = wi::to_offset (pos);
    1932          138 :             offset_int el_sz
    1933          138 :               = wi::to_offset (TYPE_SIZE_UNIT (TREE_TYPE (field)));
    1934          276 :             if (upos <= off && off < upos + el_sz)
    1935              :               {
    1936              :                 /* The C++ pretty printers print scope of the FIELD_DECLs,
    1937              :                    so punt if it is something that can't be printed.  */
    1938           74 :                 if (c_dialect_cxx ())
    1939           44 :                   if (tree scope = get_containing_scope (field))
    1940           44 :                     if (TYPE_P (scope) && TYPE_NAME (scope) == NULL_TREE)
    1941              :                       break;
    1942           70 :                 tree cop = build3_loc (loc, COMPONENT_REF, TREE_TYPE (field),
    1943              :                                        op, field, NULL_TREE);
    1944           70 :                 off = off - upos;
    1945           70 :                 if (tree ret = c_fold_indirect_ref_for_warn (loc, type, cop,
    1946              :                                                              off))
    1947           70 :                   return ret;
    1948           14 :                 return cop;
    1949              :               }
    1950              :           }
    1951              :     }
    1952              :   /* Similarly for unions, but in this case try to be very conservative,
    1953              :      only match if some field has type compatible with type and it is the
    1954              :      only such field.  */
    1955           54 :   else if (TREE_CODE (optype) == UNION_TYPE)
    1956              :     {
    1957            2 :       tree fld = NULL_TREE;
    1958            2 :       for (tree field = TYPE_FIELDS (optype);
    1959            8 :            field; field = DECL_CHAIN (field))
    1960            6 :         if (TREE_CODE (field) == FIELD_DECL
    1961            6 :             && TREE_TYPE (field) != error_mark_node
    1962           12 :             && lang_hooks.types_compatible_p (TREE_TYPE (field), type))
    1963              :           {
    1964            2 :             if (fld)
    1965              :               return NULL_TREE;
    1966              :             else
    1967              :               fld = field;
    1968              :           }
    1969            2 :       if (fld)
    1970              :         {
    1971            2 :           off = 0;
    1972            2 :           return build3_loc (loc, COMPONENT_REF, TREE_TYPE (fld), op, fld,
    1973            2 :                              NULL_TREE);
    1974              :         }
    1975              :     }
    1976              : 
    1977              :   return NULL_TREE;
    1978              : }
    1979              : 
    1980              : /* Print the MEM_REF expression REF, including its type and offset.
    1981              :    Apply casts as necessary if the type of the access is different
    1982              :    from the type of the accessed object.  Produce compact output
    1983              :    designed to include both the element index as well as any
    1984              :    misalignment by preferring
    1985              :      ((int*)((char*)p + 1))[2]
    1986              :    over
    1987              :      *(int*)((char*)p + 9)
    1988              :    The former is more verbose but makes it clearer that the access
    1989              :    to the third element of the array is misaligned by one byte.  */
    1990              : 
    1991              : static void
    1992          966 : print_mem_ref (c_pretty_printer *pp, tree e)
    1993              : {
    1994          966 :   tree arg = TREE_OPERAND (e, 0);
    1995              : 
    1996              :   /* The byte offset.  Initially equal to the MEM_REF offset, then
    1997              :      adjusted to the remainder of the division by the byte size of
    1998              :      the access.  */
    1999          966 :   offset_int byte_off = wi::to_offset (TREE_OPERAND (e, 1));
    2000              :   /* The result of dividing BYTE_OFF by the size of the access.  */
    2001          966 :   offset_int elt_idx = 0;
    2002              :   /* True to include a cast to char* (for a nonzero final BYTE_OFF).  */
    2003          966 :   bool char_cast = false;
    2004          966 :   tree op = NULL_TREE;
    2005          966 :   bool array_ref_only = false;
    2006          966 :   if (TREE_CODE (arg) == ADDR_EXPR)
    2007              :     {
    2008          352 :       op = c_fold_indirect_ref_for_warn (EXPR_LOCATION (e), TREE_TYPE (e),
    2009          352 :                                          TREE_OPERAND (arg, 0), byte_off);
    2010              :       /* Try to fold it back to component, array ref or their combination,
    2011              :          but print it only if the types and TBAA types are compatible.  */
    2012          352 :       if (op
    2013          616 :           && byte_off == 0
    2014          327 :           && lang_hooks.types_compatible_p (TREE_TYPE (e), TREE_TYPE (op))
    2015          643 :           && (!flag_strict_aliasing
    2016           28 :               || (get_deref_alias_set (TREE_OPERAND (e, 1))
    2017           14 :                   == get_alias_set (op))))
    2018              :         {
    2019          289 :           pp->expression (op);
    2020          289 :           return;
    2021              :         }
    2022           63 :       if (op == NULL_TREE)
    2023           25 :         op = TREE_OPERAND (arg, 0);
    2024              :       /* If the types or TBAA types are incompatible, undo the
    2025              :          UNION_TYPE handling from c_fold_indirect_ref_for_warn, and similarly
    2026              :          undo __real__/__imag__ the code below doesn't try to handle.  */
    2027           63 :       if (op != TREE_OPERAND (arg, 0)
    2028           63 :           && ((TREE_CODE (op) == COMPONENT_REF
    2029           16 :                && TREE_CODE (TREE_TYPE (TREE_OPERAND (op, 0))) == UNION_TYPE)
    2030           36 :               || TREE_CODE (op) == REALPART_EXPR
    2031           36 :               || TREE_CODE (op) == IMAGPART_EXPR))
    2032            2 :         op = TREE_OPERAND (op, 0);
    2033           63 :       if (op != TREE_OPERAND (arg, 0))
    2034              :         {
    2035           62 :           array_ref_only = true;
    2036           62 :           for (tree ref = op; ref != TREE_OPERAND (arg, 0);
    2037           24 :                ref = TREE_OPERAND (ref, 0))
    2038           42 :             if (TREE_CODE (ref) != ARRAY_REF)
    2039              :               {
    2040              :                 array_ref_only = false;
    2041              :                 break;
    2042              :               }
    2043              :         }
    2044              :     }
    2045              : 
    2046          677 :   tree access_type = TREE_TYPE (e);
    2047          677 :   tree arg_type = TREE_TYPE (TREE_TYPE (arg));
    2048          677 :   if (tree access_size = TYPE_SIZE_UNIT (access_type))
    2049         1281 :     if (byte_off != 0
    2050           74 :         && TREE_CODE (access_size) == INTEGER_CST
    2051          750 :         && !integer_zerop (access_size))
    2052              :       {
    2053           73 :         offset_int asize = wi::to_offset (access_size);
    2054           73 :         elt_idx = byte_off / asize;
    2055           73 :         byte_off = byte_off % asize;
    2056              :       }
    2057              : 
    2058              :   /* True to include a cast to the accessed type.  */
    2059          677 :   const bool access_cast
    2060           63 :     = ((op && op != TREE_OPERAND (arg, 0))
    2061          639 :        || VOID_TYPE_P (arg_type)
    2062         1275 :        || !lang_hooks.types_compatible_p (access_type, arg_type));
    2063          677 :   const bool has_off = byte_off != 0 || (op && op != TREE_OPERAND (arg, 0));
    2064              : 
    2065          677 :   if (has_off && (byte_off != 0 || !array_ref_only))
    2066              :     {
    2067              :       /* When printing the byte offset for a pointer to a type of
    2068              :          a different size than char, include a cast to char* first,
    2069              :          before printing the cast to a pointer to the accessed type.  */
    2070           49 :       tree size = TYPE_SIZE (arg_type);
    2071           49 :       if (size == NULL_TREE
    2072           49 :           || TREE_CODE (size) != INTEGER_CST
    2073           98 :           || wi::to_wide (size) != BITS_PER_UNIT)
    2074              :         char_cast = true;
    2075              :     }
    2076              : 
    2077          677 :   if (elt_idx == 0)
    2078          616 :     pp_c_star (pp);
    2079           61 :   else if (access_cast || char_cast)
    2080           33 :     pp_c_left_paren (pp);
    2081              : 
    2082          649 :   if (access_cast)
    2083              :     {
    2084              :       /* Include a cast to the accessed type if it isn't compatible
    2085              :          with the type of the referenced object (or if the object
    2086              :          is typeless).  */
    2087          137 :       pp_c_left_paren (pp);
    2088          137 :       pp->type_id (build_pointer_type (access_type));
    2089          137 :       pp_c_right_paren (pp);
    2090              :     }
    2091              : 
    2092          677 :   if (has_off)
    2093           69 :     pp_c_left_paren (pp);
    2094              : 
    2095          677 :   if (char_cast)
    2096              :     {
    2097              :       /* Include a cast to char *.  */
    2098           43 :       pp_c_left_paren (pp);
    2099           43 :       pp->type_id (string_type_node);
    2100           43 :       pp_c_right_paren (pp);
    2101              :     }
    2102              : 
    2103          677 :   pp->unary_expression (arg);
    2104              : 
    2105          677 :   if (op && op != TREE_OPERAND (arg, 0))
    2106              :     {
    2107           38 :       auto_vec<tree, 16> refs;
    2108           38 :       tree ref;
    2109           38 :       unsigned i;
    2110           38 :       bool array_refs = true;
    2111          122 :       for (ref = op; ref != TREE_OPERAND (arg, 0); ref = TREE_OPERAND (ref, 0))
    2112           84 :         refs.safe_push (ref);
    2113          198 :       FOR_EACH_VEC_ELT_REVERSE (refs, i, ref)
    2114           84 :         if (array_refs && TREE_CODE (ref) == ARRAY_REF)
    2115              :           {
    2116           26 :             pp_c_left_bracket (pp);
    2117           26 :             pp->expression (TREE_OPERAND (ref, 1));
    2118           26 :             pp_c_right_bracket (pp);
    2119              :           }
    2120              :         else
    2121              :           {
    2122           18 :             if (array_refs)
    2123              :               {
    2124           18 :                 array_refs = false;
    2125           18 :                 pp_string (pp, " + offsetof");
    2126           18 :                 pp_c_left_paren (pp);
    2127           18 :                 pp->type_id (TREE_TYPE (TREE_OPERAND (ref, 0)));
    2128           18 :                 pp_comma (pp);
    2129              :               }
    2130           40 :             else if (TREE_CODE (ref) == COMPONENT_REF)
    2131           38 :               pp_c_dot (pp);
    2132           58 :             if (TREE_CODE (ref) == COMPONENT_REF)
    2133           56 :               pp->expression (TREE_OPERAND (ref, 1));
    2134              :             else
    2135              :               {
    2136            2 :                 pp_c_left_bracket (pp);
    2137            2 :                 pp->expression (TREE_OPERAND (ref, 1));
    2138            2 :                 pp_c_right_bracket (pp);
    2139              :               }
    2140              :           }
    2141           38 :       if (!array_refs)
    2142           18 :         pp_c_right_paren (pp);
    2143           38 :     }
    2144              : 
    2145          677 :   if (byte_off != 0)
    2146              :     {
    2147           31 :       pp_space (pp);
    2148           31 :       pp_plus (pp);
    2149           31 :       pp_space (pp);
    2150           31 :       tree off = wide_int_to_tree (ssizetype, byte_off);
    2151           31 :       pp->constant (off);
    2152              :     }
    2153              : 
    2154          677 :   if (has_off)
    2155           69 :     pp_c_right_paren (pp);
    2156              : 
    2157          677 :   if (elt_idx != 0)
    2158              :     {
    2159           61 :       if (access_cast || char_cast)
    2160           33 :         pp_c_right_paren (pp);
    2161              : 
    2162           61 :       pp_c_left_bracket (pp);
    2163           61 :       tree idx = wide_int_to_tree (ssizetype, elt_idx);
    2164           61 :       pp->constant (idx);
    2165           61 :       pp_c_right_bracket (pp);
    2166              :     }
    2167              : }
    2168              : 
    2169              : /* unary-expression:
    2170              :       postfix-expression
    2171              :       ++ cast-expression
    2172              :       -- cast-expression
    2173              :       unary-operator cast-expression
    2174              :       sizeof unary-expression
    2175              :       sizeof ( type-id )
    2176              : 
    2177              :   unary-operator: one of
    2178              :       * &  + - ! ~
    2179              : 
    2180              :    GNU extensions.
    2181              :    unary-expression:
    2182              :       __alignof__ unary-expression
    2183              :       __alignof__ ( type-id )
    2184              :       __real__ unary-expression
    2185              :       __imag__ unary-expression  */
    2186              : 
    2187              : void
    2188         9870 : c_pretty_printer::unary_expression (tree e)
    2189              : {
    2190         9870 :   enum tree_code code = TREE_CODE (e);
    2191         9870 :   switch (code)
    2192              :     {
    2193            1 :     case PREINCREMENT_EXPR:
    2194            1 :     case PREDECREMENT_EXPR:
    2195            1 :       pp_string (this, code == PREINCREMENT_EXPR ? "++" : "--");
    2196            1 :       unary_expression (TREE_OPERAND (e, 0));
    2197            1 :       break;
    2198              : 
    2199         1992 :     case ADDR_EXPR:
    2200         1992 :     case INDIRECT_REF:
    2201         1992 :     case NEGATE_EXPR:
    2202         1992 :     case BIT_NOT_EXPR:
    2203         1992 :     case TRUTH_NOT_EXPR:
    2204         1992 :     case CONJ_EXPR:
    2205              :       /* String literal are used by address.  */
    2206         1992 :       if (code == ADDR_EXPR && TREE_CODE (TREE_OPERAND (e, 0)) != STRING_CST)
    2207          308 :         pp_ampersand (this);
    2208         1684 :       else if (code == INDIRECT_REF)
    2209              :         {
    2210          523 :           tree type = TREE_TYPE (TREE_OPERAND (e, 0));
    2211          523 :           if (type && TREE_CODE (type) == REFERENCE_TYPE)
    2212              :             /* Reference decay is implicit, don't print anything.  */;
    2213              :           else
    2214          425 :             pp_c_star (this);
    2215              :         }
    2216         1161 :       else if (code == NEGATE_EXPR)
    2217           26 :         pp_minus (this);
    2218         1135 :       else if (code == BIT_NOT_EXPR || code == CONJ_EXPR)
    2219            6 :         pp_complement (this);
    2220         1129 :       else if (code == TRUTH_NOT_EXPR)
    2221         1129 :         pp_exclamation (this);
    2222         1992 :       pp_c_cast_expression (this, TREE_OPERAND (e, 0));
    2223         1992 :       break;
    2224              : 
    2225          966 :     case MEM_REF:
    2226          966 :       print_mem_ref (this, e);
    2227          966 :       break;
    2228              : 
    2229            0 :     case TARGET_MEM_REF:
    2230              :       /* TARGET_MEM_REF can't appear directly from source, but can appear
    2231              :          during late GIMPLE optimizations and through late diagnostic we might
    2232              :          need to support it.  Print it as dereferencing of a pointer after
    2233              :          cast to the TARGET_MEM_REF type, with pointer arithmetics on some
    2234              :          pointer to single byte types, so
    2235              :          *(type *)((char *) ptr + step * index + index2) if all the operands
    2236              :          are present and the casts are needed.  */
    2237            0 :       pp_c_star (this);
    2238            0 :       if (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (TMR_BASE (e)))) == NULL_TREE
    2239            0 :           || !integer_onep (TYPE_SIZE_UNIT
    2240              :                                 (TREE_TYPE (TREE_TYPE (TMR_BASE (e))))))
    2241              :         {
    2242            0 :           if (TYPE_SIZE_UNIT (TREE_TYPE (e))
    2243            0 :               && integer_onep (TYPE_SIZE_UNIT (TREE_TYPE (e))))
    2244              :             {
    2245            0 :               pp_c_left_paren (this);
    2246            0 :               pp_c_type_cast (this, build_pointer_type (TREE_TYPE (e)));
    2247              :             }
    2248              :           else
    2249              :             {
    2250            0 :               pp_c_type_cast (this, build_pointer_type (TREE_TYPE (e)));
    2251            0 :               pp_c_left_paren (this);
    2252            0 :               pp_c_type_cast (this, build_pointer_type (char_type_node));
    2253              :             }
    2254              :         }
    2255            0 :       else if (!lang_hooks.types_compatible_p
    2256            0 :                   (TREE_TYPE (e), TREE_TYPE (TREE_TYPE (TMR_BASE (e)))))
    2257              :         {
    2258            0 :           pp_c_type_cast (this, build_pointer_type (TREE_TYPE (e)));
    2259            0 :           pp_c_left_paren (this);
    2260              :         }
    2261              :       else
    2262            0 :         pp_c_left_paren (this);
    2263            0 :       pp_c_cast_expression (this, TMR_BASE (e));
    2264            0 :       if (TMR_STEP (e) && TMR_INDEX (e))
    2265              :         {
    2266            0 :           pp_plus (this);
    2267            0 :           pp_c_cast_expression (this, TMR_INDEX (e));
    2268            0 :           pp_c_star (this);
    2269            0 :           pp_c_cast_expression (this, TMR_STEP (e));
    2270              :         }
    2271            0 :       if (TMR_INDEX2 (e))
    2272              :         {
    2273            0 :           pp_plus (this);
    2274            0 :           pp_c_cast_expression (this, TMR_INDEX2 (e));
    2275              :         }
    2276            0 :       if (!integer_zerop (TMR_OFFSET (e)))
    2277              :         {
    2278            0 :           pp_plus (this);
    2279            0 :           pp_c_integer_constant (this,
    2280            0 :                                  fold_convert (ssizetype, TMR_OFFSET (e)));
    2281              :         }
    2282            0 :       pp_c_right_paren (this);
    2283            0 :       break;
    2284              : 
    2285           14 :     case REALPART_EXPR:
    2286           14 :     case IMAGPART_EXPR:
    2287           21 :       pp_c_ws_string (this, code == REALPART_EXPR ? "__real__" : "__imag__");
    2288           14 :       pp_c_whitespace (this);
    2289           14 :       unary_expression (TREE_OPERAND (e, 0));
    2290           14 :       break;
    2291              : 
    2292         6897 :     default:
    2293         6897 :       postfix_expression (e);
    2294         6897 :       break;
    2295              :     }
    2296         9870 : }
    2297              : 
    2298              : /* cast-expression:
    2299              :       unary-expression
    2300              :       ( type-name ) cast-expression  */
    2301              : 
    2302              : void
    2303         6731 : pp_c_cast_expression (c_pretty_printer *pp, tree e)
    2304              : {
    2305         7399 :   switch (TREE_CODE (e))
    2306              :     {
    2307          668 :     case FLOAT_EXPR:
    2308          668 :     case FIX_TRUNC_EXPR:
    2309          668 :     CASE_CONVERT:
    2310          668 :     case VIEW_CONVERT_EXPR:
    2311          668 :     case EXCESS_PRECISION_EXPR:
    2312          668 :       if (!location_wrapper_p (e))
    2313          273 :         pp_c_type_cast (pp, TREE_TYPE (e));
    2314          668 :       pp_c_cast_expression (pp, TREE_OPERAND (e, 0));
    2315          668 :       break;
    2316              : 
    2317         6731 :     default:
    2318         6731 :       pp->unary_expression (e);
    2319              :     }
    2320         6731 : }
    2321              : 
    2322              : /* multiplicative-expression:
    2323              :       cast-expression
    2324              :       multiplicative-expression * cast-expression
    2325              :       multiplicative-expression / cast-expression
    2326              :       multiplicative-expression % cast-expression   */
    2327              : 
    2328              : void
    2329         2197 : c_pretty_printer::multiplicative_expression (tree e)
    2330              : {
    2331         2197 :   enum tree_code code = TREE_CODE (e);
    2332         2197 :   switch (code)
    2333              :     {
    2334          140 :     case MULT_EXPR:
    2335          140 :     case TRUNC_DIV_EXPR:
    2336          140 :     case TRUNC_MOD_EXPR:
    2337          140 :     case EXACT_DIV_EXPR:
    2338          140 :     case RDIV_EXPR:
    2339          140 :       multiplicative_expression (TREE_OPERAND (e, 0));
    2340          140 :       pp_c_whitespace (this);
    2341          140 :       if (code == MULT_EXPR)
    2342          135 :         pp_c_star (this);
    2343            5 :       else if (code != TRUNC_MOD_EXPR)
    2344            4 :         pp_slash (this);
    2345              :       else
    2346            1 :         pp_modulo (this);
    2347          140 :       pp_c_whitespace (this);
    2348          140 :       pp_c_cast_expression (this, TREE_OPERAND (e, 1));
    2349          140 :       break;
    2350              : 
    2351         2057 :     default:
    2352         2057 :       pp_c_cast_expression (this, e);
    2353         2057 :       break;
    2354              :     }
    2355         2197 : }
    2356              : 
    2357              : /* additive-expression:
    2358              :       multiplicative-expression
    2359              :       additive-expression + multiplicative-expression
    2360              :       additive-expression - multiplicative-expression   */
    2361              : 
    2362              : static void
    2363         4074 : pp_c_additive_expression (c_pretty_printer *pp, tree e)
    2364              : {
    2365         4074 :   enum tree_code code = TREE_CODE (e);
    2366         4074 :   switch (code)
    2367              :     {
    2368          861 :     case POINTER_PLUS_EXPR:
    2369          861 :     case PLUS_EXPR:
    2370          861 :     case POINTER_DIFF_EXPR:
    2371          861 :     case MINUS_EXPR:
    2372          861 :       pp_c_additive_expression (pp, TREE_OPERAND (e, 0));
    2373          861 :       pp_c_whitespace (pp);
    2374          861 :       if (code == PLUS_EXPR || code == POINTER_PLUS_EXPR)
    2375          850 :         pp_plus (pp);
    2376              :       else
    2377           11 :         pp_minus (pp);
    2378          861 :       pp_c_whitespace (pp);
    2379          861 :       {
    2380          861 :         tree op1 = TREE_OPERAND (e, 1);
    2381          861 :         if (code == POINTER_PLUS_EXPR
    2382           66 :             && TREE_CODE (op1) == INTEGER_CST
    2383          882 :             && tree_int_cst_sign_bit (op1))
    2384              :           /* A pointer minus an integer is represented internally as plus a very
    2385              :              large number, don't expose that to users.  */
    2386            7 :           op1 = convert (ssizetype, op1);
    2387          861 :         pp->multiplicative_expression (op1);
    2388              :       }
    2389          861 :       break;
    2390              : 
    2391         3213 :     default:
    2392         3213 :       pp->multiplicative_expression (e);
    2393         3213 :       break;
    2394              :     }
    2395         4074 : }
    2396              : 
    2397              : /* additive-expression:
    2398              :       additive-expression
    2399              :       shift-expression << additive-expression
    2400              :       shift-expression >> additive-expression   */
    2401              : 
    2402              : static void
    2403         2353 : pp_c_shift_expression (c_pretty_printer *pp, tree e)
    2404              : {
    2405         2353 :   enum tree_code code = TREE_CODE (e);
    2406         2353 :   switch (code)
    2407              :     {
    2408          105 :     case LSHIFT_EXPR:
    2409          105 :     case RSHIFT_EXPR:
    2410          105 :     case LROTATE_EXPR:
    2411          105 :     case RROTATE_EXPR:
    2412          105 :       pp_c_shift_expression (pp, TREE_OPERAND (e, 0));
    2413          105 :       pp_c_whitespace (pp);
    2414          209 :       pp_string (pp, code == LSHIFT_EXPR ? "<<" :
    2415              :                      code == RSHIFT_EXPR ? ">>" :
    2416              :                      code == LROTATE_EXPR ? "<<<" : ">>>");
    2417          105 :       pp_c_whitespace (pp);
    2418          105 :       pp_c_additive_expression (pp, TREE_OPERAND (e, 1));
    2419          105 :       break;
    2420              : 
    2421         2248 :     default:
    2422         2248 :       pp_c_additive_expression (pp, e);
    2423              :     }
    2424         2353 : }
    2425              : 
    2426              : /* relational-expression:
    2427              :       shift-expression
    2428              :       relational-expression < shift-expression
    2429              :       relational-expression > shift-expression
    2430              :       relational-expression <= shift-expression
    2431              :       relational-expression >= shift-expression   */
    2432              : 
    2433              : static void
    2434         2143 : pp_c_relational_expression (c_pretty_printer *pp, tree e)
    2435              : {
    2436         2143 :   enum tree_code code = TREE_CODE (e);
    2437         2143 :   switch (code)
    2438              :     {
    2439           40 :     case LT_EXPR:
    2440           40 :     case GT_EXPR:
    2441           40 :     case LE_EXPR:
    2442           40 :     case GE_EXPR:
    2443           40 :       pp_c_relational_expression (pp, TREE_OPERAND (e, 0));
    2444           40 :       pp_c_whitespace (pp);
    2445           40 :       if (code == LT_EXPR)
    2446            7 :         pp_less (pp);
    2447           33 :       else if (code == GT_EXPR)
    2448           27 :         pp_greater (pp);
    2449            6 :       else if (code == LE_EXPR)
    2450            0 :         pp_less_equal (pp);
    2451            6 :       else if (code == GE_EXPR)
    2452            6 :         pp_greater_equal (pp);
    2453           40 :       pp_c_whitespace (pp);
    2454           40 :       pp_c_shift_expression (pp, TREE_OPERAND (e, 1));
    2455           40 :       break;
    2456              : 
    2457         2103 :     default:
    2458         2103 :       pp_c_shift_expression (pp, e);
    2459         2103 :       break;
    2460              :     }
    2461         2143 : }
    2462              : 
    2463              : /* equality-expression:
    2464              :       relational-expression
    2465              :       equality-expression == relational-expression
    2466              :       equality-equality != relational-expression  */
    2467              : 
    2468              : static void
    2469         2063 : pp_c_equality_expression (c_pretty_printer *pp, tree e)
    2470              : {
    2471         2063 :   enum tree_code code = TREE_CODE (e);
    2472         2063 :   switch (code)
    2473              :     {
    2474          347 :     case EQ_EXPR:
    2475          347 :     case NE_EXPR:
    2476          347 :       pp_c_equality_expression (pp, TREE_OPERAND (e, 0));
    2477          347 :       pp_c_whitespace (pp);
    2478          410 :       pp_string (pp, code == EQ_EXPR ? "==" : "!=");
    2479          347 :       pp_c_whitespace (pp);
    2480          347 :       pp_c_relational_expression (pp, TREE_OPERAND (e, 1));
    2481          347 :       break;
    2482              : 
    2483         1716 :     default:
    2484         1716 :       pp_c_relational_expression (pp, e);
    2485         1716 :       break;
    2486              :     }
    2487         2063 : }
    2488              : 
    2489              : /* AND-expression:
    2490              :       equality-expression
    2491              :       AND-expression & equality-equality   */
    2492              : 
    2493              : static void
    2494         1415 : pp_c_and_expression (c_pretty_printer *pp, tree e)
    2495              : {
    2496         1415 :   if (TREE_CODE (e) == BIT_AND_EXPR)
    2497              :     {
    2498            4 :       pp_c_and_expression (pp, TREE_OPERAND (e, 0));
    2499            4 :       pp_c_whitespace (pp);
    2500            4 :       pp_ampersand (pp);
    2501            4 :       pp_c_whitespace (pp);
    2502            4 :       pp_c_equality_expression (pp, TREE_OPERAND (e, 1));
    2503              :     }
    2504              :   else
    2505         1411 :     pp_c_equality_expression (pp, e);
    2506         1415 : }
    2507              : 
    2508              : /* exclusive-OR-expression:
    2509              :      AND-expression
    2510              :      exclusive-OR-expression ^ AND-expression  */
    2511              : 
    2512              : static void
    2513         1407 : pp_c_exclusive_or_expression (c_pretty_printer *pp, tree e)
    2514              : {
    2515         1407 :   if (TREE_CODE (e) == BIT_XOR_EXPR
    2516         1407 :       || TREE_CODE (e) == TRUTH_XOR_EXPR)
    2517              :     {
    2518            1 :       pp_c_exclusive_or_expression (pp, TREE_OPERAND (e, 0));
    2519            1 :       if (TREE_CODE (e) == BIT_XOR_EXPR)
    2520            0 :         pp_c_maybe_whitespace (pp);
    2521              :       else
    2522            1 :         pp_c_whitespace (pp);
    2523            1 :       pp_carret (pp);
    2524            1 :       pp_c_whitespace (pp);
    2525            1 :       pp_c_and_expression (pp, TREE_OPERAND (e, 1));
    2526              :     }
    2527              :   else
    2528         1406 :     pp_c_and_expression (pp, e);
    2529         1407 : }
    2530              : 
    2531              : /* inclusive-OR-expression:
    2532              :      exclusive-OR-expression
    2533              :      inclusive-OR-expression | exclusive-OR-expression  */
    2534              : 
    2535              : static void
    2536         1396 : pp_c_inclusive_or_expression (c_pretty_printer *pp, tree e)
    2537              : {
    2538         1396 :   if (TREE_CODE (e) == BIT_IOR_EXPR)
    2539              :     {
    2540            9 :       pp_c_exclusive_or_expression (pp, TREE_OPERAND (e, 0));
    2541            9 :       pp_c_whitespace (pp);
    2542            9 :       pp_bar (pp);
    2543            9 :       pp_c_whitespace (pp);
    2544            9 :       pp_c_exclusive_or_expression (pp, TREE_OPERAND (e, 1));
    2545              :     }
    2546              :   else
    2547         1387 :     pp_c_exclusive_or_expression (pp, e);
    2548         1396 : }
    2549              : 
    2550              : /* logical-AND-expression:
    2551              :       inclusive-OR-expression
    2552              :       logical-AND-expression && inclusive-OR-expression  */
    2553              : 
    2554              : static void
    2555         1387 : pp_c_logical_and_expression (c_pretty_printer *pp, tree e)
    2556              : {
    2557         1387 :   if (TREE_CODE (e) == TRUTH_ANDIF_EXPR
    2558          767 :       || TREE_CODE (e) == TRUTH_AND_EXPR)
    2559              :     {
    2560          621 :       pp_c_logical_and_expression (pp, TREE_OPERAND (e, 0));
    2561          621 :       pp_c_whitespace (pp);
    2562          621 :       pp_ampersand_ampersand (pp);
    2563          621 :       pp_c_whitespace (pp);
    2564          621 :       pp_c_inclusive_or_expression (pp, TREE_OPERAND (e, 1));
    2565              :     }
    2566              :   else
    2567          766 :     pp_c_inclusive_or_expression (pp, e);
    2568         1387 : }
    2569              : 
    2570              : /* logical-OR-expression:
    2571              :       logical-AND-expression
    2572              :       logical-OR-expression || logical-AND-expression  */
    2573              : 
    2574              : void
    2575          250 : pp_c_logical_or_expression (c_pretty_printer *pp, tree e)
    2576              : {
    2577          250 :   if (TREE_CODE (e) == TRUTH_ORIF_EXPR
    2578          152 :       || TREE_CODE (e) == TRUTH_OR_EXPR)
    2579              :     {
    2580           99 :       pp_c_logical_or_expression (pp, TREE_OPERAND (e, 0));
    2581           99 :       pp_c_whitespace (pp);
    2582           99 :       pp_bar_bar (pp);
    2583           99 :       pp_c_whitespace (pp);
    2584           99 :       pp_c_logical_and_expression (pp, TREE_OPERAND (e, 1));
    2585              :     }
    2586              :   else
    2587          151 :     pp_c_logical_and_expression (pp, e);
    2588          250 : }
    2589              : 
    2590              : /* conditional-expression:
    2591              :       logical-OR-expression
    2592              :       logical-OR-expression ? expression : conditional-expression  */
    2593              : 
    2594              : void
    2595           42 : c_pretty_printer::conditional_expression (tree e)
    2596              : {
    2597           42 :   if (TREE_CODE (e) == COND_EXPR)
    2598              :     {
    2599           21 :       pp_c_logical_or_expression (this, TREE_OPERAND (e, 0));
    2600           21 :       pp_c_whitespace (this);
    2601           21 :       pp_question (this);
    2602           21 :       pp_c_whitespace (this);
    2603           21 :       expression (TREE_OPERAND (e, 1));
    2604           21 :       pp_c_whitespace (this);
    2605           21 :       pp_colon (this);
    2606           21 :       pp_c_whitespace (this);
    2607           21 :       conditional_expression (TREE_OPERAND (e, 2));
    2608              :     }
    2609              :   else
    2610           21 :     pp_c_logical_or_expression (this, e);
    2611           42 : }
    2612              : 
    2613              : 
    2614              : /* assignment-expression:
    2615              :       conditional-expression
    2616              :       unary-expression assignment-operator  assignment-expression
    2617              : 
    2618              :    assignment-expression: one of
    2619              :       =    *=    /=    %=    +=    -=    >>=    <<=    &=    ^=    |=  */
    2620              : 
    2621              : void
    2622            0 : c_pretty_printer::assignment_expression (tree e)
    2623              : {
    2624            0 :   if (TREE_CODE (e) == MODIFY_EXPR
    2625            0 :       || TREE_CODE (e) == INIT_EXPR)
    2626              :     {
    2627            0 :       unary_expression (TREE_OPERAND (e, 0));
    2628            0 :       pp_c_whitespace (this);
    2629            0 :       pp_equal (this);
    2630            0 :       pp_space (this);
    2631            0 :       expression (TREE_OPERAND (e, 1));
    2632              :     }
    2633              :   else
    2634            0 :     conditional_expression (e);
    2635            0 : }
    2636              : 
    2637              : /* expression:
    2638              :        assignment-expression
    2639              :        expression , assignment-expression
    2640              : 
    2641              :   Implementation note:  instead of going through the usual recursion
    2642              :   chain, I take the liberty of dispatching nodes to the appropriate
    2643              :   functions.  This makes some redundancy, but it worths it. That also
    2644              :   prevents a possible infinite recursion between primary_expression ()
    2645              :   and expression ().  */
    2646              : 
    2647              : void
    2648        46396 : c_pretty_printer::expression (tree e)
    2649              : {
    2650        46396 :   switch (TREE_CODE (e))
    2651              :     {
    2652            0 :     case VOID_CST:
    2653            0 :       pp_c_void_constant (this);
    2654            0 :       break;
    2655              : 
    2656         7536 :     case INTEGER_CST:
    2657         7536 :       pp_c_integer_constant (this, e);
    2658         7536 :       break;
    2659              : 
    2660          171 :     case REAL_CST:
    2661          171 :       pp_c_floating_constant (this, e);
    2662          171 :       break;
    2663              : 
    2664            0 :     case FIXED_CST:
    2665            0 :       pp_c_fixed_constant (this, e);
    2666            0 :       break;
    2667              : 
    2668          280 :     case STRING_CST:
    2669          280 :       pp_c_string_literal (this, e);
    2670          280 :       break;
    2671              : 
    2672        27384 :     case IDENTIFIER_NODE:
    2673        27384 :     case FUNCTION_DECL:
    2674        27384 :     case VAR_DECL:
    2675        27384 :     case CONST_DECL:
    2676        27384 :     case PARM_DECL:
    2677        27384 :     case RESULT_DECL:
    2678        27384 :     case FIELD_DECL:
    2679        27384 :     case LABEL_DECL:
    2680        27384 :     case ERROR_MARK:
    2681        27384 :       primary_expression (e);
    2682        27384 :       break;
    2683              : 
    2684         4669 :     case SSA_NAME:
    2685         4669 :       if (SSA_NAME_VAR (e)
    2686         4591 :           && !DECL_ARTIFICIAL (SSA_NAME_VAR (e)))
    2687         4579 :         expression (SSA_NAME_VAR (e));
    2688              :       else
    2689           90 :         translate_string ("<unknown>");
    2690              :       break;
    2691              : 
    2692         1393 :     case POSTINCREMENT_EXPR:
    2693         1393 :     case POSTDECREMENT_EXPR:
    2694         1393 :     case ARRAY_REF:
    2695         1393 :     case OMP_ARRAY_SECTION:
    2696         1393 :     case CALL_EXPR:
    2697         1393 :     case COMPONENT_REF:
    2698         1393 :     case BIT_FIELD_REF:
    2699         1393 :     case COMPLEX_CST:
    2700         1393 :     case COMPLEX_EXPR:
    2701         1393 :     case VECTOR_CST:
    2702         1393 :     case ORDERED_EXPR:
    2703         1393 :     case UNORDERED_EXPR:
    2704         1393 :     case LTGT_EXPR:
    2705         1393 :     case UNEQ_EXPR:
    2706         1393 :     case UNLE_EXPR:
    2707         1393 :     case UNLT_EXPR:
    2708         1393 :     case UNGE_EXPR:
    2709         1393 :     case UNGT_EXPR:
    2710         1393 :     case MAX_EXPR:
    2711         1393 :     case MIN_EXPR:
    2712         1393 :     case ABS_EXPR:
    2713         1393 :     case CONSTRUCTOR:
    2714         1393 :     case COMPOUND_LITERAL_EXPR:
    2715         1393 :     case VA_ARG_EXPR:
    2716         1393 :       postfix_expression (e);
    2717         1393 :       break;
    2718              : 
    2719         2024 :     case CONJ_EXPR:
    2720         2024 :     case ADDR_EXPR:
    2721         2024 :     case INDIRECT_REF:
    2722         2024 :     case MEM_REF:
    2723         2024 :     case TARGET_MEM_REF:
    2724         2024 :     case NEGATE_EXPR:
    2725         2024 :     case BIT_NOT_EXPR:
    2726         2024 :     case TRUTH_NOT_EXPR:
    2727         2024 :     case PREINCREMENT_EXPR:
    2728         2024 :     case PREDECREMENT_EXPR:
    2729         2024 :     case REALPART_EXPR:
    2730         2024 :     case IMAGPART_EXPR:
    2731         2024 :       unary_expression (e);
    2732         2024 :       break;
    2733              : 
    2734          262 :     case FLOAT_EXPR:
    2735          262 :     case FIX_TRUNC_EXPR:
    2736          262 :     CASE_CONVERT:
    2737          262 :     case VIEW_CONVERT_EXPR:
    2738          262 :     case EXCESS_PRECISION_EXPR:
    2739          262 :       pp_c_cast_expression (this, e);
    2740          262 :       break;
    2741              : 
    2742           97 :     case MULT_EXPR:
    2743           97 :     case TRUNC_MOD_EXPR:
    2744           97 :     case TRUNC_DIV_EXPR:
    2745           97 :     case EXACT_DIV_EXPR:
    2746           97 :     case RDIV_EXPR:
    2747           97 :       multiplicative_expression (e);
    2748           97 :       break;
    2749              : 
    2750          105 :     case LSHIFT_EXPR:
    2751          105 :     case RSHIFT_EXPR:
    2752          105 :     case LROTATE_EXPR:
    2753          105 :     case RROTATE_EXPR:
    2754          105 :       pp_c_shift_expression (this, e);
    2755          105 :       break;
    2756              : 
    2757           40 :     case LT_EXPR:
    2758           40 :     case GT_EXPR:
    2759           40 :     case LE_EXPR:
    2760           40 :     case GE_EXPR:
    2761           40 :       pp_c_relational_expression (this, e);
    2762           40 :       break;
    2763              : 
    2764            4 :     case BIT_AND_EXPR:
    2765            4 :       pp_c_and_expression (this, e);
    2766            4 :       break;
    2767              : 
    2768            1 :     case BIT_XOR_EXPR:
    2769            1 :     case TRUTH_XOR_EXPR:
    2770            1 :       pp_c_exclusive_or_expression (this, e);
    2771            1 :       break;
    2772              : 
    2773            9 :     case BIT_IOR_EXPR:
    2774            9 :       pp_c_inclusive_or_expression (this, e);
    2775            9 :       break;
    2776              : 
    2777          516 :     case TRUTH_ANDIF_EXPR:
    2778          516 :     case TRUTH_AND_EXPR:
    2779          516 :       pp_c_logical_and_expression (this, e);
    2780          516 :       break;
    2781              : 
    2782           75 :     case TRUTH_ORIF_EXPR:
    2783           75 :     case TRUTH_OR_EXPR:
    2784           75 :       pp_c_logical_or_expression (this, e);
    2785           75 :       break;
    2786              : 
    2787          301 :     case EQ_EXPR:
    2788          301 :     case NE_EXPR:
    2789          301 :       pp_c_equality_expression (this, e);
    2790          301 :       break;
    2791              : 
    2792           21 :     case COND_EXPR:
    2793           21 :       conditional_expression (e);
    2794           21 :       break;
    2795              : 
    2796          860 :     case POINTER_PLUS_EXPR:
    2797          860 :     case PLUS_EXPR:
    2798          860 :     case POINTER_DIFF_EXPR:
    2799          860 :     case MINUS_EXPR:
    2800          860 :       pp_c_additive_expression (this, e);
    2801          860 :       break;
    2802              : 
    2803            0 :     case MODIFY_EXPR:
    2804            0 :     case INIT_EXPR:
    2805            0 :       assignment_expression (e);
    2806            0 :       break;
    2807              : 
    2808            7 :     case COMPOUND_EXPR:
    2809            7 :       pp_c_left_paren (this);
    2810            7 :       expression (TREE_OPERAND (e, 0));
    2811            7 :       pp_separate_with (this, ',');
    2812            7 :       assignment_expression (TREE_OPERAND (e, 1));
    2813            7 :       pp_c_right_paren (this);
    2814            7 :       break;
    2815              : 
    2816          630 :     case NON_LVALUE_EXPR:
    2817          630 :     case SAVE_EXPR:
    2818          630 :       expression (TREE_OPERAND (e, 0));
    2819          630 :       break;
    2820              : 
    2821            3 :     case TARGET_EXPR:
    2822            3 :       postfix_expression (TARGET_EXPR_INITIAL (e));
    2823            3 :       break;
    2824              : 
    2825            2 :     case BIND_EXPR:
    2826            2 :     case GOTO_EXPR:
    2827              :       /* We don't yet have a way of dumping statements in a
    2828              :          human-readable format.  */
    2829            2 :       pp_string (this, "({...})");
    2830            2 :       break;
    2831              : 
    2832            6 :     case C_MAYBE_CONST_EXPR:
    2833            6 :       expression (C_MAYBE_CONST_EXPR_EXPR (e));
    2834            6 :       break;
    2835              : 
    2836            0 :     default:
    2837            0 :       pp_unsupported_tree (this, e);
    2838            0 :       break;
    2839              :     }
    2840        46396 : }
    2841              : 
    2842              : 
    2843              : 
    2844              : /* Statements.  */
    2845              : 
    2846              : void
    2847         7562 : c_pretty_printer::statement (tree t)
    2848              : {
    2849         7562 :   if (t == NULL)
    2850              :     return;
    2851              : 
    2852         7562 :   switch (TREE_CODE (t))
    2853              :     {
    2854              : 
    2855            0 :     case SWITCH_STMT:
    2856            0 :       if (dump_flags != TDF_NONE)
    2857            0 :         internal_error ("dump flags not handled here");
    2858              : 
    2859            0 :       pp_c_ws_string (this, "switch");
    2860            0 :       pp_space (this);
    2861            0 :       pp_c_left_paren (this);
    2862            0 :       expression (SWITCH_STMT_COND (t));
    2863            0 :       pp_c_right_paren (this);
    2864            0 :       pp_indentation (this) += 3;
    2865            0 :       pp_needs_newline (this) = true;
    2866            0 :       statement (SWITCH_STMT_BODY (t));
    2867            0 :       pp_newline_and_indent (this, -3);
    2868            0 :       break;
    2869              : 
    2870              :       /* iteration-statement:
    2871              :             while ( expression ) statement
    2872              :             do statement while ( expression ) ;
    2873              :             for ( expression(opt) ; expression(opt) ; expression(opt) ) statement
    2874              :             for ( declaration expression(opt) ; expression(opt) ) statement  */
    2875            0 :     case WHILE_STMT:
    2876            0 :       if (dump_flags != TDF_NONE)
    2877            0 :         internal_error ("dump flags not handled here");
    2878              : 
    2879            0 :       pp_c_ws_string (this, "while");
    2880            0 :       pp_space (this);
    2881            0 :       pp_c_left_paren (this);
    2882            0 :       expression (WHILE_COND (t));
    2883            0 :       pp_c_right_paren (this);
    2884            0 :       pp_newline_and_indent (this, 3);
    2885            0 :       statement (WHILE_BODY (t));
    2886            0 :       pp_indentation (this) -= 3;
    2887            0 :       pp_needs_newline (this) = true;
    2888            0 :       break;
    2889              : 
    2890            0 :     case DO_STMT:
    2891            0 :       if (dump_flags != TDF_NONE)
    2892            0 :         internal_error ("dump flags not handled here");
    2893              : 
    2894            0 :       pp_c_ws_string (this, "do");
    2895            0 :       pp_newline_and_indent (this, 3);
    2896            0 :       statement (DO_BODY (t));
    2897            0 :       pp_newline_and_indent (this, -3);
    2898            0 :       pp_c_ws_string (this, "while");
    2899            0 :       pp_space (this);
    2900            0 :       pp_c_left_paren (this);
    2901            0 :       expression (DO_COND (t));
    2902            0 :       pp_c_right_paren (this);
    2903            0 :       pp_c_semicolon (this);
    2904            0 :       pp_needs_newline (this) = true;
    2905            0 :       break;
    2906              : 
    2907            0 :     case FOR_STMT:
    2908            0 :       if (dump_flags != TDF_NONE)
    2909            0 :         internal_error ("dump flags not handled here");
    2910              : 
    2911            0 :       pp_c_ws_string (this, "for");
    2912            0 :       pp_space (this);
    2913            0 :       pp_c_left_paren (this);
    2914            0 :       if (FOR_INIT_STMT (t))
    2915            0 :         statement (FOR_INIT_STMT (t));
    2916              :       else
    2917            0 :         pp_c_semicolon (this);
    2918            0 :       pp_needs_newline (this) = false;
    2919            0 :       pp_c_whitespace (this);
    2920            0 :       if (FOR_COND (t))
    2921            0 :         expression (FOR_COND (t));
    2922            0 :       pp_c_semicolon (this);
    2923            0 :       pp_needs_newline (this) = false;
    2924            0 :       pp_c_whitespace (this);
    2925            0 :       if (FOR_EXPR (t))
    2926            0 :         expression (FOR_EXPR (t));
    2927            0 :       pp_c_right_paren (this);
    2928            0 :       pp_newline_and_indent (this, 3);
    2929            0 :       statement (FOR_BODY (t));
    2930            0 :       pp_indentation (this) -= 3;
    2931            0 :       pp_needs_newline (this) = true;
    2932            0 :       break;
    2933              : 
    2934              :       /* jump-statement:
    2935              :             goto identifier;
    2936              :             continue ;
    2937              :             return expression(opt) ;  */
    2938            0 :     case BREAK_STMT:
    2939            0 :       if (dump_flags != TDF_NONE)
    2940            0 :         internal_error ("dump flags not handled here");
    2941              : 
    2942            0 :       pp_string (this, "break");
    2943            0 :       if (BREAK_NAME (t))
    2944              :         {
    2945            0 :           pp_space (this);
    2946            0 :           pp_c_tree_decl_identifier (this, BREAK_NAME (t));
    2947              :         }
    2948            0 :       pp_c_semicolon (this);
    2949            0 :       pp_needs_newline (this) = true;
    2950            0 :       break;
    2951              : 
    2952            0 :     case CONTINUE_STMT:
    2953            0 :       if (dump_flags != TDF_NONE)
    2954            0 :         internal_error ("dump flags not handled here");
    2955              : 
    2956            0 :       pp_string (this, "continue");
    2957            0 :       if (CONTINUE_NAME (t))
    2958              :         {
    2959            0 :           pp_space (this);
    2960            0 :           pp_c_tree_decl_identifier (this, CONTINUE_NAME (t));
    2961              :         }
    2962            0 :       pp_c_semicolon (this);
    2963            0 :       pp_needs_newline (this) = true;
    2964            0 :       break;
    2965              : 
    2966         7562 :     default:
    2967         7562 :       if (pp_needs_newline (this))
    2968         7562 :         pp_newline_and_indent (this, 0);
    2969         7562 :       dump_generic_node (this, t, pp_indentation (this), dump_flags, true);
    2970              :     }
    2971              : }
    2972              : 
    2973              : 
    2974              : /* Initialize the PRETTY-PRINTER for handling C codes.  */
    2975              : 
    2976       330822 : c_pretty_printer::c_pretty_printer (dump_flags_t dump_flags)
    2977              :   : pretty_printer (),
    2978       330822 :     dump_flags (dump_flags),
    2979       330822 :     offset_list (),
    2980       330822 :     flags ()
    2981              : {
    2982       330822 :   type_specifier_seq        = pp_c_specifier_qualifier_list;
    2983       330822 :   ptr_operator              = pp_c_pointer;
    2984       330822 :   parameter_list            = pp_c_parameter_type_list;
    2985       330822 : }
    2986              : 
    2987              : /* c_pretty_printer's implementation of pretty_printer::clone vfunc.  */
    2988              : 
    2989              : std::unique_ptr<pretty_printer>
    2990       262242 : c_pretty_printer::clone () const
    2991              : {
    2992       262242 :   return std::make_unique<c_pretty_printer> (*this);
    2993              : }
    2994              : 
    2995              : /* Print the tree T in full, on file FILE.  */
    2996              : 
    2997              : void
    2998         7562 : print_c_tree (FILE *file, tree t, dump_flags_t dump_flags)
    2999              : {
    3000         7562 :   c_pretty_printer pp (dump_flags);
    3001              : 
    3002         7562 :   pp_needs_newline (&pp) = true;
    3003         7562 :   pp.set_output_stream (file);
    3004         7562 :   pp.statement (t);
    3005         7562 :   pp_newline_and_flush (&pp);
    3006         7562 : }
    3007              : 
    3008              : /* Print the tree T in full, on stderr.  */
    3009              : 
    3010              : DEBUG_FUNCTION void
    3011            0 : debug_c_tree (tree t)
    3012              : {
    3013            0 :   print_c_tree (stderr, t, TDF_NONE);
    3014            0 :   fputc ('\n', stderr);
    3015            0 : }
    3016              : 
    3017              : /* Output the DECL_NAME of T.  If T has no DECL_NAME, output a string made
    3018              :    up of T's memory address.  */
    3019              : 
    3020              : void
    3021        58664 : pp_c_tree_decl_identifier (c_pretty_printer *pp, tree t)
    3022              : {
    3023        58664 :   const char *name;
    3024              : 
    3025        58664 :   gcc_assert (DECL_P (t));
    3026              : 
    3027        58664 :   if (DECL_NAME (t))
    3028              :     {
    3029        58560 :       const char *dot;
    3030        58560 :       name = IDENTIFIER_POINTER (DECL_NAME (t));
    3031        58560 :       if (DECL_ARTIFICIAL (t) && (dot = strchr (name, '.')))
    3032              :         {
    3033              :           /* Print the name without the . suffix (such as in VLAs and
    3034              :              callee-copied parameters).  */
    3035           63 :           size_t size = dot - name;
    3036           63 :           char *ident = XALLOCAVEC (char, size + 1);
    3037           63 :           memcpy (ident, name, size);
    3038           63 :           ident[size] = '\0';
    3039           63 :           name = ident;
    3040              :         }
    3041              :     }
    3042              :   else
    3043              :     {
    3044          104 :       static char xname[8];
    3045          104 :       sprintf (xname, "<U%4hx>", ((unsigned short) ((uintptr_t) (t)
    3046              :                                                     & 0xffff)));
    3047          104 :       name = xname;
    3048              :     }
    3049              : 
    3050        58664 :   pp_c_identifier (pp, name);
    3051        58664 : }
    3052              : 
    3053              : /* Prints "[version: VERSION]" for a versioned function decl.
    3054              :    This will only print for targets with target_version semantics.  */
    3055              : void
    3056       769087 : pp_c_function_target_version (c_pretty_printer *pp, tree t)
    3057              : {
    3058       769087 :   if (TARGET_HAS_FMV_TARGET_ATTRIBUTE)
    3059       769087 :     return;
    3060              : 
    3061              :   string_slice version = get_target_version (t);
    3062              :   if (!version.is_valid ())
    3063              :     return;
    3064              : 
    3065              :   pp_c_whitespace (pp);
    3066              : 
    3067              :   pp_c_left_bracket (pp);
    3068              :   pp_c_left_bracket (pp);
    3069              :   pp_string (pp, "target_version");
    3070              :   pp_c_left_paren (pp);
    3071              :   pp_doublequote (pp);
    3072              :   pp_string_n (pp, version.begin (), version.size ());
    3073              :   pp_doublequote (pp);
    3074              :   pp_c_right_paren (pp);
    3075              :   pp_c_right_bracket (pp);
    3076              :   pp_c_right_bracket (pp);
    3077              : 
    3078              :   pp->set_padding (pp_before);
    3079              : }
    3080              : 
    3081              : /* Prints "[clones: VERSION, +]" for a versioned function decl.
    3082              :    This only works for targets with target_version semantics.  */
    3083              : void
    3084       769087 : pp_c_function_target_clones (c_pretty_printer *pp, tree t)
    3085              : {
    3086              :   /* Only print for target_version semantics.
    3087              :      This is because for target FMV semantics a target_clone always defines
    3088              :      the entire FMV set.  target_version semantics can mix target_clone and
    3089              :      target_version decls in the definition of a FMV set and so the
    3090              :      target_clone becomes a part of the identity of the declaration.  */
    3091       769087 :   if (TARGET_HAS_FMV_TARGET_ATTRIBUTE)
    3092       769087 :     return;
    3093              : 
    3094              :   auto_vec<string_slice> versions = get_clone_versions (t, NULL, false);
    3095              :   if (versions.is_empty ())
    3096              :     return;
    3097              : 
    3098              :   pp_c_whitespace (pp);
    3099              : 
    3100              :   string_slice final_version = versions.pop ();
    3101              :   pp_c_left_bracket (pp);
    3102              :   pp_c_left_bracket (pp);
    3103              :   pp_string (pp, "target_clones");
    3104              :   pp_c_left_paren (pp);
    3105              :   for (string_slice version : versions)
    3106              :     {
    3107              :       pp_doublequote (pp);
    3108              :       pp_string_n (pp, version.begin (), version.size ());
    3109              :       pp_doublequote (pp);
    3110              :       pp_string (pp, ",");
    3111              :       pp_c_whitespace (pp);
    3112              :     }
    3113              :   pp_doublequote (pp);
    3114              :   pp_string_n (pp, final_version.begin (), final_version.size ());
    3115              :   pp_doublequote (pp);
    3116              :   pp_c_right_paren (pp);
    3117              :   pp_c_right_bracket (pp);
    3118              :   pp_c_right_bracket (pp);
    3119              : 
    3120              :   pp->set_padding (pp_before);
    3121              : }
    3122              : 
    3123              : #if CHECKING_P
    3124              : 
    3125              : namespace selftest {
    3126              : 
    3127              : /* Selftests for pretty-printing trees.  */
    3128              : 
    3129              : /* Verify that EXPR printed by c_pretty_printer is EXPECTED, using
    3130              :    LOC as the effective location for any failures.  */
    3131              : 
    3132              : static void
    3133           12 : assert_c_pretty_printer_output (const location &loc, const char *expected,
    3134              :                                 tree expr)
    3135              : {
    3136           12 :   c_pretty_printer pp;
    3137           12 :   pp.expression (expr);
    3138           12 :   ASSERT_STREQ_AT (loc, expected, pp_formatted_text (&pp));
    3139           12 : }
    3140              : 
    3141              : /* Helper function for calling assert_c_pretty_printer_output.
    3142              :    This is to avoid having to write SELFTEST_LOCATION.  */
    3143              : 
    3144              : #define ASSERT_C_PRETTY_PRINTER_OUTPUT(EXPECTED, EXPR) \
    3145              :   SELFTEST_BEGIN_STMT                                           \
    3146              :     assert_c_pretty_printer_output ((SELFTEST_LOCATION),        \
    3147              :                                     (EXPECTED),         \
    3148              :                                     (EXPR));                    \
    3149              :   SELFTEST_END_STMT
    3150              : 
    3151              : /* Verify that location wrappers don't show up in pretty-printed output.  */
    3152              : 
    3153              : static void
    3154            3 : test_location_wrappers ()
    3155              : {
    3156              :   /* VAR_DECL.  */
    3157            3 :   tree id = get_identifier ("foo");
    3158            3 :   tree decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, id,
    3159              :                           integer_type_node);
    3160            3 :   tree wrapped_decl = maybe_wrap_with_location (decl, BUILTINS_LOCATION);
    3161            3 :   ASSERT_NE (wrapped_decl, decl);
    3162            3 :   ASSERT_C_PRETTY_PRINTER_OUTPUT ("foo", decl);
    3163            3 :   ASSERT_C_PRETTY_PRINTER_OUTPUT ("foo", wrapped_decl);
    3164              : 
    3165              :   /* INTEGER_CST.  */
    3166            3 :   tree int_cst = build_int_cst (integer_type_node, 42);
    3167            3 :   tree wrapped_cst = maybe_wrap_with_location (int_cst, BUILTINS_LOCATION);
    3168            3 :   ASSERT_NE (wrapped_cst, int_cst);
    3169            3 :   ASSERT_C_PRETTY_PRINTER_OUTPUT ("42", int_cst);
    3170            3 :   ASSERT_C_PRETTY_PRINTER_OUTPUT ("42", wrapped_cst);
    3171            3 : }
    3172              : 
    3173              : /* Run all of the selftests within this file.  */
    3174              : 
    3175              : void
    3176            3 : c_pretty_print_cc_tests ()
    3177              : {
    3178            3 :   test_location_wrappers ();
    3179            3 : }
    3180              : 
    3181              : } // namespace selftest
    3182              : 
    3183              : #endif /* CHECKING_P */
        

Generated by: LCOV version 2.5.0-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.