1 /* Subroutines common to both C and C++ pretty-printers.
2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
3 Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
5 This file is part of GCC.
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
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
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/>. */
23 #include "coretypes.h"
26 #include "fixed-value.h"
27 #include "c-pretty-print.h"
29 #include "tree-iterator.h"
30 #include "diagnostic.h"
32 /* The pretty-printer code is primarily designed to closely follow
33 (GNU) C and C++ grammars. That is to be contrasted with spaghetti
34 codes we used to have in the past. Following a structured
35 approach (preferably the official grammars) is believed to make it
36 much easier to add extensions and nifty pretty-printing effects that
37 takes expression or declaration contexts into account. */
40 #define pp_c_maybe_whitespace(PP) \
42 if (pp_base (PP)->padding == pp_before) \
43 pp_c_whitespace (PP); \
47 static void pp_c_char (c_pretty_printer *, int);
49 /* postfix-expression */
50 static void pp_c_initializer_list (c_pretty_printer *, tree);
51 static void pp_c_brace_enclosed_initializer_list (c_pretty_printer *, tree);
53 static void pp_c_multiplicative_expression (c_pretty_printer *, tree);
54 static void pp_c_additive_expression (c_pretty_printer *, tree);
55 static void pp_c_shift_expression (c_pretty_printer *, tree);
56 static void pp_c_relational_expression (c_pretty_printer *, tree);
57 static void pp_c_equality_expression (c_pretty_printer *, tree);
58 static void pp_c_and_expression (c_pretty_printer *, tree);
59 static void pp_c_exclusive_or_expression (c_pretty_printer *, tree);
60 static void pp_c_inclusive_or_expression (c_pretty_printer *, tree);
61 static void pp_c_logical_and_expression (c_pretty_printer *, tree);
62 static void pp_c_conditional_expression (c_pretty_printer *, tree);
63 static void pp_c_assignment_expression (c_pretty_printer *, tree);
68 /* Helper functions. */
71 pp_c_whitespace (c_pretty_printer *pp)
74 pp_base (pp)->padding = pp_none;
78 pp_c_left_paren (c_pretty_printer *pp)
81 pp_base (pp)->padding = pp_none;
85 pp_c_right_paren (c_pretty_printer *pp)
88 pp_base (pp)->padding = pp_none;
92 pp_c_left_brace (c_pretty_printer *pp)
95 pp_base (pp)->padding = pp_none;
99 pp_c_right_brace (c_pretty_printer *pp)
102 pp_base (pp)->padding = pp_none;
106 pp_c_left_bracket (c_pretty_printer *pp)
108 pp_left_bracket (pp);
109 pp_base (pp)->padding = pp_none;
113 pp_c_right_bracket (c_pretty_printer *pp)
115 pp_right_bracket (pp);
116 pp_base (pp)->padding = pp_none;
120 pp_c_dot (c_pretty_printer *pp)
123 pp_base (pp)->padding = pp_none;
127 pp_c_ampersand (c_pretty_printer *pp)
130 pp_base (pp)->padding = pp_none;
134 pp_c_star (c_pretty_printer *pp)
137 pp_base (pp)->padding = pp_none;
141 pp_c_arrow (c_pretty_printer *pp)
144 pp_base (pp)->padding = pp_none;
148 pp_c_semicolon (c_pretty_printer *pp)
151 pp_base (pp)->padding = pp_none;
155 pp_c_complement (c_pretty_printer *pp)
158 pp_base (pp)->padding = pp_none;
162 pp_c_exclamation (c_pretty_printer *pp)
165 pp_base (pp)->padding = pp_none;
168 /* Print out the external representation of CV-QUALIFIER. */
171 pp_c_cv_qualifier (c_pretty_printer *pp, const char *cv)
173 const char *p = pp_last_position_in_text (pp);
174 /* The C programming language does not have references, but it is much
175 simpler to handle those here rather than going through the same
176 logic in the C++ pretty-printer. */
177 if (p != NULL && (*p == '*' || *p == '&'))
178 pp_c_whitespace (pp);
179 pp_c_identifier (pp, cv);
182 /* Pretty-print T using the type-cast notation '( type-name )'. */
185 pp_c_type_cast (c_pretty_printer *pp, tree t)
187 pp_c_left_paren (pp);
189 pp_c_right_paren (pp);
192 /* We're about to pretty-print a pointer type as indicated by T.
193 Output a whitespace, if needed, preparing for subsequent output. */
196 pp_c_space_for_pointer_operator (c_pretty_printer *pp, tree t)
198 if (POINTER_TYPE_P (t))
200 tree pointee = strip_pointer_operator (TREE_TYPE (t));
201 if (TREE_CODE (pointee) != ARRAY_TYPE
202 && TREE_CODE (pointee) != FUNCTION_TYPE)
203 pp_c_whitespace (pp);
210 /* C++ cv-qualifiers are called type-qualifiers in C. Print out the
211 cv-qualifiers of T. If T is a declaration then it is the cv-qualifier
212 of its type. Take care of possible extensions.
216 type-qualifier-list type-qualifier
221 __restrict__ -- GNU C
225 pp_c_type_qualifier_list (c_pretty_printer *pp, tree t)
232 qualifiers = TYPE_QUALS (t);
233 if (qualifiers & TYPE_QUAL_CONST)
234 pp_c_cv_qualifier (pp, "const");
235 if (qualifiers & TYPE_QUAL_VOLATILE)
236 pp_c_cv_qualifier (pp, "volatile");
237 if (qualifiers & TYPE_QUAL_RESTRICT)
238 pp_c_cv_qualifier (pp, flag_isoc99 ? "restrict" : "__restrict__");
242 * type-qualifier-list(opt)
243 * type-qualifier-list(opt) pointer */
246 pp_c_pointer (c_pretty_printer *pp, tree t)
248 if (!TYPE_P (t) && TREE_CODE (t) != TYPE_DECL)
250 switch (TREE_CODE (t))
253 /* It is easier to handle C++ reference types here. */
255 if (TREE_CODE (TREE_TYPE (t)) == POINTER_TYPE)
256 pp_c_pointer (pp, TREE_TYPE (t));
257 if (TREE_CODE (t) == POINTER_TYPE)
261 pp_c_type_qualifier_list (pp, t);
264 /* ??? This node is now in GENERIC and so shouldn't be here. But
265 we'll fix that later. */
267 pp_declaration (pp, DECL_EXPR_DECL (t));
268 pp_needs_newline (pp) = true;
272 pp_unsupported_tree (pp, t);
289 struct-or-union-specifier
294 simple-type-specifier:
299 pp_c_type_specifier (c_pretty_printer *pp, tree t)
301 const enum tree_code code = TREE_CODE (t);
305 pp_c_identifier (pp, "<type-error>");
308 case IDENTIFIER_NODE:
309 pp_c_tree_decl_identifier (pp, t);
316 case FIXED_POINT_TYPE:
320 pp_c_type_specifier (pp, t);
324 int prec = TYPE_PRECISION (t);
325 if (ALL_FIXED_POINT_MODE_P (TYPE_MODE (t)))
326 t = c_common_type_for_mode (TYPE_MODE (t), TYPE_SATURATING (t));
328 t = c_common_type_for_mode (TYPE_MODE (t), TYPE_UNSIGNED (t));
331 pp_c_type_specifier (pp, t);
332 if (TYPE_PRECISION (t) != prec)
335 pp_decimal_int (pp, prec);
343 pp_string (pp, (TYPE_UNSIGNED (t)
344 ? "<unnamed-unsigned:"
345 : "<unnamed-signed:"));
348 pp_string (pp, "<unnamed-float:");
350 case FIXED_POINT_TYPE:
351 pp_string (pp, "<unnamed-fixed:");
356 pp_decimal_int (pp, prec);
364 pp_id_expression (pp, t);
366 pp_c_identifier (pp, "<typedef-error>");
372 if (code == UNION_TYPE)
373 pp_c_identifier (pp, "union");
374 else if (code == RECORD_TYPE)
375 pp_c_identifier (pp, "struct");
376 else if (code == ENUMERAL_TYPE)
377 pp_c_identifier (pp, "enum");
379 pp_c_identifier (pp, "<tag-error>");
382 pp_id_expression (pp, TYPE_NAME (t));
384 pp_c_identifier (pp, "<anonymous>");
388 pp_unsupported_tree (pp, t);
393 /* specifier-qualifier-list:
394 type-specifier specifier-qualifier-list-opt
395 type-qualifier specifier-qualifier-list-opt
398 Implementation note: Because of the non-linearities in array or
399 function declarations, this routine prints not just the
400 specifier-qualifier-list of such entities or types of such entities,
401 but also the 'pointer' production part of their declarators. The
402 remaining part is done by pp_declarator or pp_c_abstract_declarator. */
405 pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t)
407 const enum tree_code code = TREE_CODE (t);
409 if (TREE_CODE (t) != POINTER_TYPE)
410 pp_c_type_qualifier_list (pp, t);
416 /* Get the types-specifier of this type. */
417 tree pointee = strip_pointer_operator (TREE_TYPE (t));
418 pp_c_specifier_qualifier_list (pp, pointee);
419 if (TREE_CODE (pointee) == ARRAY_TYPE
420 || TREE_CODE (pointee) == FUNCTION_TYPE)
422 pp_c_whitespace (pp);
423 pp_c_left_paren (pp);
425 else if (!c_dialect_cxx ())
426 pp_c_whitespace (pp);
427 pp_ptr_operator (pp, t);
433 pp_c_specifier_qualifier_list (pp, TREE_TYPE (t));
438 pp_c_specifier_qualifier_list (pp, TREE_TYPE (t));
439 if (code == COMPLEX_TYPE)
440 pp_c_identifier (pp, flag_isoc99 ? "_Complex" : "__complex__");
441 else if (code == VECTOR_TYPE)
442 pp_c_identifier (pp, "__vector__");
446 pp_simple_type_specifier (pp, t);
451 /* parameter-type-list:
456 parameter-declaration
457 parameter-list , parameter-declaration
459 parameter-declaration:
460 declaration-specifiers declarator
461 declaration-specifiers abstract-declarator(opt) */
464 pp_c_parameter_type_list (c_pretty_printer *pp, tree t)
466 bool want_parm_decl = DECL_P (t) && !(pp->flags & pp_c_flag_abstract);
467 tree parms = want_parm_decl ? DECL_ARGUMENTS (t) : TYPE_ARG_TYPES (t);
468 pp_c_left_paren (pp);
469 if (parms == void_list_node)
470 pp_c_identifier (pp, "void");
474 for ( ; parms && parms != void_list_node; parms = TREE_CHAIN (parms))
477 pp_separate_with (pp, ',');
479 pp_declaration_specifiers
480 (pp, want_parm_decl ? parms : TREE_VALUE (parms));
482 pp_declarator (pp, parms);
484 pp_abstract_declarator (pp, TREE_VALUE (parms));
487 pp_c_right_paren (pp);
490 /* abstract-declarator:
492 pointer(opt) direct-abstract-declarator */
495 pp_c_abstract_declarator (c_pretty_printer *pp, tree t)
497 if (TREE_CODE (t) == POINTER_TYPE)
499 if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE
500 || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
501 pp_c_right_paren (pp);
505 pp_direct_abstract_declarator (pp, t);
508 /* direct-abstract-declarator:
509 ( abstract-declarator )
510 direct-abstract-declarator(opt) [ assignment-expression(opt) ]
511 direct-abstract-declarator(opt) [ * ]
512 direct-abstract-declarator(opt) ( parameter-type-list(opt) ) */
515 pp_c_direct_abstract_declarator (c_pretty_printer *pp, tree t)
517 switch (TREE_CODE (t))
520 pp_abstract_declarator (pp, t);
524 pp_c_parameter_type_list (pp, t);
525 pp_direct_abstract_declarator (pp, TREE_TYPE (t));
529 pp_c_left_bracket (pp);
530 if (TYPE_DOMAIN (t) && TYPE_MAX_VALUE (TYPE_DOMAIN (t)))
532 tree maxval = TYPE_MAX_VALUE (TYPE_DOMAIN (t));
533 tree type = TREE_TYPE (maxval);
535 if (host_integerp (maxval, 0))
536 pp_wide_integer (pp, tree_low_cst (maxval, 0) + 1);
538 pp_expression (pp, fold_build2 (PLUS_EXPR, type, maxval,
539 build_int_cst (type, 1)));
541 pp_c_right_bracket (pp);
542 pp_direct_abstract_declarator (pp, TREE_TYPE (t));
545 case IDENTIFIER_NODE:
550 case FIXED_POINT_TYPE:
560 pp_unsupported_tree (pp, t);
566 specifier-qualifier-list abstract-declarator(opt) */
569 pp_c_type_id (c_pretty_printer *pp, tree t)
571 pp_c_specifier_qualifier_list (pp, t);
572 pp_abstract_declarator (pp, t);
575 /* storage-class-specifier:
583 pp_c_storage_class_specifier (c_pretty_printer *pp, tree t)
585 if (TREE_CODE (t) == TYPE_DECL)
586 pp_c_identifier (pp, "typedef");
589 if (DECL_REGISTER (t))
590 pp_c_identifier (pp, "register");
591 else if (TREE_STATIC (t) && TREE_CODE (t) == VAR_DECL)
592 pp_c_identifier (pp, "static");
596 /* function-specifier:
600 pp_c_function_specifier (c_pretty_printer *pp, tree t)
602 if (TREE_CODE (t) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (t))
603 pp_c_identifier (pp, "inline");
606 /* declaration-specifiers:
607 storage-class-specifier declaration-specifiers(opt)
608 type-specifier declaration-specifiers(opt)
609 type-qualifier declaration-specifiers(opt)
610 function-specifier declaration-specifiers(opt) */
613 pp_c_declaration_specifiers (c_pretty_printer *pp, tree t)
615 pp_storage_class_specifier (pp, t);
616 pp_function_specifier (pp, t);
617 pp_c_specifier_qualifier_list (pp, DECL_P (t) ? TREE_TYPE (t) : t);
623 direct-declarator [ type-qualifier-list(opt) assignment-expression(opt) ]
624 direct-declarator [ static type-qualifier-list(opt) assignment-expression(opt)]
625 direct-declarator [ type-qualifier-list static assignment-expression ]
626 direct-declarator [ type-qualifier-list * ]
627 direct-declarator ( parameter-type-list )
628 direct-declarator ( identifier-list(opt) ) */
631 pp_c_direct_declarator (c_pretty_printer *pp, tree t)
633 switch (TREE_CODE (t))
640 pp_c_space_for_pointer_operator (pp, TREE_TYPE (t));
641 pp_c_tree_decl_identifier (pp, t);
646 pp_abstract_declarator (pp, TREE_TYPE (t));
650 pp_parameter_list (pp, t);
651 pp_abstract_declarator (pp, TREE_TYPE (t));
655 pp_c_space_for_pointer_operator (pp, TREE_TYPE (TREE_TYPE (t)));
656 pp_c_tree_decl_identifier (pp, t);
657 if (pp_c_base (pp)->flags & pp_c_flag_abstract)
658 pp_abstract_declarator (pp, TREE_TYPE (t));
661 pp_parameter_list (pp, t);
662 pp_abstract_declarator (pp, TREE_TYPE (TREE_TYPE (t)));
668 case FIXED_POINT_TYPE:
675 pp_unsupported_tree (pp, t);
682 pointer(opt) direct-declarator */
685 pp_c_declarator (c_pretty_printer *pp, tree t)
687 switch (TREE_CODE (t))
691 case FIXED_POINT_TYPE:
704 pp_direct_declarator (pp, t);
709 pp_unsupported_tree (pp, t);
715 declaration-specifiers init-declarator-list(opt) ; */
718 pp_c_declaration (c_pretty_printer *pp, tree t)
720 pp_declaration_specifiers (pp, t);
721 pp_c_init_declarator (pp, t);
724 /* Pretty-print ATTRIBUTES using GNU C extension syntax. */
727 pp_c_attributes (c_pretty_printer *pp, tree attributes)
729 if (attributes == NULL_TREE)
732 pp_c_identifier (pp, "__attribute__");
733 pp_c_left_paren (pp);
734 pp_c_left_paren (pp);
735 for (; attributes != NULL_TREE; attributes = TREE_CHAIN (attributes))
737 pp_tree_identifier (pp, TREE_PURPOSE (attributes));
738 if (TREE_VALUE (attributes))
739 pp_c_call_argument_list (pp, TREE_VALUE (attributes));
741 if (TREE_CHAIN (attributes))
742 pp_separate_with (pp, ',');
744 pp_c_right_paren (pp);
745 pp_c_right_paren (pp);
748 /* function-definition:
749 declaration-specifiers declarator compound-statement */
752 pp_c_function_definition (c_pretty_printer *pp, tree t)
754 pp_declaration_specifiers (pp, t);
755 pp_declarator (pp, t);
756 pp_needs_newline (pp) = true;
757 pp_statement (pp, DECL_SAVED_TREE (t));
765 /* Print out a c-char. This is called solely for characters which are
766 in the *target* execution character set. We ought to convert them
767 back to the *host* execution character set before printing, but we
768 have no way to do this at present. A decent compromise is to print
769 all characters as if they were in the host execution character set,
770 and not attempt to recover any named escape characters, but render
771 all unprintables as octal escapes. If the host and target character
772 sets are the same, this produces relatively readable output. If they
773 are not the same, strings may appear as gibberish, but that's okay
774 (in fact, it may well be what the reader wants, e.g. if they are looking
775 to see if conversion to the target character set happened correctly).
777 A special case: we need to prefix \, ", and ' with backslashes. It is
778 correct to do so for the *host*'s \, ", and ', because the rest of the
779 file appears in the host character set. */
782 pp_c_char (c_pretty_printer *pp, int c)
788 case '\\': pp_string (pp, "\\\\"); break;
789 case '\'': pp_string (pp, "\\\'"); break;
790 case '\"': pp_string (pp, "\\\""); break;
791 default: pp_character (pp, c);
795 pp_scalar (pp, "\\%03o", (unsigned) c);
798 /* Print out a STRING literal. */
801 pp_c_string_literal (c_pretty_printer *pp, tree s)
803 const char *p = TREE_STRING_POINTER (s);
804 int n = TREE_STRING_LENGTH (s) - 1;
807 for (i = 0; i < n; ++i)
808 pp_c_char (pp, p[i]);
812 /* Pretty-print an INTEGER literal. */
815 pp_c_integer_constant (c_pretty_printer *pp, tree i)
817 tree type = TREE_TYPE (i);
819 if (TREE_INT_CST_HIGH (i) == 0)
820 pp_wide_integer (pp, TREE_INT_CST_LOW (i));
823 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (i);
824 HOST_WIDE_INT high = TREE_INT_CST_HIGH (i);
825 if (tree_int_cst_sgn (i) < 0)
827 pp_character (pp, '-');
831 sprintf (pp_buffer (pp)->digit_buffer,
832 HOST_WIDE_INT_PRINT_DOUBLE_HEX, high, low);
833 pp_string (pp, pp_buffer (pp)->digit_buffer);
835 if (TYPE_UNSIGNED (type))
836 pp_character (pp, 'u');
837 if (type == long_integer_type_node || type == long_unsigned_type_node)
838 pp_character (pp, 'l');
839 else if (type == long_long_integer_type_node
840 || type == long_long_unsigned_type_node)
841 pp_string (pp, "ll");
844 /* Print out a CHARACTER literal. */
847 pp_c_character_constant (c_pretty_printer *pp, tree c)
849 tree type = TREE_TYPE (c);
850 if (type == wchar_type_node)
851 pp_character (pp, 'L');
853 if (host_integerp (c, TYPE_UNSIGNED (type)))
854 pp_c_char (pp, tree_low_cst (c, TYPE_UNSIGNED (type)));
856 pp_scalar (pp, "\\x%x", (unsigned) TREE_INT_CST_LOW (c));
860 /* Print out a BOOLEAN literal. */
863 pp_c_bool_constant (c_pretty_printer *pp, tree b)
865 if (b == boolean_false_node)
867 if (c_dialect_cxx ())
868 pp_c_identifier (pp, "false");
869 else if (flag_isoc99)
870 pp_c_identifier (pp, "_False");
872 pp_unsupported_tree (pp, b);
874 else if (b == boolean_true_node)
876 if (c_dialect_cxx ())
877 pp_c_identifier (pp, "true");
878 else if (flag_isoc99)
879 pp_c_identifier (pp, "_True");
881 pp_unsupported_tree (pp, b);
883 else if (TREE_CODE (b) == INTEGER_CST)
884 pp_c_integer_constant (pp, b);
886 pp_unsupported_tree (pp, b);
889 /* Attempt to print out an ENUMERATOR. Return true on success. Else return
890 false; that means the value was obtained by a cast, in which case
891 print out the type-id part of the cast-expression -- the casted value
892 is then printed by pp_c_integer_literal. */
895 pp_c_enumeration_constant (c_pretty_printer *pp, tree e)
897 bool value_is_named = true;
898 tree type = TREE_TYPE (e);
901 /* Find the name of this constant. */
902 for (value = TYPE_VALUES (type);
903 value != NULL_TREE && !tree_int_cst_equal (TREE_VALUE (value), e);
904 value = TREE_CHAIN (value))
907 if (value != NULL_TREE)
908 pp_id_expression (pp, TREE_PURPOSE (value));
911 /* Value must have been cast. */
912 pp_c_type_cast (pp, type);
913 value_is_named = false;
916 return value_is_named;
919 /* Print out a REAL value as a decimal-floating-constant. */
922 pp_c_floating_constant (c_pretty_printer *pp, tree r)
924 real_to_decimal (pp_buffer (pp)->digit_buffer, &TREE_REAL_CST (r),
925 sizeof (pp_buffer (pp)->digit_buffer), 0, 1);
926 pp_string (pp, pp_buffer(pp)->digit_buffer);
927 if (TREE_TYPE (r) == float_type_node)
928 pp_character (pp, 'f');
929 else if (TREE_TYPE (r) == long_double_type_node)
930 pp_character (pp, 'l');
931 else if (TREE_TYPE (r) == dfloat128_type_node)
932 pp_string (pp, "dl");
933 else if (TREE_TYPE (r) == dfloat64_type_node)
934 pp_string (pp, "dd");
935 else if (TREE_TYPE (r) == dfloat32_type_node)
936 pp_string (pp, "df");
939 /* Print out a FIXED value as a decimal-floating-constant. */
942 pp_c_fixed_constant (c_pretty_printer *pp, tree r)
944 fixed_to_decimal (pp_buffer (pp)->digit_buffer, &TREE_FIXED_CST (r),
945 sizeof (pp_buffer (pp)->digit_buffer));
946 pp_string (pp, pp_buffer(pp)->digit_buffer);
949 /* Pretty-print a compound literal expression. GNU extensions include
953 pp_c_compound_literal (c_pretty_printer *pp, tree e)
955 tree type = TREE_TYPE (e);
956 pp_c_type_cast (pp, type);
958 switch (TREE_CODE (type))
965 pp_c_brace_enclosed_initializer_list (pp, e);
969 pp_unsupported_tree (pp, e);
979 character-constant */
982 pp_c_constant (c_pretty_printer *pp, tree e)
984 const enum tree_code code = TREE_CODE (e);
990 tree type = TREE_TYPE (e);
991 if (type == boolean_type_node)
992 pp_c_bool_constant (pp, e);
993 else if (type == char_type_node)
994 pp_c_character_constant (pp, e);
995 else if (TREE_CODE (type) == ENUMERAL_TYPE
996 && pp_c_enumeration_constant (pp, e))
999 pp_c_integer_constant (pp, e);
1004 pp_c_floating_constant (pp, e);
1008 pp_c_fixed_constant (pp, e);
1012 pp_c_string_literal (pp, e);
1016 pp_unsupported_tree (pp, e);
1021 /* Pretty-print an IDENTIFIER_NODE, preceded by whitespace is necessary. */
1024 pp_c_identifier (c_pretty_printer *pp, const char *id)
1026 pp_c_maybe_whitespace (pp);
1027 pp_identifier (pp, id);
1028 pp_base (pp)->padding = pp_before;
1031 /* Pretty-print a C primary-expression.
1039 pp_c_primary_expression (c_pretty_printer *pp, tree e)
1041 switch (TREE_CODE (e))
1049 pp_c_tree_decl_identifier (pp, e);
1052 case IDENTIFIER_NODE:
1053 pp_c_tree_identifier (pp, e);
1057 pp_c_identifier (pp, "<erroneous-expression>");
1061 pp_c_identifier (pp, "<return-value>");
1068 pp_c_constant (pp, e);
1072 pp_c_identifier (pp, "__builtin_memcpy");
1073 pp_c_left_paren (pp);
1075 pp_primary_expression (pp, TREE_OPERAND (e, 0));
1076 pp_separate_with (pp, ',');
1078 pp_initializer (pp, TREE_OPERAND (e, 1));
1079 if (TREE_OPERAND (e, 2))
1081 pp_separate_with (pp, ',');
1082 pp_c_expression (pp, TREE_OPERAND (e, 2));
1084 pp_c_right_paren (pp);
1088 /* FIXME: Make sure we won't get into an infinie loop. */
1089 pp_c_left_paren (pp);
1090 pp_expression (pp, e);
1091 pp_c_right_paren (pp);
1096 /* Print out a C initializer -- also support C compound-literals.
1098 assignment-expression:
1099 { initializer-list }
1100 { initializer-list , } */
1103 pp_c_initializer (c_pretty_printer *pp, tree e)
1105 if (TREE_CODE (e) == CONSTRUCTOR)
1106 pp_c_brace_enclosed_initializer_list (pp, e);
1108 pp_expression (pp, e);
1113 declarator = initializer */
1116 pp_c_init_declarator (c_pretty_printer *pp, tree t)
1118 pp_declarator (pp, t);
1119 /* We don't want to output function definitions here. There are handled
1120 elsewhere (and the syntactic form is bogus anyway). */
1121 if (TREE_CODE (t) != FUNCTION_DECL && DECL_INITIAL (t))
1123 tree init = DECL_INITIAL (t);
1124 /* This C++ bit is handled here because it is easier to do so.
1125 In templates, the C++ parser builds a TREE_LIST for a
1126 direct-initialization; the TREE_PURPOSE is the variable to
1127 initialize and the TREE_VALUE is the initializer. */
1128 if (TREE_CODE (init) == TREE_LIST)
1130 pp_c_left_paren (pp);
1131 pp_expression (pp, TREE_VALUE (init));
1132 pp_right_paren (pp);
1139 pp_c_initializer (pp, init);
1144 /* initializer-list:
1145 designation(opt) initializer
1146 initializer-list , designation(opt) initializer
1153 designator-list designator
1156 [ constant-expression ]
1160 pp_c_initializer_list (c_pretty_printer *pp, tree e)
1162 tree type = TREE_TYPE (e);
1163 const enum tree_code code = TREE_CODE (type);
1171 tree init = TREE_OPERAND (e, 0);
1172 for (; init != NULL_TREE; init = TREE_CHAIN (init))
1174 if (code == RECORD_TYPE || code == UNION_TYPE)
1177 pp_c_primary_expression (pp, TREE_PURPOSE (init));
1181 pp_c_left_bracket (pp);
1182 if (TREE_PURPOSE (init))
1183 pp_c_constant (pp, TREE_PURPOSE (init));
1184 pp_c_right_bracket (pp);
1186 pp_c_whitespace (pp);
1188 pp_c_whitespace (pp);
1189 pp_initializer (pp, TREE_VALUE (init));
1190 if (TREE_CHAIN (init))
1191 pp_separate_with (pp, ',');
1197 if (TREE_CODE (e) == VECTOR_CST)
1198 pp_c_expression_list (pp, TREE_VECTOR_CST_ELTS (e));
1199 else if (TREE_CODE (e) == CONSTRUCTOR)
1200 pp_c_constructor_elts (pp, CONSTRUCTOR_ELTS (e));
1206 if (TREE_CODE (e) == CONSTRUCTOR)
1207 pp_c_constructor_elts (pp, CONSTRUCTOR_ELTS (e));
1208 else if (TREE_CODE (e) == COMPLEX_CST || TREE_CODE (e) == COMPLEX_EXPR)
1210 const bool cst = TREE_CODE (e) == COMPLEX_CST;
1211 pp_expression (pp, cst ? TREE_REALPART (e) : TREE_OPERAND (e, 0));
1212 pp_separate_with (pp, ',');
1213 pp_expression (pp, cst ? TREE_IMAGPART (e) : TREE_OPERAND (e, 1));
1223 pp_unsupported_tree (pp, type);
1226 /* Pretty-print a brace-enclosed initializer-list. */
1229 pp_c_brace_enclosed_initializer_list (c_pretty_printer *pp, tree l)
1231 pp_c_left_brace (pp);
1232 pp_c_initializer_list (pp, l);
1233 pp_c_right_brace (pp);
1237 /* This is a convenient function, used to bridge gap between C and C++
1244 pp_c_id_expression (c_pretty_printer *pp, tree t)
1246 switch (TREE_CODE (t))
1255 pp_c_tree_decl_identifier (pp, t);
1258 case IDENTIFIER_NODE:
1259 pp_c_tree_identifier (pp, t);
1263 pp_unsupported_tree (pp, t);
1268 /* postfix-expression:
1270 postfix-expression [ expression ]
1271 postfix-expression ( argument-expression-list(opt) )
1272 postfix-expression . identifier
1273 postfix-expression -> identifier
1274 postfix-expression ++
1275 postfix-expression --
1276 ( type-name ) { initializer-list }
1277 ( type-name ) { initializer-list , } */
1280 pp_c_postfix_expression (c_pretty_printer *pp, tree e)
1282 enum tree_code code = TREE_CODE (e);
1285 case POSTINCREMENT_EXPR:
1286 case POSTDECREMENT_EXPR:
1287 pp_postfix_expression (pp, TREE_OPERAND (e, 0));
1288 pp_identifier (pp, code == POSTINCREMENT_EXPR ? "++" : "--");
1292 pp_postfix_expression (pp, TREE_OPERAND (e, 0));
1293 pp_c_left_bracket (pp);
1294 pp_expression (pp, TREE_OPERAND (e, 1));
1295 pp_c_right_bracket (pp);
1300 call_expr_arg_iterator iter;
1302 pp_postfix_expression (pp, CALL_EXPR_FN (e));
1303 pp_c_left_paren (pp);
1304 FOR_EACH_CALL_EXPR_ARG (arg, iter, e)
1306 pp_expression (pp, arg);
1307 if (more_call_expr_args_p (&iter))
1308 pp_separate_with (pp, ',');
1310 pp_c_right_paren (pp);
1314 case UNORDERED_EXPR:
1315 pp_c_identifier (pp, flag_isoc99
1317 : "__builtin_isunordered");
1321 pp_c_identifier (pp, flag_isoc99
1323 : "!__builtin_isunordered");
1327 pp_c_identifier (pp, flag_isoc99
1329 : "!__builtin_isgreaterequal");
1333 pp_c_identifier (pp, flag_isoc99
1335 : "!__builtin_isgreater");
1339 pp_c_identifier (pp, flag_isoc99
1341 : "!__builtin_islessequal");
1345 pp_c_identifier (pp, flag_isoc99
1347 : "!__builtin_isless");
1351 pp_c_identifier (pp, flag_isoc99
1353 : "!__builtin_islessgreater");
1357 pp_c_identifier (pp, flag_isoc99
1359 : "__builtin_islessgreater");
1363 pp_c_left_paren (pp);
1364 pp_expression (pp, TREE_OPERAND (e, 0));
1365 pp_separate_with (pp, ',');
1366 pp_expression (pp, TREE_OPERAND (e, 1));
1367 pp_c_right_paren (pp);
1371 pp_c_identifier (pp, "__builtin_abs");
1372 pp_c_left_paren (pp);
1373 pp_expression (pp, TREE_OPERAND (e, 0));
1374 pp_c_right_paren (pp);
1379 tree object = TREE_OPERAND (e, 0);
1380 if (TREE_CODE (object) == INDIRECT_REF)
1382 pp_postfix_expression (pp, TREE_OPERAND (object, 0));
1387 pp_postfix_expression (pp, object);
1390 pp_expression (pp, TREE_OPERAND (e, 1));
1397 pp_c_compound_literal (pp, e);
1400 case COMPOUND_LITERAL_EXPR:
1401 e = DECL_INITIAL (COMPOUND_LITERAL_EXPR_DECL (e));
1404 pp_initializer (pp, e);
1408 pp_c_identifier (pp, "__builtin_va_arg");
1409 pp_c_left_paren (pp);
1410 pp_assignment_expression (pp, TREE_OPERAND (e, 0));
1411 pp_separate_with (pp, ',');
1412 pp_type_id (pp, TREE_TYPE (e));
1413 pp_c_right_paren (pp);
1417 if (TREE_CODE (TREE_OPERAND (e, 0)) == FUNCTION_DECL)
1419 pp_c_id_expression (pp, TREE_OPERAND (e, 0));
1422 /* else fall through. */
1425 pp_primary_expression (pp, e);
1430 /* Print out an expression-list; E is expected to be a TREE_LIST. */
1433 pp_c_expression_list (c_pretty_printer *pp, tree e)
1435 for (; e != NULL_TREE; e = TREE_CHAIN (e))
1437 pp_expression (pp, TREE_VALUE (e));
1439 pp_separate_with (pp, ',');
1443 /* Print out V, which contains the elements of a constructor. */
1446 pp_c_constructor_elts (c_pretty_printer *pp, VEC(constructor_elt,gc) *v)
1448 unsigned HOST_WIDE_INT ix;
1451 FOR_EACH_CONSTRUCTOR_VALUE (v, ix, value)
1453 pp_expression (pp, value);
1454 if (ix != VEC_length (constructor_elt, v) - 1)
1455 pp_separate_with (pp, ',');
1459 /* Print out an expression-list in parens, as if it were the argument
1460 list to a function. */
1463 pp_c_call_argument_list (c_pretty_printer *pp, tree t)
1465 pp_c_left_paren (pp);
1466 if (t && TREE_CODE (t) == TREE_LIST)
1467 pp_c_expression_list (pp, t);
1468 pp_c_right_paren (pp);
1471 /* unary-expression:
1475 unary-operator cast-expression
1476 sizeof unary-expression
1479 unary-operator: one of
1484 __alignof__ unary-expression
1485 __alignof__ ( type-id )
1486 __real__ unary-expression
1487 __imag__ unary-expression */
1490 pp_c_unary_expression (c_pretty_printer *pp, tree e)
1492 enum tree_code code = TREE_CODE (e);
1495 case PREINCREMENT_EXPR:
1496 case PREDECREMENT_EXPR:
1497 pp_identifier (pp, code == PREINCREMENT_EXPR ? "++" : "--");
1498 pp_c_unary_expression (pp, TREE_OPERAND (e, 0));
1505 case TRUTH_NOT_EXPR:
1507 /* String literal are used by address. */
1508 if (code == ADDR_EXPR && TREE_CODE (TREE_OPERAND (e, 0)) != STRING_CST)
1510 else if (code == INDIRECT_REF)
1512 else if (code == NEGATE_EXPR)
1514 else if (code == BIT_NOT_EXPR || code == CONJ_EXPR)
1516 else if (code == TRUTH_NOT_EXPR)
1517 pp_exclamation (pp);
1518 pp_c_cast_expression (pp, TREE_OPERAND (e, 0));
1523 pp_c_identifier (pp, code == REALPART_EXPR ? "__real__" : "__imag__");
1524 pp_c_whitespace (pp);
1525 pp_unary_expression (pp, TREE_OPERAND (e, 0));
1529 pp_postfix_expression (pp, e);
1536 ( type-name ) cast-expression */
1539 pp_c_cast_expression (c_pretty_printer *pp, tree e)
1541 switch (TREE_CODE (e))
1544 case FIX_TRUNC_EXPR:
1547 pp_c_type_cast (pp, TREE_TYPE (e));
1548 pp_c_cast_expression (pp, TREE_OPERAND (e, 0));
1552 pp_unary_expression (pp, e);
1556 /* multiplicative-expression:
1558 multiplicative-expression * cast-expression
1559 multiplicative-expression / cast-expression
1560 multiplicative-expression % cast-expression */
1563 pp_c_multiplicative_expression (c_pretty_printer *pp, tree e)
1565 enum tree_code code = TREE_CODE (e);
1569 case TRUNC_DIV_EXPR:
1570 case TRUNC_MOD_EXPR:
1571 pp_multiplicative_expression (pp, TREE_OPERAND (e, 0));
1572 pp_c_whitespace (pp);
1573 if (code == MULT_EXPR)
1575 else if (code == TRUNC_DIV_EXPR)
1579 pp_c_whitespace (pp);
1580 pp_c_cast_expression (pp, TREE_OPERAND (e, 1));
1584 pp_c_cast_expression (pp, e);
1589 /* additive-expression:
1590 multiplicative-expression
1591 additive-expression + multiplicative-expression
1592 additive-expression - multiplicative-expression */
1595 pp_c_additive_expression (c_pretty_printer *pp, tree e)
1597 enum tree_code code = TREE_CODE (e);
1600 case POINTER_PLUS_EXPR:
1603 pp_c_additive_expression (pp, TREE_OPERAND (e, 0));
1604 pp_c_whitespace (pp);
1605 if (code == PLUS_EXPR || code == POINTER_PLUS_EXPR)
1609 pp_c_whitespace (pp);
1610 pp_multiplicative_expression (pp, TREE_OPERAND (e, 1));
1614 pp_multiplicative_expression (pp, e);
1619 /* additive-expression:
1621 shift-expression << additive-expression
1622 shift-expression >> additive-expression */
1625 pp_c_shift_expression (c_pretty_printer *pp, tree e)
1627 enum tree_code code = TREE_CODE (e);
1632 pp_c_shift_expression (pp, TREE_OPERAND (e, 0));
1633 pp_c_whitespace (pp);
1634 pp_identifier (pp, code == LSHIFT_EXPR ? "<<" : ">>");
1635 pp_c_whitespace (pp);
1636 pp_c_additive_expression (pp, TREE_OPERAND (e, 1));
1640 pp_c_additive_expression (pp, e);
1644 /* relational-expression:
1646 relational-expression < shift-expression
1647 relational-expression > shift-expression
1648 relational-expression <= shift-expression
1649 relational-expression >= shift-expression */
1652 pp_c_relational_expression (c_pretty_printer *pp, tree e)
1654 enum tree_code code = TREE_CODE (e);
1661 pp_c_relational_expression (pp, TREE_OPERAND (e, 0));
1662 pp_c_whitespace (pp);
1663 if (code == LT_EXPR)
1665 else if (code == GT_EXPR)
1667 else if (code == LE_EXPR)
1668 pp_identifier (pp, "<=");
1669 else if (code == GE_EXPR)
1670 pp_identifier (pp, ">=");
1671 pp_c_whitespace (pp);
1672 pp_c_shift_expression (pp, TREE_OPERAND (e, 1));
1676 pp_c_shift_expression (pp, e);
1681 /* equality-expression:
1682 relational-expression
1683 equality-expression == relational-expression
1684 equality-equality != relational-expression */
1687 pp_c_equality_expression (c_pretty_printer *pp, tree e)
1689 enum tree_code code = TREE_CODE (e);
1694 pp_c_equality_expression (pp, TREE_OPERAND (e, 0));
1695 pp_c_whitespace (pp);
1696 pp_identifier (pp, code == EQ_EXPR ? "==" : "!=");
1697 pp_c_whitespace (pp);
1698 pp_c_relational_expression (pp, TREE_OPERAND (e, 1));
1702 pp_c_relational_expression (pp, e);
1709 AND-expression & equality-equality */
1712 pp_c_and_expression (c_pretty_printer *pp, tree e)
1714 if (TREE_CODE (e) == BIT_AND_EXPR)
1716 pp_c_and_expression (pp, TREE_OPERAND (e, 0));
1717 pp_c_whitespace (pp);
1719 pp_c_whitespace (pp);
1720 pp_c_equality_expression (pp, TREE_OPERAND (e, 1));
1723 pp_c_equality_expression (pp, e);
1726 /* exclusive-OR-expression:
1728 exclusive-OR-expression ^ AND-expression */
1731 pp_c_exclusive_or_expression (c_pretty_printer *pp, tree e)
1733 if (TREE_CODE (e) == BIT_XOR_EXPR)
1735 pp_c_exclusive_or_expression (pp, TREE_OPERAND (e, 0));
1736 pp_c_maybe_whitespace (pp);
1738 pp_c_whitespace (pp);
1739 pp_c_and_expression (pp, TREE_OPERAND (e, 1));
1742 pp_c_and_expression (pp, e);
1745 /* inclusive-OR-expression:
1746 exclusive-OR-expression
1747 inclusive-OR-expression | exclusive-OR-expression */
1750 pp_c_inclusive_or_expression (c_pretty_printer *pp, tree e)
1752 if (TREE_CODE (e) == BIT_IOR_EXPR)
1754 pp_c_exclusive_or_expression (pp, TREE_OPERAND (e, 0));
1755 pp_c_whitespace (pp);
1757 pp_c_whitespace (pp);
1758 pp_c_exclusive_or_expression (pp, TREE_OPERAND (e, 1));
1761 pp_c_exclusive_or_expression (pp, e);
1764 /* logical-AND-expression:
1765 inclusive-OR-expression
1766 logical-AND-expression && inclusive-OR-expression */
1769 pp_c_logical_and_expression (c_pretty_printer *pp, tree e)
1771 if (TREE_CODE (e) == TRUTH_ANDIF_EXPR)
1773 pp_c_logical_and_expression (pp, TREE_OPERAND (e, 0));
1774 pp_c_whitespace (pp);
1775 pp_identifier (pp, "&&");
1776 pp_c_whitespace (pp);
1777 pp_c_inclusive_or_expression (pp, TREE_OPERAND (e, 1));
1780 pp_c_inclusive_or_expression (pp, e);
1783 /* logical-OR-expression:
1784 logical-AND-expression
1785 logical-OR-expression || logical-AND-expression */
1788 pp_c_logical_or_expression (c_pretty_printer *pp, tree e)
1790 if (TREE_CODE (e) == TRUTH_ORIF_EXPR)
1792 pp_c_logical_or_expression (pp, TREE_OPERAND (e, 0));
1793 pp_c_whitespace (pp);
1794 pp_identifier (pp, "||");
1795 pp_c_whitespace (pp);
1796 pp_c_logical_and_expression (pp, TREE_OPERAND (e, 1));
1799 pp_c_logical_and_expression (pp, e);
1802 /* conditional-expression:
1803 logical-OR-expression
1804 logical-OR-expression ? expression : conditional-expression */
1807 pp_c_conditional_expression (c_pretty_printer *pp, tree e)
1809 if (TREE_CODE (e) == COND_EXPR)
1811 pp_c_logical_or_expression (pp, TREE_OPERAND (e, 0));
1812 pp_c_whitespace (pp);
1814 pp_c_whitespace (pp);
1815 pp_expression (pp, TREE_OPERAND (e, 1));
1816 pp_c_whitespace (pp);
1818 pp_c_whitespace (pp);
1819 pp_c_conditional_expression (pp, TREE_OPERAND (e, 2));
1822 pp_c_logical_or_expression (pp, e);
1826 /* assignment-expression:
1827 conditional-expression
1828 unary-expression assignment-operator assignment-expression
1830 assignment-expression: one of
1831 = *= /= %= += -= >>= <<= &= ^= |= */
1834 pp_c_assignment_expression (c_pretty_printer *pp, tree e)
1836 if (TREE_CODE (e) == MODIFY_EXPR
1837 || TREE_CODE (e) == GIMPLE_MODIFY_STMT
1838 || TREE_CODE (e) == INIT_EXPR)
1840 pp_c_unary_expression (pp, GENERIC_TREE_OPERAND (e, 0));
1841 pp_c_whitespace (pp);
1844 pp_c_expression (pp, GENERIC_TREE_OPERAND (e, 1));
1847 pp_c_conditional_expression (pp, e);
1851 assignment-expression
1852 expression , assignment-expression
1854 Implementation note: instead of going through the usual recursion
1855 chain, I take the liberty of dispatching nodes to the appropriate
1856 functions. This makes some redundancy, but it worths it. That also
1857 prevents a possible infinite recursion between pp_c_primary_expression ()
1858 and pp_c_expression (). */
1861 pp_c_expression (c_pretty_printer *pp, tree e)
1863 switch (TREE_CODE (e))
1866 pp_c_integer_constant (pp, e);
1870 pp_c_floating_constant (pp, e);
1874 pp_c_fixed_constant (pp, e);
1878 pp_c_string_literal (pp, e);
1881 case IDENTIFIER_NODE:
1890 pp_primary_expression (pp, e);
1893 case POSTINCREMENT_EXPR:
1894 case POSTDECREMENT_EXPR:
1902 case UNORDERED_EXPR:
1911 case COMPOUND_LITERAL_EXPR:
1913 pp_postfix_expression (pp, e);
1921 case TRUTH_NOT_EXPR:
1922 case PREINCREMENT_EXPR:
1923 case PREDECREMENT_EXPR:
1926 pp_c_unary_expression (pp, e);
1930 case FIX_TRUNC_EXPR:
1933 pp_c_cast_expression (pp, e);
1937 case TRUNC_MOD_EXPR:
1938 case TRUNC_DIV_EXPR:
1939 pp_multiplicative_expression (pp, e);
1944 pp_c_shift_expression (pp, e);
1951 pp_c_relational_expression (pp, e);
1955 pp_c_and_expression (pp, e);
1959 pp_c_exclusive_or_expression (pp, e);
1963 pp_c_inclusive_or_expression (pp, e);
1966 case TRUTH_ANDIF_EXPR:
1967 pp_c_logical_and_expression (pp, e);
1970 case TRUTH_ORIF_EXPR:
1971 pp_c_logical_or_expression (pp, e);
1976 pp_c_equality_expression (pp, e);
1980 pp_conditional_expression (pp, e);
1983 case POINTER_PLUS_EXPR:
1986 pp_c_additive_expression (pp, e);
1990 case GIMPLE_MODIFY_STMT:
1992 pp_assignment_expression (pp, e);
1996 pp_c_left_paren (pp);
1997 pp_expression (pp, TREE_OPERAND (e, 0));
1998 pp_separate_with (pp, ',');
1999 pp_assignment_expression (pp, TREE_OPERAND (e, 1));
2000 pp_c_right_paren (pp);
2003 case NON_LVALUE_EXPR:
2005 pp_expression (pp, TREE_OPERAND (e, 0));
2009 pp_postfix_expression (pp, TREE_OPERAND (e, 1));
2013 pp_unsupported_tree (pp, e);
2023 pp_c_statement (c_pretty_printer *pp, tree stmt)
2028 if (pp_needs_newline (pp))
2029 pp_newline_and_indent (pp, 0);
2031 dump_generic_node (pp_base (pp), stmt, pp_indentation (pp), 0, true);
2035 /* Initialize the PRETTY-PRINTER for handling C codes. */
2038 pp_c_pretty_printer_init (c_pretty_printer *pp)
2040 pp->offset_list = 0;
2042 pp->declaration = pp_c_declaration;
2043 pp->declaration_specifiers = pp_c_declaration_specifiers;
2044 pp->declarator = pp_c_declarator;
2045 pp->direct_declarator = pp_c_direct_declarator;
2046 pp->type_specifier_seq = pp_c_specifier_qualifier_list;
2047 pp->abstract_declarator = pp_c_abstract_declarator;
2048 pp->direct_abstract_declarator = pp_c_direct_abstract_declarator;
2049 pp->ptr_operator = pp_c_pointer;
2050 pp->parameter_list = pp_c_parameter_type_list;
2051 pp->type_id = pp_c_type_id;
2052 pp->simple_type_specifier = pp_c_type_specifier;
2053 pp->function_specifier = pp_c_function_specifier;
2054 pp->storage_class_specifier = pp_c_storage_class_specifier;
2056 pp->statement = pp_c_statement;
2058 pp->constant = pp_c_constant;
2059 pp->id_expression = pp_c_id_expression;
2060 pp->primary_expression = pp_c_primary_expression;
2061 pp->postfix_expression = pp_c_postfix_expression;
2062 pp->unary_expression = pp_c_unary_expression;
2063 pp->initializer = pp_c_initializer;
2064 pp->multiplicative_expression = pp_c_multiplicative_expression;
2065 pp->conditional_expression = pp_c_conditional_expression;
2066 pp->assignment_expression = pp_c_assignment_expression;
2067 pp->expression = pp_c_expression;
2071 /* Print the tree T in full, on file FILE. */
2074 print_c_tree (FILE *file, tree t)
2076 static c_pretty_printer pp_rec;
2077 static bool initialized = 0;
2078 c_pretty_printer *pp = &pp_rec;
2083 pp_construct (pp_base (pp), NULL, 0);
2084 pp_c_pretty_printer_init (pp);
2085 pp_needs_newline (pp) = true;
2087 pp_base (pp)->buffer->stream = file;
2089 pp_statement (pp, t);
2095 /* Print the tree T in full, on stderr. */
2098 debug_c_tree (tree t)
2100 print_c_tree (stderr, t);
2101 fputc ('\n', stderr);
2104 /* Output the DECL_NAME of T. If T has no DECL_NAME, output a string made
2105 up of T's memory address. */
2108 pp_c_tree_decl_identifier (c_pretty_printer *pp, tree t)
2112 gcc_assert (DECL_P (t));
2115 name = IDENTIFIER_POINTER (DECL_NAME (t));
2118 static char xname[8];
2119 sprintf (xname, "<U%4x>", ((unsigned)((unsigned long)(t) & 0xffff)));
2123 pp_c_identifier (pp, name);