OSDN Git Service

Fix misapplied patch.
[pf3gnuchains/gcc-fork.git] / gcc / c-pretty-print.c
1 /* Subroutines common to both C and C++ pretty-printers.
2    Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
3    Free Software Foundation, Inc.
4    Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "real.h"
27 #include "fixed-value.h"
28 #include "intl.h"
29 #include "c-pretty-print.h"
30 #include "c-tree.h"
31 #include "tree-iterator.h"
32 #include "diagnostic.h"
33
34 /* Translate if being used for diagnostics, but not for dump files or
35    __PRETTY_FUNCTION.  */
36 #define M_(msgid) (pp_translate_identifiers (pp) ? _(msgid) : (msgid))
37
38 /* The pretty-printer code is primarily designed to closely follow
39    (GNU) C and C++ grammars.  That is to be contrasted with spaghetti
40    codes we used to have in the past.  Following a structured
41    approach (preferably the official grammars) is believed to make it
42    much easier to add extensions and nifty pretty-printing effects that
43    takes expression or declaration contexts into account.  */
44
45
46 #define pp_c_maybe_whitespace(PP)            \
47    do {                                      \
48      if (pp_base (PP)->padding == pp_before) \
49        pp_c_whitespace (PP);                 \
50    } while (0)
51
52 /* literal  */
53 static void pp_c_char (c_pretty_printer *, int);
54
55 /* postfix-expression  */
56 static void pp_c_initializer_list (c_pretty_printer *, tree);
57 static void pp_c_brace_enclosed_initializer_list (c_pretty_printer *, tree);
58
59 static void pp_c_multiplicative_expression (c_pretty_printer *, tree);
60 static void pp_c_additive_expression (c_pretty_printer *, tree);
61 static void pp_c_shift_expression (c_pretty_printer *, tree);
62 static void pp_c_relational_expression (c_pretty_printer *, tree);
63 static void pp_c_equality_expression (c_pretty_printer *, tree);
64 static void pp_c_and_expression (c_pretty_printer *, tree);
65 static void pp_c_exclusive_or_expression (c_pretty_printer *, tree);
66 static void pp_c_inclusive_or_expression (c_pretty_printer *, tree);
67 static void pp_c_logical_and_expression (c_pretty_printer *, tree);
68 static void pp_c_conditional_expression (c_pretty_printer *, tree);
69 static void pp_c_assignment_expression (c_pretty_printer *, tree);
70
71 /* declarations.  */
72
73 \f
74 /* Helper functions.  */
75
76 void
77 pp_c_whitespace (c_pretty_printer *pp)
78 {
79   pp_space (pp);
80   pp_base (pp)->padding = pp_none;
81 }
82
83 void
84 pp_c_left_paren (c_pretty_printer *pp)
85 {
86   pp_left_paren (pp);
87   pp_base (pp)->padding = pp_none;
88 }
89
90 void
91 pp_c_right_paren (c_pretty_printer *pp)
92 {
93   pp_right_paren (pp);
94   pp_base (pp)->padding = pp_none;
95 }
96
97 void
98 pp_c_left_brace (c_pretty_printer *pp)
99 {
100   pp_left_brace (pp);
101   pp_base (pp)->padding = pp_none;
102 }
103
104 void
105 pp_c_right_brace (c_pretty_printer *pp)
106 {
107   pp_right_brace (pp);
108   pp_base (pp)->padding = pp_none;
109 }
110
111 void
112 pp_c_left_bracket (c_pretty_printer *pp)
113 {
114   pp_left_bracket (pp);
115   pp_base (pp)->padding = pp_none;
116 }
117
118 void
119 pp_c_right_bracket (c_pretty_printer *pp)
120 {
121   pp_right_bracket (pp);
122   pp_base (pp)->padding = pp_none;
123 }
124
125 void
126 pp_c_dot (c_pretty_printer *pp)
127 {
128   pp_dot (pp);
129   pp_base (pp)->padding = pp_none;
130 }
131
132 void
133 pp_c_ampersand (c_pretty_printer *pp)
134 {
135   pp_ampersand (pp);
136   pp_base (pp)->padding = pp_none;
137 }
138
139 void
140 pp_c_star (c_pretty_printer *pp)
141 {
142   pp_star (pp);
143   pp_base (pp)->padding = pp_none;
144 }
145
146 void
147 pp_c_arrow (c_pretty_printer *pp)
148 {
149   pp_arrow (pp);
150   pp_base (pp)->padding = pp_none;
151 }
152
153 void
154 pp_c_semicolon (c_pretty_printer *pp)
155 {
156   pp_semicolon (pp);
157   pp_base (pp)->padding = pp_none;
158 }
159
160 void
161 pp_c_complement (c_pretty_printer *pp)
162 {
163   pp_complement (pp);
164   pp_base (pp)->padding = pp_none;
165 }
166
167 void
168 pp_c_exclamation (c_pretty_printer *pp)
169 {
170   pp_exclamation (pp);
171   pp_base (pp)->padding = pp_none;
172 }
173
174 /* Print out the external representation of CV-QUALIFIER.  */
175
176 static void
177 pp_c_cv_qualifier (c_pretty_printer *pp, const char *cv)
178 {
179   const char *p = pp_last_position_in_text (pp);
180   /* The C programming language does not have references, but it is much
181      simpler to handle those here rather than going through the same
182      logic in the C++ pretty-printer.  */
183   if (p != NULL && (*p == '*' || *p == '&'))
184     pp_c_whitespace (pp);
185   pp_c_ws_string (pp, cv);
186 }
187
188 /* Pretty-print T using the type-cast notation '( type-name )'.  */
189
190 static void
191 pp_c_type_cast (c_pretty_printer *pp, tree t)
192 {
193   pp_c_left_paren (pp);
194   pp_type_id (pp, t);
195   pp_c_right_paren (pp);
196 }
197
198 /* We're about to pretty-print a pointer type as indicated by T.
199    Output a whitespace, if needed, preparing for subsequent output.  */
200
201 void
202 pp_c_space_for_pointer_operator (c_pretty_printer *pp, tree t)
203 {
204   if (POINTER_TYPE_P (t))
205     {
206       tree pointee = strip_pointer_operator (TREE_TYPE (t));
207       if (TREE_CODE (pointee) != ARRAY_TYPE
208           && TREE_CODE (pointee) != FUNCTION_TYPE)
209         pp_c_whitespace (pp);
210     }
211 }
212
213 \f
214 /* Declarations.  */
215
216 /* C++ cv-qualifiers are called type-qualifiers in C.  Print out the
217    cv-qualifiers of T.  If T is a declaration then it is the cv-qualifier
218    of its type.  Take care of possible extensions.
219
220    type-qualifier-list:
221        type-qualifier
222        type-qualifier-list type-qualifier
223
224    type-qualifier:
225        const
226        restrict                              -- C99
227        __restrict__                          -- GNU C
228        volatile    */
229
230 void
231 pp_c_type_qualifier_list (c_pretty_printer *pp, tree t)
232 {
233   int qualifiers;
234
235   if (!t || t == error_mark_node)
236     return;
237
238   if (!TYPE_P (t))
239     t = TREE_TYPE (t);
240
241   qualifiers = TYPE_QUALS (t);
242   if (qualifiers & TYPE_QUAL_CONST)
243     pp_c_cv_qualifier (pp, "const");
244   if (qualifiers & TYPE_QUAL_VOLATILE)
245     pp_c_cv_qualifier (pp, "volatile");
246   if (qualifiers & TYPE_QUAL_RESTRICT)
247     pp_c_cv_qualifier (pp, flag_isoc99 ? "restrict" : "__restrict__");
248 }
249
250 /* pointer:
251       * type-qualifier-list(opt)
252       * type-qualifier-list(opt) pointer  */
253
254 static void
255 pp_c_pointer (c_pretty_printer *pp, tree t)
256 {
257   if (!TYPE_P (t) && TREE_CODE (t) != TYPE_DECL)
258     t = TREE_TYPE (t);
259   switch (TREE_CODE (t))
260     {
261     case POINTER_TYPE:
262       /* It is easier to handle C++ reference types here.  */
263     case REFERENCE_TYPE:
264       if (TREE_CODE (TREE_TYPE (t)) == POINTER_TYPE)
265         pp_c_pointer (pp, TREE_TYPE (t));
266       if (TREE_CODE (t) == POINTER_TYPE)
267         pp_c_star (pp);
268       else
269         pp_c_ampersand (pp);
270       pp_c_type_qualifier_list (pp, t);
271       break;
272
273       /* ??? This node is now in GENERIC and so shouldn't be here.  But
274          we'll fix that later.  */
275     case DECL_EXPR:
276       pp_declaration (pp, DECL_EXPR_DECL (t));
277       pp_needs_newline (pp) = true;
278       break;
279
280     default:
281       pp_unsupported_tree (pp, t);
282     }
283 }
284
285 /* type-specifier:
286       void
287       char
288       short
289       int
290       long
291       float
292       double
293       signed
294       unsigned
295       _Bool                          -- C99
296       _Complex                       -- C99
297       _Imaginary                     -- C99
298       struct-or-union-specifier
299       enum-specifier
300       typedef-name.
301
302   GNU extensions.
303   simple-type-specifier:
304       __complex__
305       __vector__   */
306
307 void
308 pp_c_type_specifier (c_pretty_printer *pp, tree t)
309 {
310   const enum tree_code code = TREE_CODE (t);
311   switch (code)
312     {
313     case ERROR_MARK:
314       pp_c_ws_string (pp, M_("<type-error>"));
315       break;
316
317     case IDENTIFIER_NODE:
318       pp_c_tree_decl_identifier (pp, t);
319       break;
320
321     case VOID_TYPE:
322     case BOOLEAN_TYPE:
323     case INTEGER_TYPE:
324     case REAL_TYPE:
325     case FIXED_POINT_TYPE:
326       if (TYPE_NAME (t))
327         {
328           t = TYPE_NAME (t);
329           pp_c_type_specifier (pp, t);
330         }
331       else
332         {
333           int prec = TYPE_PRECISION (t);
334           if (ALL_FIXED_POINT_MODE_P (TYPE_MODE (t)))
335             t = c_common_type_for_mode (TYPE_MODE (t), TYPE_SATURATING (t));
336           else
337             t = c_common_type_for_mode (TYPE_MODE (t), TYPE_UNSIGNED (t));
338           if (TYPE_NAME (t))
339             {
340               pp_c_type_specifier (pp, t);
341               if (TYPE_PRECISION (t) != prec)
342                 {
343                   pp_string (pp, ":");
344                   pp_decimal_int (pp, prec);
345                 }
346             }
347           else
348             {
349               switch (code)
350                 {
351                 case INTEGER_TYPE:
352                   pp_string (pp, (TYPE_UNSIGNED (t)
353                                   ? M_("<unnamed-unsigned:")
354                                   : M_("<unnamed-signed:")));
355                   break;
356                 case REAL_TYPE:
357                   pp_string (pp, M_("<unnamed-float:"));
358                   break;
359                 case FIXED_POINT_TYPE:
360                   pp_string (pp, M_("<unnamed-fixed:"));
361                   break;
362                 default:
363                   gcc_unreachable ();
364                 }
365               pp_decimal_int (pp, prec);
366               pp_string (pp, ">");
367             }
368         }
369       break;
370
371     case TYPE_DECL:
372       if (DECL_NAME (t))
373         pp_id_expression (pp, t);
374       else
375         pp_c_ws_string (pp, M_("<typedef-error>"));
376       break;
377
378     case UNION_TYPE:
379     case RECORD_TYPE:
380     case ENUMERAL_TYPE:
381       if (code == UNION_TYPE)
382         pp_c_ws_string (pp, "union");
383       else if (code == RECORD_TYPE)
384         pp_c_ws_string (pp, "struct");
385       else if (code == ENUMERAL_TYPE)
386         pp_c_ws_string (pp, "enum");
387       else
388         pp_c_ws_string (pp, M_("<tag-error>"));
389
390       if (TYPE_NAME (t))
391         pp_id_expression (pp, TYPE_NAME (t));
392       else
393         pp_c_ws_string (pp, M_("<anonymous>"));
394       break;
395
396     default:
397       pp_unsupported_tree (pp, t);
398       break;
399     }
400 }
401
402 /* specifier-qualifier-list:
403       type-specifier specifier-qualifier-list-opt
404       type-qualifier specifier-qualifier-list-opt
405
406
407   Implementation note:  Because of the non-linearities in array or
408   function declarations, this routine prints not just the
409   specifier-qualifier-list of such entities or types of such entities,
410   but also the 'pointer' production part of their declarators.  The
411   remaining part is done by pp_declarator or pp_c_abstract_declarator.  */
412
413 void
414 pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t)
415 {
416   const enum tree_code code = TREE_CODE (t);
417
418   if (TREE_CODE (t) != POINTER_TYPE)
419     pp_c_type_qualifier_list (pp, t);
420   switch (code)
421     {
422     case REFERENCE_TYPE:
423     case POINTER_TYPE:
424       {
425         /* Get the types-specifier of this type.  */
426         tree pointee = strip_pointer_operator (TREE_TYPE (t));
427         pp_c_specifier_qualifier_list (pp, pointee);
428         if (TREE_CODE (pointee) == ARRAY_TYPE
429             || TREE_CODE (pointee) == FUNCTION_TYPE)
430           {
431             pp_c_whitespace (pp);
432             pp_c_left_paren (pp);
433           }
434         else if (!c_dialect_cxx ())
435           pp_c_whitespace (pp);
436         pp_ptr_operator (pp, t);
437       }
438       break;
439
440     case FUNCTION_TYPE:
441     case ARRAY_TYPE:
442       pp_c_specifier_qualifier_list (pp, TREE_TYPE (t));
443       break;
444
445     case VECTOR_TYPE:
446     case COMPLEX_TYPE:
447       pp_c_specifier_qualifier_list (pp, TREE_TYPE (t));
448       if (code == COMPLEX_TYPE)
449         pp_c_ws_string (pp, flag_isoc99 ? "_Complex" : "__complex__");
450       else if (code == VECTOR_TYPE)
451         pp_c_ws_string (pp, "__vector__");
452       break;
453
454     default:
455       pp_simple_type_specifier (pp, t);
456       break;
457     }
458 }
459
460 /* parameter-type-list:
461       parameter-list
462       parameter-list , ...
463
464    parameter-list:
465       parameter-declaration
466       parameter-list , parameter-declaration
467
468    parameter-declaration:
469       declaration-specifiers declarator
470       declaration-specifiers abstract-declarator(opt)   */
471
472 void
473 pp_c_parameter_type_list (c_pretty_printer *pp, tree t)
474 {
475   bool want_parm_decl = DECL_P (t) && !(pp->flags & pp_c_flag_abstract);
476   tree parms = want_parm_decl ? DECL_ARGUMENTS (t) :  TYPE_ARG_TYPES (t);
477   pp_c_left_paren (pp);
478   if (parms == void_list_node)
479     pp_c_ws_string (pp, "void");
480   else
481     {
482       bool first = true;
483       for ( ; parms && parms != void_list_node; parms = TREE_CHAIN (parms))
484         {
485           if (!first)
486             pp_separate_with (pp, ',');
487           first = false;
488           pp_declaration_specifiers
489             (pp, want_parm_decl ? parms : TREE_VALUE (parms));
490           if (want_parm_decl)
491             pp_declarator (pp, parms);
492           else
493             pp_abstract_declarator (pp, TREE_VALUE (parms));
494         }
495     }
496   pp_c_right_paren (pp);
497 }
498
499 /* abstract-declarator:
500       pointer
501       pointer(opt) direct-abstract-declarator  */
502
503 static void
504 pp_c_abstract_declarator (c_pretty_printer *pp, tree t)
505 {
506   if (TREE_CODE (t) == POINTER_TYPE)
507     {
508       if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE
509           || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
510         pp_c_right_paren (pp);
511       t = TREE_TYPE (t);
512     }
513
514   pp_direct_abstract_declarator (pp, t);
515 }
516
517 /* direct-abstract-declarator:
518       ( abstract-declarator )
519       direct-abstract-declarator(opt) [ assignment-expression(opt) ]
520       direct-abstract-declarator(opt) [ * ]
521       direct-abstract-declarator(opt) ( parameter-type-list(opt) )  */
522
523 void
524 pp_c_direct_abstract_declarator (c_pretty_printer *pp, tree t)
525 {
526   switch (TREE_CODE (t))
527     {
528     case POINTER_TYPE:
529       pp_abstract_declarator (pp, t);
530       break;
531
532     case FUNCTION_TYPE:
533       pp_c_parameter_type_list (pp, t);
534       pp_direct_abstract_declarator (pp, TREE_TYPE (t));
535       break;
536
537     case ARRAY_TYPE:
538       pp_c_left_bracket (pp);
539       if (TYPE_DOMAIN (t) && TYPE_MAX_VALUE (TYPE_DOMAIN (t)))
540         {
541           tree maxval = TYPE_MAX_VALUE (TYPE_DOMAIN (t));
542           tree type = TREE_TYPE (maxval);
543
544           if (host_integerp (maxval, 0))
545             pp_wide_integer (pp, tree_low_cst (maxval, 0) + 1);
546           else
547             pp_expression (pp, fold_build2 (PLUS_EXPR, type, maxval,
548                                             build_int_cst (type, 1)));
549         }
550       pp_c_right_bracket (pp);
551       pp_direct_abstract_declarator (pp, TREE_TYPE (t));
552       break;
553
554     case IDENTIFIER_NODE:
555     case VOID_TYPE:
556     case BOOLEAN_TYPE:
557     case INTEGER_TYPE:
558     case REAL_TYPE:
559     case FIXED_POINT_TYPE:
560     case ENUMERAL_TYPE:
561     case RECORD_TYPE:
562     case UNION_TYPE:
563     case VECTOR_TYPE:
564     case COMPLEX_TYPE:
565     case TYPE_DECL:
566       break;
567
568     default:
569       pp_unsupported_tree (pp, t);
570       break;
571     }
572 }
573
574 /* type-name:
575       specifier-qualifier-list  abstract-declarator(opt)  */
576
577 void
578 pp_c_type_id (c_pretty_printer *pp, tree t)
579 {
580   pp_c_specifier_qualifier_list (pp, t);
581   pp_abstract_declarator (pp, t);
582 }
583
584 /* storage-class-specifier:
585       typedef
586       extern
587       static
588       auto
589       register  */
590
591 void
592 pp_c_storage_class_specifier (c_pretty_printer *pp, tree t)
593 {
594   if (TREE_CODE (t) == TYPE_DECL)
595     pp_c_ws_string (pp, "typedef");
596   else if (DECL_P (t))
597     {
598       if (DECL_REGISTER (t))
599         pp_c_ws_string (pp, "register");
600       else if (TREE_STATIC (t) && TREE_CODE (t) == VAR_DECL)
601         pp_c_ws_string (pp, "static");
602     }
603 }
604
605 /* function-specifier:
606       inline   */
607
608 void
609 pp_c_function_specifier (c_pretty_printer *pp, tree t)
610 {
611   if (TREE_CODE (t) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (t))
612     pp_c_ws_string (pp, "inline");
613 }
614
615 /* declaration-specifiers:
616       storage-class-specifier declaration-specifiers(opt)
617       type-specifier declaration-specifiers(opt)
618       type-qualifier declaration-specifiers(opt)
619       function-specifier declaration-specifiers(opt)  */
620
621 void
622 pp_c_declaration_specifiers (c_pretty_printer *pp, tree t)
623 {
624   pp_storage_class_specifier (pp, t);
625   pp_function_specifier (pp, t);
626   pp_c_specifier_qualifier_list (pp, DECL_P (t) ?  TREE_TYPE (t) : t);
627 }
628
629 /* direct-declarator
630       identifier
631       ( declarator )
632       direct-declarator [ type-qualifier-list(opt) assignment-expression(opt) ]
633       direct-declarator [ static type-qualifier-list(opt) assignment-expression(opt)]
634       direct-declarator [ type-qualifier-list static assignment-expression ]
635       direct-declarator [ type-qualifier-list * ]
636       direct-declarator ( parameter-type-list )
637       direct-declarator ( identifier-list(opt) )  */
638
639 void
640 pp_c_direct_declarator (c_pretty_printer *pp, tree t)
641 {
642   switch (TREE_CODE (t))
643     {
644     case VAR_DECL:
645     case PARM_DECL:
646     case TYPE_DECL:
647     case FIELD_DECL:
648     case LABEL_DECL:
649       pp_c_space_for_pointer_operator (pp, TREE_TYPE (t));
650       pp_c_tree_decl_identifier (pp, t);
651       break;
652
653     case ARRAY_TYPE:
654     case POINTER_TYPE:
655       pp_abstract_declarator (pp, TREE_TYPE (t));
656       break;
657
658     case FUNCTION_TYPE:
659       pp_parameter_list (pp, t);
660       pp_abstract_declarator (pp, TREE_TYPE (t));
661       break;
662
663     case FUNCTION_DECL:
664       pp_c_space_for_pointer_operator (pp, TREE_TYPE (TREE_TYPE (t)));
665       pp_c_tree_decl_identifier (pp, t);
666       if (pp_c_base (pp)->flags & pp_c_flag_abstract)
667         pp_abstract_declarator (pp, TREE_TYPE (t));
668       else
669         {
670           pp_parameter_list (pp, t);
671           pp_abstract_declarator (pp, TREE_TYPE (TREE_TYPE (t)));
672         }
673       break;
674
675     case INTEGER_TYPE:
676     case REAL_TYPE:
677     case FIXED_POINT_TYPE:
678     case ENUMERAL_TYPE:
679     case UNION_TYPE:
680     case RECORD_TYPE:
681       break;
682
683     default:
684       pp_unsupported_tree (pp, t);
685       break;
686     }
687 }
688
689
690 /* declarator:
691       pointer(opt)  direct-declarator   */
692
693 void
694 pp_c_declarator (c_pretty_printer *pp, tree t)
695 {
696   switch (TREE_CODE (t))
697     {
698     case INTEGER_TYPE:
699     case REAL_TYPE:
700     case FIXED_POINT_TYPE:
701     case ENUMERAL_TYPE:
702     case UNION_TYPE:
703     case RECORD_TYPE:
704       break;
705
706     case VAR_DECL:
707     case PARM_DECL:
708     case FIELD_DECL:
709     case ARRAY_TYPE:
710     case FUNCTION_TYPE:
711     case FUNCTION_DECL:
712     case TYPE_DECL:
713       pp_direct_declarator (pp, t);
714     break;
715
716
717     default:
718       pp_unsupported_tree (pp, t);
719       break;
720     }
721 }
722
723 /* declaration:
724       declaration-specifiers init-declarator-list(opt) ;  */
725
726 void
727 pp_c_declaration (c_pretty_printer *pp, tree t)
728 {
729   pp_declaration_specifiers (pp, t);
730   pp_c_init_declarator (pp, t);
731 }
732
733 /* Pretty-print ATTRIBUTES using GNU C extension syntax.  */
734
735 void
736 pp_c_attributes (c_pretty_printer *pp, tree attributes)
737 {
738   if (attributes == NULL_TREE)
739     return;
740
741   pp_c_ws_string (pp, "__attribute__");
742   pp_c_left_paren (pp);
743   pp_c_left_paren (pp);
744   for (; attributes != NULL_TREE; attributes = TREE_CHAIN (attributes))
745     {
746       pp_tree_identifier (pp, TREE_PURPOSE (attributes));
747       if (TREE_VALUE (attributes))
748         pp_c_call_argument_list (pp, TREE_VALUE (attributes));
749
750       if (TREE_CHAIN (attributes))
751         pp_separate_with (pp, ',');
752     }
753   pp_c_right_paren (pp);
754   pp_c_right_paren (pp);
755 }
756
757 /* function-definition:
758       declaration-specifiers declarator compound-statement  */
759
760 void
761 pp_c_function_definition (c_pretty_printer *pp, tree t)
762 {
763   pp_declaration_specifiers (pp, t);
764   pp_declarator (pp, t);
765   pp_needs_newline (pp) = true;
766   pp_statement (pp, DECL_SAVED_TREE (t));
767   pp_newline (pp);
768   pp_flush (pp);
769 }
770
771 \f
772 /* Expressions.  */
773
774 /* Print out a c-char.  This is called solely for characters which are
775    in the *target* execution character set.  We ought to convert them
776    back to the *host* execution character set before printing, but we
777    have no way to do this at present.  A decent compromise is to print
778    all characters as if they were in the host execution character set,
779    and not attempt to recover any named escape characters, but render
780    all unprintables as octal escapes.  If the host and target character
781    sets are the same, this produces relatively readable output.  If they
782    are not the same, strings may appear as gibberish, but that's okay
783    (in fact, it may well be what the reader wants, e.g. if they are looking
784    to see if conversion to the target character set happened correctly).
785
786    A special case: we need to prefix \, ", and ' with backslashes.  It is
787    correct to do so for the *host*'s \, ", and ', because the rest of the
788    file appears in the host character set.  */
789
790 static void
791 pp_c_char (c_pretty_printer *pp, int c)
792 {
793   if (ISPRINT (c))
794     {
795       switch (c)
796         {
797         case '\\': pp_string (pp, "\\\\"); break;
798         case '\'': pp_string (pp, "\\\'"); break;
799         case '\"': pp_string (pp, "\\\""); break;
800         default:   pp_character (pp, c);
801         }
802     }
803   else
804     pp_scalar (pp, "\\%03o", (unsigned) c);
805 }
806
807 /* Print out a STRING literal.  */
808
809 void
810 pp_c_string_literal (c_pretty_printer *pp, tree s)
811 {
812   const char *p = TREE_STRING_POINTER (s);
813   int n = TREE_STRING_LENGTH (s) - 1;
814   int i;
815   pp_doublequote (pp);
816   for (i = 0; i < n; ++i)
817     pp_c_char (pp, p[i]);
818   pp_doublequote (pp);
819 }
820
821 /* Pretty-print an INTEGER literal.  */
822
823 static void
824 pp_c_integer_constant (c_pretty_printer *pp, tree i)
825 {
826   tree type = TREE_TYPE (i);
827
828   if (TREE_INT_CST_HIGH (i) == 0)
829     pp_wide_integer (pp, TREE_INT_CST_LOW (i));
830   else
831     {
832       unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (i);
833       HOST_WIDE_INT high = TREE_INT_CST_HIGH (i);
834       if (tree_int_cst_sgn (i) < 0)
835         {
836           pp_character (pp, '-');
837           high = ~high + !low;
838           low = -low;
839         }
840       sprintf (pp_buffer (pp)->digit_buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX, 
841                (unsigned HOST_WIDE_INT) high, (unsigned HOST_WIDE_INT) low);
842       pp_string (pp, pp_buffer (pp)->digit_buffer);
843     }
844   if (TYPE_UNSIGNED (type))
845     pp_character (pp, 'u');
846   if (type == long_integer_type_node || type == long_unsigned_type_node)
847     pp_character (pp, 'l');
848   else if (type == long_long_integer_type_node
849            || type == long_long_unsigned_type_node)
850     pp_string (pp, "ll");
851 }
852
853 /* Print out a CHARACTER literal.  */
854
855 static void
856 pp_c_character_constant (c_pretty_printer *pp, tree c)
857 {
858   tree type = TREE_TYPE (c);
859   if (type == wchar_type_node)
860     pp_character (pp, 'L');
861   pp_quote (pp);
862   if (host_integerp (c, TYPE_UNSIGNED (type)))
863     pp_c_char (pp, tree_low_cst (c, TYPE_UNSIGNED (type)));
864   else
865     pp_scalar (pp, "\\x%x", (unsigned) TREE_INT_CST_LOW (c));
866   pp_quote (pp);
867 }
868
869 /* Print out a BOOLEAN literal.  */
870
871 static void
872 pp_c_bool_constant (c_pretty_printer *pp, tree b)
873 {
874   if (b == boolean_false_node)
875     {
876       if (c_dialect_cxx ())
877         pp_c_ws_string (pp, "false");
878       else if (flag_isoc99)
879         pp_c_ws_string (pp, "_False");
880       else
881         pp_unsupported_tree (pp, b);
882     }
883   else if (b == boolean_true_node)
884     {
885       if (c_dialect_cxx ())
886         pp_c_ws_string (pp, "true");
887       else if (flag_isoc99)
888         pp_c_ws_string (pp, "_True");
889       else
890         pp_unsupported_tree (pp, b);
891     }
892   else if (TREE_CODE (b) == INTEGER_CST)
893     pp_c_integer_constant (pp, b);
894   else
895     pp_unsupported_tree (pp, b);
896 }
897
898 /* Attempt to print out an ENUMERATOR.  Return true on success.  Else return
899    false; that means the value was obtained by a cast, in which case
900    print out the type-id part of the cast-expression -- the casted value
901    is then printed by pp_c_integer_literal.  */
902
903 static bool
904 pp_c_enumeration_constant (c_pretty_printer *pp, tree e)
905 {
906   bool value_is_named = true;
907   tree type = TREE_TYPE (e);
908   tree value;
909
910   /* Find the name of this constant.  */
911   for (value = TYPE_VALUES (type);
912        value != NULL_TREE && !tree_int_cst_equal (TREE_VALUE (value), e);
913        value = TREE_CHAIN (value))
914     ;
915
916   if (value != NULL_TREE)
917     pp_id_expression (pp, TREE_PURPOSE (value));
918   else
919     {
920       /* Value must have been cast.  */
921       pp_c_type_cast (pp, type);
922       value_is_named = false;
923     }
924
925   return value_is_named;
926 }
927
928 /* Print out a REAL value as a decimal-floating-constant.  */
929
930 static void
931 pp_c_floating_constant (c_pretty_printer *pp, tree r)
932 {
933   real_to_decimal (pp_buffer (pp)->digit_buffer, &TREE_REAL_CST (r),
934                    sizeof (pp_buffer (pp)->digit_buffer), 0, 1);
935   pp_string (pp, pp_buffer(pp)->digit_buffer);
936   if (TREE_TYPE (r) == float_type_node)
937     pp_character (pp, 'f');
938   else if (TREE_TYPE (r) == long_double_type_node)
939     pp_character (pp, 'l');
940   else if (TREE_TYPE (r) == dfloat128_type_node)
941     pp_string (pp, "dl");
942   else if (TREE_TYPE (r) == dfloat64_type_node)
943     pp_string (pp, "dd");
944   else if (TREE_TYPE (r) == dfloat32_type_node)
945     pp_string (pp, "df");
946 }
947
948 /* Print out a FIXED value as a decimal-floating-constant.  */
949
950 static void
951 pp_c_fixed_constant (c_pretty_printer *pp, tree r)
952 {
953   fixed_to_decimal (pp_buffer (pp)->digit_buffer, &TREE_FIXED_CST (r),
954                    sizeof (pp_buffer (pp)->digit_buffer));
955   pp_string (pp, pp_buffer(pp)->digit_buffer);
956 }
957
958 /* Pretty-print a compound literal expression.  GNU extensions include
959    vector constants.  */
960
961 static void
962 pp_c_compound_literal (c_pretty_printer *pp, tree e)
963 {
964   tree type = TREE_TYPE (e);
965   pp_c_type_cast (pp, type);
966
967   switch (TREE_CODE (type))
968     {
969     case RECORD_TYPE:
970     case UNION_TYPE:
971     case ARRAY_TYPE:
972     case VECTOR_TYPE:
973     case COMPLEX_TYPE:
974       pp_c_brace_enclosed_initializer_list (pp, e);
975       break;
976
977     default:
978       pp_unsupported_tree (pp, e);
979       break;
980     }
981 }
982
983 /* Pretty-print a COMPLEX_EXPR expression.  */
984
985 static void
986 pp_c_complex_expr (c_pretty_printer *pp, tree e)
987 {
988   /* Handle a few common special cases, otherwise fallback
989      to printing it as compound literal.  */
990   tree type = TREE_TYPE (e);
991   tree realexpr = TREE_OPERAND (e, 0);
992   tree imagexpr = TREE_OPERAND (e, 1);
993
994   /* Cast of an COMPLEX_TYPE expression to a different COMPLEX_TYPE.  */
995   if (TREE_CODE (realexpr) == NOP_EXPR
996       && TREE_CODE (imagexpr) == NOP_EXPR
997       && TREE_TYPE (realexpr) == TREE_TYPE (type)
998       && TREE_TYPE (imagexpr) == TREE_TYPE (type)
999       && TREE_CODE (TREE_OPERAND (realexpr, 0)) == REALPART_EXPR
1000       && TREE_CODE (TREE_OPERAND (imagexpr, 0)) == IMAGPART_EXPR
1001       && TREE_OPERAND (TREE_OPERAND (realexpr, 0), 0)
1002          == TREE_OPERAND (TREE_OPERAND (imagexpr, 0), 0))
1003     {
1004       pp_c_type_cast (pp, type);
1005       pp_expression (pp, TREE_OPERAND (TREE_OPERAND (realexpr, 0), 0));
1006       return;
1007     }
1008
1009   /* Cast of an scalar expression to COMPLEX_TYPE.  */
1010   if ((integer_zerop (imagexpr) || real_zerop (imagexpr))
1011       && TREE_TYPE (realexpr) == TREE_TYPE (type))
1012     {
1013       pp_c_type_cast (pp, type);
1014       if (TREE_CODE (realexpr) == NOP_EXPR)
1015         realexpr = TREE_OPERAND (realexpr, 0);
1016       pp_expression (pp, realexpr);
1017       return;
1018     }
1019
1020   pp_c_compound_literal (pp, e);
1021 }
1022
1023 /* constant:
1024       integer-constant
1025       floating-constant
1026       fixed-point-constant
1027       enumeration-constant
1028       character-constant   */
1029
1030 void
1031 pp_c_constant (c_pretty_printer *pp, tree e)
1032 {
1033   const enum tree_code code = TREE_CODE (e);
1034
1035   switch (code)
1036     {
1037     case INTEGER_CST:
1038       {
1039         tree type = TREE_TYPE (e);
1040         if (type == boolean_type_node)
1041           pp_c_bool_constant (pp, e);
1042         else if (type == char_type_node)
1043           pp_c_character_constant (pp, e);
1044         else if (TREE_CODE (type) == ENUMERAL_TYPE
1045                  && pp_c_enumeration_constant (pp, e))
1046           ;
1047         else
1048           pp_c_integer_constant (pp, e);
1049       }
1050       break;
1051
1052     case REAL_CST:
1053       pp_c_floating_constant (pp, e);
1054       break;
1055
1056     case FIXED_CST:
1057       pp_c_fixed_constant (pp, e);
1058       break;
1059
1060     case STRING_CST:
1061       pp_c_string_literal (pp, e);
1062       break;
1063
1064     case COMPLEX_CST:
1065       /* Sometimes, we are confused and we think a complex literal
1066          is a constant.  Such thing is a compound literal which
1067          grammatically belongs to postfix-expr production.  */
1068       pp_c_compound_literal (pp, e);
1069       break;
1070
1071     default:
1072       pp_unsupported_tree (pp, e);
1073       break;
1074     }
1075 }
1076
1077 /* Pretty-print a string such as an identifier, without changing its
1078    encoding, preceded by whitespace is necessary.  */
1079
1080 void
1081 pp_c_ws_string (c_pretty_printer *pp, const char *str)
1082 {
1083   pp_c_maybe_whitespace (pp);
1084   pp_string (pp, str);
1085   pp_base (pp)->padding = pp_before;
1086 }
1087
1088 /* Pretty-print an IDENTIFIER_NODE, which may contain UTF-8 sequences
1089    that need converting to the locale encoding, preceded by whitespace
1090    is necessary.  */
1091
1092 void
1093 pp_c_identifier (c_pretty_printer *pp, const char *id)
1094 {
1095   pp_c_maybe_whitespace (pp);
1096   pp_identifier (pp, id);
1097   pp_base (pp)->padding = pp_before;
1098 }
1099
1100 /* Pretty-print a C primary-expression.
1101    primary-expression:
1102       identifier
1103       constant
1104       string-literal
1105       ( expression )   */
1106
1107 void
1108 pp_c_primary_expression (c_pretty_printer *pp, tree e)
1109 {
1110   switch (TREE_CODE (e))
1111     {
1112     case VAR_DECL:
1113     case PARM_DECL:
1114     case FIELD_DECL:
1115     case CONST_DECL:
1116     case FUNCTION_DECL:
1117     case LABEL_DECL:
1118       pp_c_tree_decl_identifier (pp, e);
1119       break;
1120
1121     case IDENTIFIER_NODE:
1122       pp_c_tree_identifier (pp, e);
1123       break;
1124
1125     case ERROR_MARK:
1126       pp_c_ws_string (pp, M_("<erroneous-expression>"));
1127       break;
1128
1129     case RESULT_DECL:
1130       pp_c_ws_string (pp, M_("<return-value>"));
1131       break;
1132
1133     case INTEGER_CST:
1134     case REAL_CST:
1135     case FIXED_CST:
1136     case STRING_CST:
1137       pp_c_constant (pp, e);
1138       break;
1139
1140     case TARGET_EXPR:
1141       pp_c_ws_string (pp, "__builtin_memcpy");
1142       pp_c_left_paren (pp);
1143       pp_ampersand (pp);
1144       pp_primary_expression (pp, TREE_OPERAND (e, 0));
1145       pp_separate_with (pp, ',');
1146       pp_ampersand (pp);
1147       pp_initializer (pp, TREE_OPERAND (e, 1));
1148       if (TREE_OPERAND (e, 2))
1149         {
1150           pp_separate_with (pp, ',');
1151           pp_c_expression (pp, TREE_OPERAND (e, 2));
1152         }
1153       pp_c_right_paren (pp);
1154       break;
1155
1156     default:
1157       /* FIXME:  Make sure we won't get into an infinite loop.  */
1158       pp_c_left_paren (pp);
1159       pp_expression (pp, e);
1160       pp_c_right_paren (pp);
1161       break;
1162     }
1163 }
1164
1165 /* Print out a C initializer -- also support C compound-literals.
1166    initializer:
1167       assignment-expression:
1168       { initializer-list }
1169       { initializer-list , }   */
1170
1171 static void
1172 pp_c_initializer (c_pretty_printer *pp, tree e)
1173 {
1174   if (TREE_CODE (e) == CONSTRUCTOR)
1175     pp_c_brace_enclosed_initializer_list (pp, e);
1176   else
1177     pp_expression (pp, e);
1178 }
1179
1180 /* init-declarator:
1181       declarator:
1182       declarator = initializer   */
1183
1184 void
1185 pp_c_init_declarator (c_pretty_printer *pp, tree t)
1186 {
1187   pp_declarator (pp, t);
1188   /* We don't want to output function definitions here.  There are handled
1189      elsewhere (and the syntactic form is bogus anyway).  */
1190   if (TREE_CODE (t) != FUNCTION_DECL && DECL_INITIAL (t))
1191     {
1192       tree init = DECL_INITIAL (t);
1193       /* This C++ bit is handled here because it is easier to do so.
1194          In templates, the C++ parser builds a TREE_LIST for a
1195          direct-initialization; the TREE_PURPOSE is the variable to
1196          initialize and the TREE_VALUE is the initializer.  */
1197       if (TREE_CODE (init) == TREE_LIST)
1198         {
1199           pp_c_left_paren (pp);
1200           pp_expression (pp, TREE_VALUE (init));
1201           pp_right_paren (pp);
1202         }
1203       else
1204         {
1205           pp_space (pp);
1206           pp_equal (pp);
1207           pp_space (pp);
1208           pp_c_initializer (pp, init);
1209         }
1210     }
1211 }
1212
1213 /* initializer-list:
1214       designation(opt) initializer
1215       initializer-list , designation(opt) initializer
1216
1217    designation:
1218       designator-list =
1219
1220    designator-list:
1221       designator
1222       designator-list designator
1223
1224    designator:
1225       [ constant-expression ]
1226       identifier   */
1227
1228 static void
1229 pp_c_initializer_list (c_pretty_printer *pp, tree e)
1230 {
1231   tree type = TREE_TYPE (e);
1232   const enum tree_code code = TREE_CODE (type);
1233
1234   if (TREE_CODE (e) == CONSTRUCTOR)
1235     {
1236       pp_c_constructor_elts (pp, CONSTRUCTOR_ELTS (e));
1237       return;
1238     }
1239
1240   switch (code)
1241     {
1242     case RECORD_TYPE:
1243     case UNION_TYPE:
1244     case ARRAY_TYPE:
1245       {
1246         tree init = TREE_OPERAND (e, 0);
1247         for (; init != NULL_TREE; init = TREE_CHAIN (init))
1248           {
1249             if (code == RECORD_TYPE || code == UNION_TYPE)
1250               {
1251                 pp_c_dot (pp);
1252                 pp_c_primary_expression (pp, TREE_PURPOSE (init));
1253               }
1254             else
1255               {
1256                 pp_c_left_bracket (pp);
1257                 if (TREE_PURPOSE (init))
1258                   pp_c_constant (pp, TREE_PURPOSE (init));
1259                 pp_c_right_bracket (pp);
1260               }
1261             pp_c_whitespace (pp);
1262             pp_equal (pp);
1263             pp_c_whitespace (pp);
1264             pp_initializer (pp, TREE_VALUE (init));
1265             if (TREE_CHAIN (init))
1266               pp_separate_with (pp, ',');
1267           }
1268       }
1269       return;
1270
1271     case VECTOR_TYPE:
1272       if (TREE_CODE (e) == VECTOR_CST)
1273         pp_c_expression_list (pp, TREE_VECTOR_CST_ELTS (e));
1274       else
1275         break;
1276       return;
1277
1278     case COMPLEX_TYPE:
1279       if (TREE_CODE (e) == COMPLEX_CST || TREE_CODE (e) == COMPLEX_EXPR)
1280         {
1281           const bool cst = TREE_CODE (e) == COMPLEX_CST;
1282           pp_expression (pp, cst ? TREE_REALPART (e) : TREE_OPERAND (e, 0));
1283           pp_separate_with (pp, ',');
1284           pp_expression (pp, cst ? TREE_IMAGPART (e) : TREE_OPERAND (e, 1));
1285         }
1286       else
1287         break;
1288       return;
1289
1290     default:
1291       break;
1292     }
1293
1294   pp_unsupported_tree (pp, type);
1295 }
1296
1297 /* Pretty-print a brace-enclosed initializer-list.  */
1298
1299 static void
1300 pp_c_brace_enclosed_initializer_list (c_pretty_printer *pp, tree l)
1301 {
1302   pp_c_left_brace (pp);
1303   pp_c_initializer_list (pp, l);
1304   pp_c_right_brace (pp);
1305 }
1306
1307
1308 /*  This is a convenient function, used to bridge gap between C and C++
1309     grammars.
1310
1311     id-expression:
1312        identifier  */
1313
1314 void
1315 pp_c_id_expression (c_pretty_printer *pp, tree t)
1316 {
1317   switch (TREE_CODE (t))
1318     {
1319     case VAR_DECL:
1320     case PARM_DECL:
1321     case CONST_DECL:
1322     case TYPE_DECL:
1323     case FUNCTION_DECL:
1324     case FIELD_DECL:
1325     case LABEL_DECL:
1326       pp_c_tree_decl_identifier (pp, t);
1327       break;
1328
1329     case IDENTIFIER_NODE:
1330       pp_c_tree_identifier (pp, t);
1331       break;
1332
1333     default:
1334       pp_unsupported_tree (pp, t);
1335       break;
1336     }
1337 }
1338
1339 /* postfix-expression:
1340       primary-expression
1341       postfix-expression [ expression ]
1342       postfix-expression ( argument-expression-list(opt) )
1343       postfix-expression . identifier
1344       postfix-expression -> identifier
1345       postfix-expression ++
1346       postfix-expression --
1347       ( type-name ) { initializer-list }
1348       ( type-name ) { initializer-list , }  */
1349
1350 void
1351 pp_c_postfix_expression (c_pretty_printer *pp, tree e)
1352 {
1353   enum tree_code code = TREE_CODE (e);
1354   switch (code)
1355     {
1356     case POSTINCREMENT_EXPR:
1357     case POSTDECREMENT_EXPR:
1358       pp_postfix_expression (pp, TREE_OPERAND (e, 0));
1359       pp_string (pp, code == POSTINCREMENT_EXPR ? "++" : "--");
1360       break;
1361
1362     case ARRAY_REF:
1363       pp_postfix_expression (pp, TREE_OPERAND (e, 0));
1364       pp_c_left_bracket (pp);
1365       pp_expression (pp, TREE_OPERAND (e, 1));
1366       pp_c_right_bracket (pp);
1367       break;
1368
1369     case CALL_EXPR:
1370       {
1371         call_expr_arg_iterator iter;
1372         tree arg;
1373         pp_postfix_expression (pp, CALL_EXPR_FN (e));
1374         pp_c_left_paren (pp);
1375         FOR_EACH_CALL_EXPR_ARG (arg, iter, e)
1376           {
1377             pp_expression (pp, arg);
1378             if (more_call_expr_args_p (&iter))
1379               pp_separate_with (pp, ',');
1380           }
1381         pp_c_right_paren (pp);
1382         break;
1383       }
1384
1385     case UNORDERED_EXPR:
1386       pp_c_ws_string (pp, flag_isoc99
1387                            ? "isunordered"
1388                            : "__builtin_isunordered");
1389       goto two_args_fun;
1390
1391     case ORDERED_EXPR:
1392       pp_c_ws_string (pp, flag_isoc99
1393                            ? "!isunordered"
1394                            : "!__builtin_isunordered");
1395       goto two_args_fun;
1396
1397     case UNLT_EXPR:
1398       pp_c_ws_string (pp, flag_isoc99
1399                            ? "!isgreaterequal"
1400                            : "!__builtin_isgreaterequal");
1401       goto two_args_fun;
1402
1403     case UNLE_EXPR:
1404       pp_c_ws_string (pp, flag_isoc99
1405                            ? "!isgreater"
1406                            : "!__builtin_isgreater");
1407       goto two_args_fun;
1408
1409     case UNGT_EXPR:
1410       pp_c_ws_string (pp, flag_isoc99
1411                            ? "!islessequal"
1412                            : "!__builtin_islessequal");
1413       goto two_args_fun;
1414
1415     case UNGE_EXPR:
1416       pp_c_ws_string (pp, flag_isoc99
1417                            ? "!isless"
1418                            : "!__builtin_isless");
1419       goto two_args_fun;
1420
1421     case UNEQ_EXPR:
1422       pp_c_ws_string (pp, flag_isoc99
1423                            ? "!islessgreater"
1424                            : "!__builtin_islessgreater");
1425       goto two_args_fun;
1426
1427     case LTGT_EXPR:
1428       pp_c_ws_string (pp, flag_isoc99
1429                            ? "islessgreater"
1430                            : "__builtin_islessgreater");
1431       goto two_args_fun;
1432
1433     two_args_fun:
1434       pp_c_left_paren (pp);
1435       pp_expression (pp, TREE_OPERAND (e, 0));
1436       pp_separate_with (pp, ',');
1437       pp_expression (pp, TREE_OPERAND (e, 1));
1438       pp_c_right_paren (pp);
1439       break;
1440
1441     case ABS_EXPR:
1442       pp_c_ws_string (pp, "__builtin_abs");
1443       pp_c_left_paren (pp);
1444       pp_expression (pp, TREE_OPERAND (e, 0));
1445       pp_c_right_paren (pp);
1446       break;
1447
1448     case COMPONENT_REF:
1449       {
1450         tree object = TREE_OPERAND (e, 0);
1451         if (TREE_CODE (object) == INDIRECT_REF)
1452           {
1453             pp_postfix_expression (pp, TREE_OPERAND (object, 0));
1454             pp_c_arrow (pp);
1455           }
1456         else
1457           {
1458             pp_postfix_expression (pp, object);
1459             pp_c_dot (pp);
1460           }
1461         pp_expression (pp, TREE_OPERAND (e, 1));
1462       }
1463       break;
1464
1465     case BIT_FIELD_REF:
1466       {
1467         tree type = TREE_TYPE (e);
1468
1469         type = signed_or_unsigned_type_for (TYPE_UNSIGNED (type), type);
1470         if (type
1471             && tree_int_cst_equal (TYPE_SIZE (type), TREE_OPERAND (e, 1)))
1472           {
1473             HOST_WIDE_INT bitpos = tree_low_cst (TREE_OPERAND (e, 2), 0);
1474             HOST_WIDE_INT size = tree_low_cst (TYPE_SIZE (type), 0);
1475             if ((bitpos % size) == 0)
1476               {
1477                 pp_c_left_paren (pp);
1478                 pp_c_left_paren (pp);
1479                 pp_type_id (pp, type);
1480                 pp_c_star (pp);
1481                 pp_c_right_paren (pp);
1482                 pp_c_ampersand (pp);
1483                 pp_expression (pp, TREE_OPERAND (e, 0));
1484                 pp_c_right_paren (pp);
1485                 pp_c_left_bracket (pp);
1486                 pp_wide_integer (pp, bitpos / size);
1487                 pp_c_right_bracket (pp);
1488                 break;
1489               }
1490           }
1491         pp_unsupported_tree (pp, e);
1492       }
1493       break;
1494
1495     case COMPLEX_CST:
1496     case VECTOR_CST:
1497       pp_c_compound_literal (pp, e);
1498       break;
1499
1500     case COMPLEX_EXPR:
1501       pp_c_complex_expr (pp, e);
1502       break;
1503
1504     case COMPOUND_LITERAL_EXPR:
1505       e = DECL_INITIAL (COMPOUND_LITERAL_EXPR_DECL (e));
1506       /* Fall through.  */
1507     case CONSTRUCTOR:
1508       pp_initializer (pp, e);
1509       break;
1510
1511     case VA_ARG_EXPR:
1512       pp_c_ws_string (pp, "__builtin_va_arg");
1513       pp_c_left_paren (pp);
1514       pp_assignment_expression (pp, TREE_OPERAND (e, 0));
1515       pp_separate_with (pp, ',');
1516       pp_type_id (pp, TREE_TYPE (e));
1517       pp_c_right_paren (pp);
1518       break;
1519
1520     case ADDR_EXPR:
1521       if (TREE_CODE (TREE_OPERAND (e, 0)) == FUNCTION_DECL)
1522         {
1523           pp_c_id_expression (pp, TREE_OPERAND (e, 0));
1524           break;
1525         }
1526       /* else fall through.  */
1527
1528     default:
1529       pp_primary_expression (pp, e);
1530       break;
1531     }
1532 }
1533
1534 /* Print out an expression-list; E is expected to be a TREE_LIST.  */
1535
1536 void
1537 pp_c_expression_list (c_pretty_printer *pp, tree e)
1538 {
1539   for (; e != NULL_TREE; e = TREE_CHAIN (e))
1540     {
1541       pp_expression (pp, TREE_VALUE (e));
1542       if (TREE_CHAIN (e))
1543         pp_separate_with (pp, ',');
1544     }
1545 }
1546
1547 /* Print out V, which contains the elements of a constructor.  */
1548
1549 void
1550 pp_c_constructor_elts (c_pretty_printer *pp, VEC(constructor_elt,gc) *v)
1551 {
1552   unsigned HOST_WIDE_INT ix;
1553   tree value;
1554
1555   FOR_EACH_CONSTRUCTOR_VALUE (v, ix, value)
1556     {
1557       pp_expression (pp, value);
1558       if (ix != VEC_length (constructor_elt, v) - 1)
1559         pp_separate_with (pp, ',');
1560     }
1561 }
1562
1563 /* Print out an expression-list in parens, as if it were the argument
1564    list to a function.  */
1565
1566 void
1567 pp_c_call_argument_list (c_pretty_printer *pp, tree t)
1568 {
1569   pp_c_left_paren (pp);
1570   if (t && TREE_CODE (t) == TREE_LIST)
1571     pp_c_expression_list (pp, t);
1572   pp_c_right_paren (pp);
1573 }
1574
1575 /* unary-expression:
1576       postfix-expression
1577       ++ cast-expression
1578       -- cast-expression
1579       unary-operator cast-expression
1580       sizeof unary-expression
1581       sizeof ( type-id )
1582
1583   unary-operator: one of
1584       * &  + - ! ~
1585
1586    GNU extensions.
1587    unary-expression:
1588       __alignof__ unary-expression
1589       __alignof__ ( type-id )
1590       __real__ unary-expression
1591       __imag__ unary-expression  */
1592
1593 void
1594 pp_c_unary_expression (c_pretty_printer *pp, tree e)
1595 {
1596   enum tree_code code = TREE_CODE (e);
1597   switch (code)
1598     {
1599     case PREINCREMENT_EXPR:
1600     case PREDECREMENT_EXPR:
1601       pp_string (pp, code == PREINCREMENT_EXPR ? "++" : "--");
1602       pp_c_unary_expression (pp, TREE_OPERAND (e, 0));
1603       break;
1604
1605     case ADDR_EXPR:
1606     case INDIRECT_REF:
1607     case NEGATE_EXPR:
1608     case BIT_NOT_EXPR:
1609     case TRUTH_NOT_EXPR:
1610     case CONJ_EXPR:
1611       /* String literal are used by address.  */
1612       if (code == ADDR_EXPR && TREE_CODE (TREE_OPERAND (e, 0)) != STRING_CST)
1613         pp_ampersand (pp);
1614       else if (code == INDIRECT_REF)
1615         pp_c_star (pp);
1616       else if (code == NEGATE_EXPR)
1617         pp_minus (pp);
1618       else if (code == BIT_NOT_EXPR || code == CONJ_EXPR)
1619         pp_complement (pp);
1620       else if (code == TRUTH_NOT_EXPR)
1621         pp_exclamation (pp);
1622       pp_c_cast_expression (pp, TREE_OPERAND (e, 0));
1623       break;
1624
1625     case REALPART_EXPR:
1626     case IMAGPART_EXPR:
1627       pp_c_ws_string (pp, code == REALPART_EXPR ? "__real__" : "__imag__");
1628       pp_c_whitespace (pp);
1629       pp_unary_expression (pp, TREE_OPERAND (e, 0));
1630       break;
1631
1632     default:
1633       pp_postfix_expression (pp, e);
1634       break;
1635     }
1636 }
1637
1638 /* cast-expression:
1639       unary-expression
1640       ( type-name ) cast-expression  */
1641
1642 void
1643 pp_c_cast_expression (c_pretty_printer *pp, tree e)
1644 {
1645   switch (TREE_CODE (e))
1646     {
1647     case FLOAT_EXPR:
1648     case FIX_TRUNC_EXPR:
1649     CASE_CONVERT:
1650     case VIEW_CONVERT_EXPR:
1651       pp_c_type_cast (pp, TREE_TYPE (e));
1652       pp_c_cast_expression (pp, TREE_OPERAND (e, 0));
1653       break;
1654
1655     default:
1656       pp_unary_expression (pp, e);
1657     }
1658 }
1659
1660 /* multiplicative-expression:
1661       cast-expression
1662       multiplicative-expression * cast-expression
1663       multiplicative-expression / cast-expression
1664       multiplicative-expression % cast-expression   */
1665
1666 static void
1667 pp_c_multiplicative_expression (c_pretty_printer *pp, tree e)
1668 {
1669   enum tree_code code = TREE_CODE (e);
1670   switch (code)
1671     {
1672     case MULT_EXPR:
1673     case TRUNC_DIV_EXPR:
1674     case TRUNC_MOD_EXPR:
1675       pp_multiplicative_expression (pp, TREE_OPERAND (e, 0));
1676       pp_c_whitespace (pp);
1677       if (code == MULT_EXPR)
1678         pp_c_star (pp);
1679       else if (code == TRUNC_DIV_EXPR)
1680         pp_slash (pp);
1681       else
1682         pp_modulo (pp);
1683       pp_c_whitespace (pp);
1684       pp_c_cast_expression (pp, TREE_OPERAND (e, 1));
1685       break;
1686
1687     default:
1688       pp_c_cast_expression (pp, e);
1689       break;
1690     }
1691 }
1692
1693 /* additive-expression:
1694       multiplicative-expression
1695       additive-expression + multiplicative-expression
1696       additive-expression - multiplicative-expression   */
1697
1698 static void
1699 pp_c_additive_expression (c_pretty_printer *pp, tree e)
1700 {
1701   enum tree_code code = TREE_CODE (e);
1702   switch (code)
1703     {
1704     case POINTER_PLUS_EXPR:
1705     case PLUS_EXPR:
1706     case MINUS_EXPR:
1707       pp_c_additive_expression (pp, TREE_OPERAND (e, 0));
1708       pp_c_whitespace (pp);
1709       if (code == PLUS_EXPR || code == POINTER_PLUS_EXPR)
1710         pp_plus (pp);
1711       else
1712         pp_minus (pp);
1713       pp_c_whitespace (pp);
1714       pp_multiplicative_expression (pp, TREE_OPERAND (e, 1));
1715       break;
1716
1717     default:
1718       pp_multiplicative_expression (pp, e);
1719       break;
1720     }
1721 }
1722
1723 /* additive-expression:
1724       additive-expression
1725       shift-expression << additive-expression
1726       shift-expression >> additive-expression   */
1727
1728 static void
1729 pp_c_shift_expression (c_pretty_printer *pp, tree e)
1730 {
1731   enum tree_code code = TREE_CODE (e);
1732   switch (code)
1733     {
1734     case LSHIFT_EXPR:
1735     case RSHIFT_EXPR:
1736       pp_c_shift_expression (pp, TREE_OPERAND (e, 0));
1737       pp_c_whitespace (pp);
1738       pp_string (pp, code == LSHIFT_EXPR ? "<<" : ">>");
1739       pp_c_whitespace (pp);
1740       pp_c_additive_expression (pp, TREE_OPERAND (e, 1));
1741       break;
1742
1743     default:
1744       pp_c_additive_expression (pp, e);
1745     }
1746 }
1747
1748 /* relational-expression:
1749       shift-expression
1750       relational-expression < shift-expression
1751       relational-expression > shift-expression
1752       relational-expression <= shift-expression
1753       relational-expression >= shift-expression   */
1754
1755 static void
1756 pp_c_relational_expression (c_pretty_printer *pp, tree e)
1757 {
1758   enum tree_code code = TREE_CODE (e);
1759   switch (code)
1760     {
1761     case LT_EXPR:
1762     case GT_EXPR:
1763     case LE_EXPR:
1764     case GE_EXPR:
1765       pp_c_relational_expression (pp, TREE_OPERAND (e, 0));
1766       pp_c_whitespace (pp);
1767       if (code == LT_EXPR)
1768         pp_less (pp);
1769       else if (code == GT_EXPR)
1770         pp_greater (pp);
1771       else if (code == LE_EXPR)
1772         pp_string (pp, "<=");
1773       else if (code == GE_EXPR)
1774         pp_string (pp, ">=");
1775       pp_c_whitespace (pp);
1776       pp_c_shift_expression (pp, TREE_OPERAND (e, 1));
1777       break;
1778
1779     default:
1780       pp_c_shift_expression (pp, e);
1781       break;
1782     }
1783 }
1784
1785 /* equality-expression:
1786       relational-expression
1787       equality-expression == relational-expression
1788       equality-equality != relational-expression  */
1789
1790 static void
1791 pp_c_equality_expression (c_pretty_printer *pp, tree e)
1792 {
1793   enum tree_code code = TREE_CODE (e);
1794   switch (code)
1795     {
1796     case EQ_EXPR:
1797     case NE_EXPR:
1798       pp_c_equality_expression (pp, TREE_OPERAND (e, 0));
1799       pp_c_whitespace (pp);
1800       pp_string (pp, code == EQ_EXPR ? "==" : "!=");
1801       pp_c_whitespace (pp);
1802       pp_c_relational_expression (pp, TREE_OPERAND (e, 1));
1803       break;
1804
1805     default:
1806       pp_c_relational_expression (pp, e);
1807       break;
1808     }
1809 }
1810
1811 /* AND-expression:
1812       equality-expression
1813       AND-expression & equality-equality   */
1814
1815 static void
1816 pp_c_and_expression (c_pretty_printer *pp, tree e)
1817 {
1818   if (TREE_CODE (e) == BIT_AND_EXPR)
1819     {
1820       pp_c_and_expression (pp, TREE_OPERAND (e, 0));
1821       pp_c_whitespace (pp);
1822       pp_ampersand (pp);
1823       pp_c_whitespace (pp);
1824       pp_c_equality_expression (pp, TREE_OPERAND (e, 1));
1825     }
1826   else
1827     pp_c_equality_expression (pp, e);
1828 }
1829
1830 /* exclusive-OR-expression:
1831      AND-expression
1832      exclusive-OR-expression ^ AND-expression  */
1833
1834 static void
1835 pp_c_exclusive_or_expression (c_pretty_printer *pp, tree e)
1836 {
1837   if (TREE_CODE (e) == BIT_XOR_EXPR
1838       || TREE_CODE (e) == TRUTH_XOR_EXPR)
1839     {
1840       pp_c_exclusive_or_expression (pp, TREE_OPERAND (e, 0));
1841       if (TREE_CODE (e) == BIT_XOR_EXPR)
1842         pp_c_maybe_whitespace (pp);
1843       else
1844         pp_c_whitespace (pp);
1845       pp_carret (pp);
1846       pp_c_whitespace (pp);
1847       pp_c_and_expression (pp, TREE_OPERAND (e, 1));
1848     }
1849   else
1850     pp_c_and_expression (pp, e);
1851 }
1852
1853 /* inclusive-OR-expression:
1854      exclusive-OR-expression
1855      inclusive-OR-expression | exclusive-OR-expression  */
1856
1857 static void
1858 pp_c_inclusive_or_expression (c_pretty_printer *pp, tree e)
1859 {
1860   if (TREE_CODE (e) == BIT_IOR_EXPR)
1861     {
1862       pp_c_exclusive_or_expression (pp, TREE_OPERAND (e, 0));
1863       pp_c_whitespace (pp);
1864       pp_bar (pp);
1865       pp_c_whitespace (pp);
1866       pp_c_exclusive_or_expression (pp, TREE_OPERAND (e, 1));
1867     }
1868   else
1869     pp_c_exclusive_or_expression (pp, e);
1870 }
1871
1872 /* logical-AND-expression:
1873       inclusive-OR-expression
1874       logical-AND-expression && inclusive-OR-expression  */
1875
1876 static void
1877 pp_c_logical_and_expression (c_pretty_printer *pp, tree e)
1878 {
1879   if (TREE_CODE (e) == TRUTH_ANDIF_EXPR
1880       || TREE_CODE (e) == TRUTH_AND_EXPR)
1881     {
1882       pp_c_logical_and_expression (pp, TREE_OPERAND (e, 0));
1883       pp_c_whitespace (pp);
1884       pp_string (pp, "&&");
1885       pp_c_whitespace (pp);
1886       pp_c_inclusive_or_expression (pp, TREE_OPERAND (e, 1));
1887     }
1888   else
1889     pp_c_inclusive_or_expression (pp, e);
1890 }
1891
1892 /* logical-OR-expression:
1893       logical-AND-expression
1894       logical-OR-expression || logical-AND-expression  */
1895
1896 void
1897 pp_c_logical_or_expression (c_pretty_printer *pp, tree e)
1898 {
1899   if (TREE_CODE (e) == TRUTH_ORIF_EXPR
1900       || TREE_CODE (e) == TRUTH_OR_EXPR)
1901     {
1902       pp_c_logical_or_expression (pp, TREE_OPERAND (e, 0));
1903       pp_c_whitespace (pp);
1904       pp_string (pp, "||");
1905       pp_c_whitespace (pp);
1906       pp_c_logical_and_expression (pp, TREE_OPERAND (e, 1));
1907     }
1908   else
1909     pp_c_logical_and_expression (pp, e);
1910 }
1911
1912 /* conditional-expression:
1913       logical-OR-expression
1914       logical-OR-expression ? expression : conditional-expression  */
1915
1916 static void
1917 pp_c_conditional_expression (c_pretty_printer *pp, tree e)
1918 {
1919   if (TREE_CODE (e) == COND_EXPR)
1920     {
1921       pp_c_logical_or_expression (pp, TREE_OPERAND (e, 0));
1922       pp_c_whitespace (pp);
1923       pp_question (pp);
1924       pp_c_whitespace (pp);
1925       pp_expression (pp, TREE_OPERAND (e, 1));
1926       pp_c_whitespace (pp);
1927       pp_colon (pp);
1928       pp_c_whitespace (pp);
1929       pp_c_conditional_expression (pp, TREE_OPERAND (e, 2));
1930     }
1931   else
1932     pp_c_logical_or_expression (pp, e);
1933 }
1934
1935
1936 /* assignment-expression:
1937       conditional-expression
1938       unary-expression assignment-operator  assignment-expression
1939
1940    assignment-expression: one of
1941       =    *=    /=    %=    +=    -=    >>=    <<=    &=    ^=    |=  */
1942
1943 static void
1944 pp_c_assignment_expression (c_pretty_printer *pp, tree e)
1945 {
1946   if (TREE_CODE (e) == MODIFY_EXPR 
1947       || TREE_CODE (e) == INIT_EXPR)
1948     {
1949       pp_c_unary_expression (pp, TREE_OPERAND (e, 0));
1950       pp_c_whitespace (pp);
1951       pp_equal (pp);
1952       pp_space (pp);
1953       pp_c_expression (pp, TREE_OPERAND (e, 1));
1954     }
1955   else
1956     pp_c_conditional_expression (pp, e);
1957 }
1958
1959 /* expression:
1960        assignment-expression
1961        expression , assignment-expression
1962
1963   Implementation note:  instead of going through the usual recursion
1964   chain, I take the liberty of dispatching nodes to the appropriate
1965   functions.  This makes some redundancy, but it worths it. That also
1966   prevents a possible infinite recursion between pp_c_primary_expression ()
1967   and pp_c_expression ().  */
1968
1969 void
1970 pp_c_expression (c_pretty_printer *pp, tree e)
1971 {
1972   switch (TREE_CODE (e))
1973     {
1974     case INTEGER_CST:
1975       pp_c_integer_constant (pp, e);
1976       break;
1977
1978     case REAL_CST:
1979       pp_c_floating_constant (pp, e);
1980       break;
1981
1982     case FIXED_CST:
1983       pp_c_fixed_constant (pp, e);
1984       break;
1985
1986     case STRING_CST:
1987       pp_c_string_literal (pp, e);
1988       break;
1989
1990     case IDENTIFIER_NODE:
1991     case FUNCTION_DECL:
1992     case VAR_DECL:
1993     case CONST_DECL:
1994     case PARM_DECL:
1995     case RESULT_DECL:
1996     case FIELD_DECL:
1997     case LABEL_DECL:
1998     case ERROR_MARK:
1999       pp_primary_expression (pp, e);
2000       break;
2001
2002     case POSTINCREMENT_EXPR:
2003     case POSTDECREMENT_EXPR:
2004     case ARRAY_REF:
2005     case CALL_EXPR:
2006     case COMPONENT_REF:
2007     case BIT_FIELD_REF:
2008     case COMPLEX_CST:
2009     case COMPLEX_EXPR:
2010     case VECTOR_CST:
2011     case ORDERED_EXPR:
2012     case UNORDERED_EXPR:
2013     case LTGT_EXPR:
2014     case UNEQ_EXPR:
2015     case UNLE_EXPR:
2016     case UNLT_EXPR:
2017     case UNGE_EXPR:
2018     case UNGT_EXPR:
2019     case ABS_EXPR:
2020     case CONSTRUCTOR:
2021     case COMPOUND_LITERAL_EXPR:
2022     case VA_ARG_EXPR:
2023       pp_postfix_expression (pp, e);
2024       break;
2025
2026     case CONJ_EXPR:
2027     case ADDR_EXPR:
2028     case INDIRECT_REF:
2029     case NEGATE_EXPR:
2030     case BIT_NOT_EXPR:
2031     case TRUTH_NOT_EXPR:
2032     case PREINCREMENT_EXPR:
2033     case PREDECREMENT_EXPR:
2034     case REALPART_EXPR:
2035     case IMAGPART_EXPR:
2036       pp_c_unary_expression (pp, e);
2037       break;
2038
2039     case FLOAT_EXPR:
2040     case FIX_TRUNC_EXPR:
2041     CASE_CONVERT:
2042     case VIEW_CONVERT_EXPR:
2043       pp_c_cast_expression (pp, e);
2044       break;
2045
2046     case MULT_EXPR:
2047     case TRUNC_MOD_EXPR:
2048     case TRUNC_DIV_EXPR:
2049       pp_multiplicative_expression (pp, e);
2050       break;
2051
2052     case LSHIFT_EXPR:
2053     case RSHIFT_EXPR:
2054       pp_c_shift_expression (pp, e);
2055       break;
2056
2057     case LT_EXPR:
2058     case GT_EXPR:
2059     case LE_EXPR:
2060     case GE_EXPR:
2061       pp_c_relational_expression (pp, e);
2062       break;
2063
2064     case BIT_AND_EXPR:
2065       pp_c_and_expression (pp, e);
2066       break;
2067
2068     case BIT_XOR_EXPR:
2069     case TRUTH_XOR_EXPR:
2070       pp_c_exclusive_or_expression (pp, e);
2071       break;
2072
2073     case BIT_IOR_EXPR:
2074       pp_c_inclusive_or_expression (pp, e);
2075       break;
2076
2077     case TRUTH_ANDIF_EXPR:
2078     case TRUTH_AND_EXPR:
2079       pp_c_logical_and_expression (pp, e);
2080       break;
2081
2082     case TRUTH_ORIF_EXPR:
2083     case TRUTH_OR_EXPR:
2084       pp_c_logical_or_expression (pp, e);
2085       break;
2086
2087     case EQ_EXPR:
2088     case NE_EXPR:
2089       pp_c_equality_expression (pp, e);
2090       break;
2091
2092     case COND_EXPR:
2093       pp_conditional_expression (pp, e);
2094       break;
2095
2096     case POINTER_PLUS_EXPR:
2097     case PLUS_EXPR:
2098     case MINUS_EXPR:
2099       pp_c_additive_expression (pp, e);
2100       break;
2101
2102     case MODIFY_EXPR:
2103     case INIT_EXPR:
2104       pp_assignment_expression (pp, e);
2105       break;
2106
2107     case COMPOUND_EXPR:
2108       pp_c_left_paren (pp);
2109       pp_expression (pp, TREE_OPERAND (e, 0));
2110       pp_separate_with (pp, ',');
2111       pp_assignment_expression (pp, TREE_OPERAND (e, 1));
2112       pp_c_right_paren (pp);
2113       break;
2114
2115     case NON_LVALUE_EXPR:
2116     case SAVE_EXPR:
2117       pp_expression (pp, TREE_OPERAND (e, 0));
2118       break;
2119
2120     case TARGET_EXPR:
2121       pp_postfix_expression (pp, TREE_OPERAND (e, 1));
2122       break;
2123
2124     case BIND_EXPR:
2125     case GOTO_EXPR:
2126       /* We don't yet have a way of dumping statements in a
2127          human-readable format.  */
2128       pp_string (pp, "({...})");
2129       break;
2130
2131     default:
2132       pp_unsupported_tree (pp, e);
2133       break;
2134     }
2135 }
2136
2137
2138 \f
2139 /* Statements.  */
2140
2141 void
2142 pp_c_statement (c_pretty_printer *pp, tree stmt)
2143 {
2144   if (stmt == NULL)
2145     return;
2146
2147   if (pp_needs_newline (pp))
2148     pp_newline_and_indent (pp, 0);
2149
2150   dump_generic_node (pp_base (pp), stmt, pp_indentation (pp), 0, true);
2151 }
2152
2153 \f
2154 /* Initialize the PRETTY-PRINTER for handling C codes.  */
2155
2156 void
2157 pp_c_pretty_printer_init (c_pretty_printer *pp)
2158 {
2159   pp->offset_list               = 0;
2160
2161   pp->declaration               = pp_c_declaration;
2162   pp->declaration_specifiers    = pp_c_declaration_specifiers;
2163   pp->declarator                = pp_c_declarator;
2164   pp->direct_declarator         = pp_c_direct_declarator;
2165   pp->type_specifier_seq        = pp_c_specifier_qualifier_list;
2166   pp->abstract_declarator       = pp_c_abstract_declarator;
2167   pp->direct_abstract_declarator = pp_c_direct_abstract_declarator;
2168   pp->ptr_operator              = pp_c_pointer;
2169   pp->parameter_list            = pp_c_parameter_type_list;
2170   pp->type_id                   = pp_c_type_id;
2171   pp->simple_type_specifier     = pp_c_type_specifier;
2172   pp->function_specifier        = pp_c_function_specifier;
2173   pp->storage_class_specifier   = pp_c_storage_class_specifier;
2174
2175   pp->statement                 = pp_c_statement;
2176
2177   pp->constant                  = pp_c_constant;
2178   pp->id_expression             = pp_c_id_expression;
2179   pp->primary_expression        = pp_c_primary_expression;
2180   pp->postfix_expression        = pp_c_postfix_expression;
2181   pp->unary_expression          = pp_c_unary_expression;
2182   pp->initializer               = pp_c_initializer;
2183   pp->multiplicative_expression = pp_c_multiplicative_expression;
2184   pp->conditional_expression    = pp_c_conditional_expression;
2185   pp->assignment_expression     = pp_c_assignment_expression;
2186   pp->expression                = pp_c_expression;
2187 }
2188
2189
2190 /* Print the tree T in full, on file FILE.  */
2191
2192 void
2193 print_c_tree (FILE *file, tree t)
2194 {
2195   static c_pretty_printer pp_rec;
2196   static bool initialized = 0;
2197   c_pretty_printer *pp = &pp_rec;
2198
2199   if (!initialized)
2200     {
2201       initialized = 1;
2202       pp_construct (pp_base (pp), NULL, 0);
2203       pp_c_pretty_printer_init (pp);
2204       pp_needs_newline (pp) = true;
2205     }
2206   pp_base (pp)->buffer->stream = file;
2207
2208   pp_statement (pp, t);
2209
2210   pp_newline (pp);
2211   pp_flush (pp);
2212 }
2213
2214 /* Print the tree T in full, on stderr.  */
2215
2216 void
2217 debug_c_tree (tree t)
2218 {
2219   print_c_tree (stderr, t);
2220   fputc ('\n', stderr);
2221 }
2222
2223 /* Output the DECL_NAME of T.  If T has no DECL_NAME, output a string made
2224    up of T's memory address.  */
2225
2226 void
2227 pp_c_tree_decl_identifier (c_pretty_printer *pp, tree t)
2228 {
2229   const char *name;
2230
2231   gcc_assert (DECL_P (t));
2232
2233   if (DECL_NAME (t))
2234     name = IDENTIFIER_POINTER (DECL_NAME (t));
2235   else
2236     {
2237       static char xname[8];
2238       sprintf (xname, "<U%4x>", ((unsigned)((uintptr_t)(t) & 0xffff)));
2239       name = xname;
2240     }
2241
2242   pp_c_identifier (pp, name);
2243 }