1 /* Subroutines common to both C and C++ pretty-printers.
2 Copyright (C) 2002, 2003, 2004, 2005 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 2, 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 COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
24 #include "coretypes.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
);
320 t
= c_common_type_for_mode (TYPE_MODE (t
), TYPE_UNSIGNED (t
));
321 pp_c_type_specifier (pp
, t
);
326 pp_id_expression (pp
, t
);
328 pp_c_identifier (pp
, "<typedef-error>");
334 if (code
== UNION_TYPE
)
335 pp_c_identifier (pp
, "union");
336 else if (code
== RECORD_TYPE
)
337 pp_c_identifier (pp
, "struct");
338 else if (code
== ENUMERAL_TYPE
)
339 pp_c_identifier (pp
, "enum");
341 pp_c_identifier (pp
, "<tag-error>");
344 pp_id_expression (pp
, TYPE_NAME (t
));
346 pp_c_identifier (pp
, "<anonymous>");
350 pp_unsupported_tree (pp
, t
);
355 /* specifier-qualifier-list:
356 type-specifier specifier-qualifier-list-opt
357 type-qualifier specifier-qualifier-list-opt
360 Implementation note: Because of the non-linearities in array or
361 function declarations, this routine prints not just the
362 specifier-qualifier-list of such entities or types of such entities,
363 but also the 'pointer' production part of their declarators. The
364 remaining part is done by pp_declarator or pp_c_abstract_declarator. */
367 pp_c_specifier_qualifier_list (c_pretty_printer
*pp
, tree t
)
369 const enum tree_code code
= TREE_CODE (t
);
371 if (TREE_CODE (t
) != POINTER_TYPE
)
372 pp_c_type_qualifier_list (pp
, t
);
378 /* Get the types-specifier of this type. */
379 tree pointee
= strip_pointer_operator (TREE_TYPE (t
));
380 pp_c_specifier_qualifier_list (pp
, pointee
);
381 if (TREE_CODE (pointee
) == ARRAY_TYPE
382 || TREE_CODE (pointee
) == FUNCTION_TYPE
)
384 pp_c_whitespace (pp
);
385 pp_c_left_paren (pp
);
387 else if (!c_dialect_cxx ())
388 pp_c_whitespace (pp
);
389 pp_ptr_operator (pp
, t
);
395 pp_c_specifier_qualifier_list (pp
, TREE_TYPE (t
));
400 pp_c_specifier_qualifier_list (pp
, TREE_TYPE (t
));
401 if (code
== COMPLEX_TYPE
)
402 pp_c_identifier (pp
, flag_isoc99
? "_Complex" : "__complex__");
403 else if (code
== VECTOR_TYPE
)
404 pp_c_identifier (pp
, "__vector__");
408 pp_simple_type_specifier (pp
, t
);
413 /* parameter-type-list:
418 parameter-declaration
419 parameter-list , parameter-declaration
421 parameter-declaration:
422 declaration-specifiers declarator
423 declaration-specifiers abstract-declarator(opt) */
426 pp_c_parameter_type_list (c_pretty_printer
*pp
, tree t
)
428 bool want_parm_decl
= DECL_P (t
) && !(pp
->flags
& pp_c_flag_abstract
);
429 tree parms
= want_parm_decl
? DECL_ARGUMENTS (t
) : TYPE_ARG_TYPES (t
);
430 pp_c_left_paren (pp
);
431 if (parms
== void_list_node
)
432 pp_c_identifier (pp
, "void");
436 for ( ; parms
&& parms
!= void_list_node
; parms
= TREE_CHAIN (parms
))
439 pp_separate_with (pp
, ',');
441 pp_declaration_specifiers
442 (pp
, want_parm_decl
? parms
: TREE_VALUE (parms
));
444 pp_declarator (pp
, parms
);
446 pp_abstract_declarator (pp
, TREE_VALUE (parms
));
449 pp_c_right_paren (pp
);
452 /* abstract-declarator:
454 pointer(opt) direct-abstract-declarator */
457 pp_c_abstract_declarator (c_pretty_printer
*pp
, tree t
)
459 if (TREE_CODE (t
) == POINTER_TYPE
)
461 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
462 || TREE_CODE (TREE_TYPE (t
)) == FUNCTION_TYPE
)
463 pp_c_right_paren (pp
);
467 pp_direct_abstract_declarator (pp
, t
);
470 /* direct-abstract-declarator:
471 ( abstract-declarator )
472 direct-abstract-declarator(opt) [ assignment-expression(opt) ]
473 direct-abstract-declarator(opt) [ * ]
474 direct-abstract-declarator(opt) ( parameter-type-list(opt) ) */
477 pp_c_direct_abstract_declarator (c_pretty_printer
*pp
, tree t
)
479 switch (TREE_CODE (t
))
482 pp_abstract_declarator (pp
, t
);
486 pp_c_parameter_type_list (pp
, t
);
487 pp_direct_abstract_declarator (pp
, TREE_TYPE (t
));
491 pp_c_left_bracket (pp
);
492 if (TYPE_DOMAIN (t
) && TYPE_MAX_VALUE (TYPE_DOMAIN (t
)))
493 pp_expression (pp
, TYPE_MAX_VALUE (TYPE_DOMAIN (t
)));
494 pp_c_right_bracket (pp
);
495 pp_direct_abstract_declarator (pp
, TREE_TYPE (t
));
498 case IDENTIFIER_NODE
:
512 pp_unsupported_tree (pp
, t
);
518 specifier-qualifier-list abstract-declarator(opt) */
521 pp_c_type_id (c_pretty_printer
*pp
, tree t
)
523 pp_c_specifier_qualifier_list (pp
, t
);
524 pp_abstract_declarator (pp
, t
);
527 /* storage-class-specifier:
535 pp_c_storage_class_specifier (c_pretty_printer
*pp
, tree t
)
537 if (TREE_CODE (t
) == TYPE_DECL
)
538 pp_c_identifier (pp
, "typedef");
541 if (DECL_REGISTER (t
))
542 pp_c_identifier (pp
, "register");
543 else if (TREE_STATIC (t
) && TREE_CODE (t
) == VAR_DECL
)
544 pp_c_identifier (pp
, "static");
548 /* function-specifier:
552 pp_c_function_specifier (c_pretty_printer
*pp
, tree t
)
554 if (TREE_CODE (t
) == FUNCTION_DECL
&& DECL_DECLARED_INLINE_P (t
))
555 pp_c_identifier (pp
, "inline");
558 /* declaration-specifiers:
559 storage-class-specifier declaration-specifiers(opt)
560 type-specifier declaration-specifiers(opt)
561 type-qualifier declaration-specifiers(opt)
562 function-specifier declaration-specifiers(opt) */
565 pp_c_declaration_specifiers (c_pretty_printer
*pp
, tree t
)
567 pp_storage_class_specifier (pp
, t
);
568 pp_function_specifier (pp
, t
);
569 pp_c_specifier_qualifier_list (pp
, DECL_P (t
) ? TREE_TYPE (t
) : t
);
575 direct-declarator [ type-qualifier-list(opt) assignment-expression(opt) ]
576 direct-declarator [ static type-qualifier-list(opt) assignment-expression(opt)]
577 direct-declarator [ type-qualifier-list static assignment-expression ]
578 direct-declarator [ type-qualifier-list * ]
579 direct-declarator ( parameter-type-list )
580 direct-declarator ( identifier-list(opt) ) */
583 pp_c_direct_declarator (c_pretty_printer
*pp
, tree t
)
585 switch (TREE_CODE (t
))
592 pp_c_space_for_pointer_operator (pp
, TREE_TYPE (t
));
593 pp_c_tree_decl_identifier (pp
, t
);
598 pp_abstract_declarator (pp
, TREE_TYPE (t
));
602 pp_parameter_list (pp
, t
);
603 pp_abstract_declarator (pp
, TREE_TYPE (t
));
607 pp_c_space_for_pointer_operator (pp
, TREE_TYPE (TREE_TYPE (t
)));
608 pp_c_tree_decl_identifier (pp
, t
);
609 if (pp_c_base (pp
)->flags
& pp_c_flag_abstract
)
610 pp_abstract_declarator (pp
, TREE_TYPE (t
));
613 pp_parameter_list (pp
, t
);
614 pp_abstract_declarator (pp
, TREE_TYPE (TREE_TYPE (t
)));
626 pp_unsupported_tree (pp
, t
);
633 pointer(opt) direct-declarator */
636 pp_c_declarator (c_pretty_printer
*pp
, tree t
)
638 switch (TREE_CODE (t
))
654 pp_direct_declarator (pp
, t
);
659 pp_unsupported_tree (pp
, t
);
665 declaration-specifiers init-declarator-list(opt) ; */
668 pp_c_declaration (c_pretty_printer
*pp
, tree t
)
670 pp_declaration_specifiers (pp
, t
);
671 pp_c_init_declarator (pp
, t
);
674 /* Pretty-print ATTRIBUTES using GNU C extension syntax. */
677 pp_c_attributes (c_pretty_printer
*pp
, tree attributes
)
679 if (attributes
== NULL_TREE
)
682 pp_c_identifier (pp
, "__attribute__");
683 pp_c_left_paren (pp
);
684 pp_c_left_paren (pp
);
685 for (; attributes
!= NULL_TREE
; attributes
= TREE_CHAIN (attributes
))
687 pp_tree_identifier (pp
, TREE_PURPOSE (attributes
));
688 if (TREE_VALUE (attributes
))
689 pp_c_call_argument_list (pp
, TREE_VALUE (attributes
));
691 if (TREE_CHAIN (attributes
))
692 pp_separate_with (pp
, ',');
694 pp_c_right_paren (pp
);
695 pp_c_right_paren (pp
);
698 /* function-definition:
699 declaration-specifiers declarator compound-statement */
702 pp_c_function_definition (c_pretty_printer
*pp
, tree t
)
704 pp_declaration_specifiers (pp
, t
);
705 pp_declarator (pp
, t
);
706 pp_needs_newline (pp
) = true;
707 pp_statement (pp
, DECL_SAVED_TREE (t
));
715 /* Print out a c-char. This is called solely for characters which are
716 in the *target* execution character set. We ought to convert them
717 back to the *host* execution character set before printing, but we
718 have no way to do this at present. A decent compromise is to print
719 all characters as if they were in the host execution character set,
720 and not attempt to recover any named escape characters, but render
721 all unprintables as octal escapes. If the host and target character
722 sets are the same, this produces relatively readable output. If they
723 are not the same, strings may appear as gibberish, but that's okay
724 (in fact, it may well be what the reader wants, e.g. if they are looking
725 to see if conversion to the target character set happened correctly).
727 A special case: we need to prefix \, ", and ' with backslashes. It is
728 correct to do so for the *host*'s \, ", and ', because the rest of the
729 file appears in the host character set. */
732 pp_c_char (c_pretty_printer
*pp
, int c
)
738 case '\\': pp_string (pp
, "\\\\"); break;
739 case '\'': pp_string (pp
, "\\\'"); break;
740 case '\"': pp_string (pp
, "\\\""); break;
741 default: pp_character (pp
, c
);
745 pp_scalar (pp
, "\\%03o", (unsigned) c
);
748 /* Print out a STRING literal. */
751 pp_c_string_literal (c_pretty_printer
*pp
, tree s
)
753 const char *p
= TREE_STRING_POINTER (s
);
754 int n
= TREE_STRING_LENGTH (s
) - 1;
757 for (i
= 0; i
< n
; ++i
)
758 pp_c_char (pp
, p
[i
]);
762 /* Pretty-print an INTEGER literal. */
765 pp_c_integer_constant (c_pretty_printer
*pp
, tree i
)
767 tree type
= TREE_TYPE (i
);
769 if (TREE_INT_CST_HIGH (i
) == 0)
770 pp_wide_integer (pp
, TREE_INT_CST_LOW (i
));
773 if (tree_int_cst_sgn (i
) < 0)
775 pp_character (pp
, '-');
776 i
= build_int_cst_wide (NULL_TREE
,
777 -TREE_INT_CST_LOW (i
),
778 ~TREE_INT_CST_HIGH (i
)
779 + !TREE_INT_CST_LOW (i
));
781 sprintf (pp_buffer (pp
)->digit_buffer
,
782 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
783 TREE_INT_CST_HIGH (i
), TREE_INT_CST_LOW (i
));
784 pp_string (pp
, pp_buffer (pp
)->digit_buffer
);
786 if (TYPE_UNSIGNED (type
))
787 pp_character (pp
, 'u');
788 if (type
== long_integer_type_node
|| type
== long_unsigned_type_node
)
789 pp_character (pp
, 'l');
790 else if (type
== long_long_integer_type_node
791 || type
== long_long_unsigned_type_node
)
792 pp_string (pp
, "ll");
795 /* Print out a CHARACTER literal. */
798 pp_c_character_constant (c_pretty_printer
*pp
, tree c
)
800 tree type
= TREE_TYPE (c
);
801 if (type
== wchar_type_node
)
802 pp_character (pp
, 'L');
804 if (host_integerp (c
, TYPE_UNSIGNED (type
)))
805 pp_c_char (pp
, tree_low_cst (c
, TYPE_UNSIGNED (type
)));
807 pp_scalar (pp
, "\\x%x", (unsigned) TREE_INT_CST_LOW (c
));
811 /* Print out a BOOLEAN literal. */
814 pp_c_bool_constant (c_pretty_printer
*pp
, tree b
)
816 if (b
== boolean_false_node
)
818 if (c_dialect_cxx ())
819 pp_c_identifier (pp
, "false");
820 else if (flag_isoc99
)
821 pp_c_identifier (pp
, "_False");
823 pp_unsupported_tree (pp
, b
);
825 else if (b
== boolean_true_node
)
827 if (c_dialect_cxx ())
828 pp_c_identifier (pp
, "true");
829 else if (flag_isoc99
)
830 pp_c_identifier (pp
, "_True");
832 pp_unsupported_tree (pp
, b
);
834 else if (TREE_CODE (b
) == INTEGER_CST
)
835 pp_c_integer_constant (pp
, b
);
837 pp_unsupported_tree (pp
, b
);
840 /* Attempt to print out an ENUMERATOR. Return true on success. Else return
841 false; that means the value was obtained by a cast, in which case
842 print out the type-id part of the cast-expression -- the casted value
843 is then printed by pp_c_integer_literal. */
846 pp_c_enumeration_constant (c_pretty_printer
*pp
, tree e
)
848 bool value_is_named
= true;
849 tree type
= TREE_TYPE (e
);
852 /* Find the name of this constant. */
853 for (value
= TYPE_VALUES (type
);
854 value
!= NULL_TREE
&& !tree_int_cst_equal (TREE_VALUE (value
), e
);
855 value
= TREE_CHAIN (value
))
858 if (value
!= NULL_TREE
)
859 pp_id_expression (pp
, TREE_PURPOSE (value
));
862 /* Value must have been cast. */
863 pp_c_type_cast (pp
, type
);
864 value_is_named
= false;
867 return value_is_named
;
870 /* Print out a REAL value as a decimal-floating-constant. */
873 pp_c_floating_constant (c_pretty_printer
*pp
, tree r
)
875 real_to_decimal (pp_buffer (pp
)->digit_buffer
, &TREE_REAL_CST (r
),
876 sizeof (pp_buffer (pp
)->digit_buffer
), 0, 1);
877 pp_string (pp
, pp_buffer(pp
)->digit_buffer
);
878 if (TREE_TYPE (r
) == float_type_node
)
879 pp_character (pp
, 'f');
880 else if (TREE_TYPE (r
) == long_double_type_node
)
881 pp_character (pp
, 'l');
884 /* Pretty-print a compound literal expression. GNU extensions include
888 pp_c_compound_literal (c_pretty_printer
*pp
, tree e
)
890 tree type
= TREE_TYPE (e
);
891 pp_c_type_cast (pp
, type
);
893 switch (TREE_CODE (type
))
900 pp_c_brace_enclosed_initializer_list (pp
, e
);
904 pp_unsupported_tree (pp
, e
);
913 character-constant */
916 pp_c_constant (c_pretty_printer
*pp
, tree e
)
918 const enum tree_code code
= TREE_CODE (e
);
924 tree type
= TREE_TYPE (e
);
925 if (type
== boolean_type_node
)
926 pp_c_bool_constant (pp
, e
);
927 else if (type
== char_type_node
)
928 pp_c_character_constant (pp
, e
);
929 else if (TREE_CODE (type
) == ENUMERAL_TYPE
930 && pp_c_enumeration_constant (pp
, e
))
933 pp_c_integer_constant (pp
, e
);
938 pp_c_floating_constant (pp
, e
);
942 pp_c_string_literal (pp
, e
);
946 pp_unsupported_tree (pp
, e
);
951 /* Pretty-print an IDENTIFIER_NODE, preceded by whitespace is necessary. */
954 pp_c_identifier (c_pretty_printer
*pp
, const char *id
)
956 pp_c_maybe_whitespace (pp
);
957 pp_identifier (pp
, id
);
958 pp_base (pp
)->padding
= pp_before
;
961 /* Pretty-print a C primary-expression.
969 pp_c_primary_expression (c_pretty_printer
*pp
, tree e
)
971 switch (TREE_CODE (e
))
979 pp_c_tree_decl_identifier (pp
, e
);
982 case IDENTIFIER_NODE
:
983 pp_c_tree_identifier (pp
, e
);
987 pp_c_identifier (pp
, "<erroneous-expression>");
991 pp_c_identifier (pp
, "<return-value>");
997 pp_c_constant (pp
, e
);
1001 pp_c_identifier (pp
, "__builtin_memcpy");
1002 pp_c_left_paren (pp
);
1004 pp_primary_expression (pp
, TREE_OPERAND (e
, 0));
1005 pp_separate_with (pp
, ',');
1007 pp_initializer (pp
, TREE_OPERAND (e
, 1));
1008 if (TREE_OPERAND (e
, 2))
1010 pp_separate_with (pp
, ',');
1011 pp_c_expression (pp
, TREE_OPERAND (e
, 2));
1013 pp_c_right_paren (pp
);
1017 /* FIXME: Make sure we won't get into an infinie loop. */
1018 pp_c_left_paren (pp
);
1019 pp_expression (pp
, e
);
1020 pp_c_right_paren (pp
);
1025 /* Print out a C initializer -- also support C compound-literals.
1027 assignment-expression:
1028 { initializer-list }
1029 { initializer-list , } */
1032 pp_c_initializer (c_pretty_printer
*pp
, tree e
)
1034 if (TREE_CODE (e
) == CONSTRUCTOR
)
1035 pp_c_brace_enclosed_initializer_list (pp
, e
);
1037 pp_expression (pp
, e
);
1042 declarator = initializer */
1045 pp_c_init_declarator (c_pretty_printer
*pp
, tree t
)
1047 pp_declarator (pp
, t
);
1048 /* We don't want to output function definitions here. There are handled
1049 elsewhere (and the syntactic form is bogus anyway). */
1050 if (TREE_CODE (t
) != FUNCTION_DECL
&& DECL_INITIAL (t
))
1052 tree init
= DECL_INITIAL (t
);
1053 /* This C++ bit is handled here because it is easier to do so.
1054 In templates, the C++ parser builds a TREE_LIST for a
1055 direct-initialization; the TREE_PURPOSE is the variable to
1056 initialize and the TREE_VALUE is the initializer. */
1057 if (TREE_CODE (init
) == TREE_LIST
)
1059 pp_c_left_paren (pp
);
1060 pp_expression (pp
, TREE_VALUE (init
));
1061 pp_right_paren (pp
);
1068 pp_c_initializer (pp
, init
);
1073 /* initializer-list:
1074 designation(opt) initializer
1075 initializer-list , designation(opt) initializer
1082 designator-list designator
1085 [ constant-expression ]
1089 pp_c_initializer_list (c_pretty_printer
*pp
, tree e
)
1091 tree type
= TREE_TYPE (e
);
1092 const enum tree_code code
= TREE_CODE (type
);
1100 tree init
= TREE_OPERAND (e
, 0);
1101 for (; init
!= NULL_TREE
; init
= TREE_CHAIN (init
))
1103 if (code
== RECORD_TYPE
|| code
== UNION_TYPE
)
1106 pp_c_primary_expression (pp
, TREE_PURPOSE (init
));
1110 pp_c_left_bracket (pp
);
1111 if (TREE_PURPOSE (init
))
1112 pp_c_constant (pp
, TREE_PURPOSE (init
));
1113 pp_c_right_bracket (pp
);
1115 pp_c_whitespace (pp
);
1117 pp_c_whitespace (pp
);
1118 pp_initializer (pp
, TREE_VALUE (init
));
1119 if (TREE_CHAIN (init
))
1120 pp_separate_with (pp
, ',');
1126 if (TREE_CODE (e
) == VECTOR_CST
)
1127 pp_c_expression_list (pp
, TREE_VECTOR_CST_ELTS (e
));
1128 else if (TREE_CODE (e
) == CONSTRUCTOR
)
1129 pp_c_expression_list (pp
, CONSTRUCTOR_ELTS (e
));
1135 if (TREE_CODE (e
) == CONSTRUCTOR
)
1136 pp_c_expression_list (pp
, CONSTRUCTOR_ELTS (e
));
1137 else if (TREE_CODE (e
) == COMPLEX_CST
|| TREE_CODE (e
) == COMPLEX_EXPR
)
1139 const bool cst
= TREE_CODE (e
) == COMPLEX_CST
;
1140 pp_expression (pp
, cst
? TREE_REALPART (e
) : TREE_OPERAND (e
, 0));
1141 pp_separate_with (pp
, ',');
1142 pp_expression (pp
, cst
? TREE_IMAGPART (e
) : TREE_OPERAND (e
, 1));
1152 pp_unsupported_tree (pp
, type
);
1155 /* Pretty-print a brace-enclosed initializer-list. */
1158 pp_c_brace_enclosed_initializer_list (c_pretty_printer
*pp
, tree l
)
1160 pp_c_left_brace (pp
);
1161 pp_c_initializer_list (pp
, l
);
1162 pp_c_right_brace (pp
);
1166 /* This is a convenient function, used to bridge gap between C and C++
1173 pp_c_id_expression (c_pretty_printer
*pp
, tree t
)
1175 switch (TREE_CODE (t
))
1184 pp_c_tree_decl_identifier (pp
, t
);
1187 case IDENTIFIER_NODE
:
1188 pp_c_tree_identifier (pp
, t
);
1192 pp_unsupported_tree (pp
, t
);
1197 /* postfix-expression:
1199 postfix-expression [ expression ]
1200 postfix-expression ( argument-expression-list(opt) )
1201 postfix-expression . identifier
1202 postfix-expression -> identifier
1203 postfix-expression ++
1204 postfix-expression --
1205 ( type-name ) { initializer-list }
1206 ( type-name ) { initializer-list , } */
1209 pp_c_postfix_expression (c_pretty_printer
*pp
, tree e
)
1211 enum tree_code code
= TREE_CODE (e
);
1214 case POSTINCREMENT_EXPR
:
1215 case POSTDECREMENT_EXPR
:
1216 pp_postfix_expression (pp
, TREE_OPERAND (e
, 0));
1217 pp_identifier (pp
, code
== POSTINCREMENT_EXPR
? "++" : "--");
1221 pp_postfix_expression (pp
, TREE_OPERAND (e
, 0));
1222 pp_c_left_bracket (pp
);
1223 pp_expression (pp
, TREE_OPERAND (e
, 1));
1224 pp_c_right_bracket (pp
);
1228 pp_postfix_expression (pp
, TREE_OPERAND (e
, 0));
1229 pp_c_call_argument_list (pp
, TREE_OPERAND (e
, 1));
1232 case UNORDERED_EXPR
:
1233 pp_c_identifier (pp
, flag_isoc99
1235 : "__builtin_isunordered");
1239 pp_c_identifier (pp
, flag_isoc99
1241 : "!__builtin_isunordered");
1245 pp_c_identifier (pp
, flag_isoc99
1247 : "!__builtin_isgreaterequal");
1251 pp_c_identifier (pp
, flag_isoc99
1253 : "!__builtin_isgreater");
1257 pp_c_identifier (pp
, flag_isoc99
1259 : "!__builtin_islessequal");
1263 pp_c_identifier (pp
, flag_isoc99
1265 : "!__builtin_isless");
1269 pp_c_identifier (pp
, flag_isoc99
1271 : "!__builtin_islessgreater");
1275 pp_c_identifier (pp
, flag_isoc99
1277 : "__builtin_islessgreater");
1281 pp_c_left_paren (pp
);
1282 pp_expression (pp
, TREE_OPERAND (e
, 0));
1283 pp_separate_with (pp
, ',');
1284 pp_expression (pp
, TREE_OPERAND (e
, 1));
1285 pp_c_right_paren (pp
);
1289 pp_c_identifier (pp
, "__builtin_abs");
1290 pp_c_left_paren (pp
);
1291 pp_expression (pp
, TREE_OPERAND (e
, 0));
1292 pp_c_right_paren (pp
);
1297 tree object
= TREE_OPERAND (e
, 0);
1298 if (TREE_CODE (object
) == INDIRECT_REF
)
1300 pp_postfix_expression (pp
, TREE_OPERAND (object
, 0));
1305 pp_postfix_expression (pp
, object
);
1308 pp_expression (pp
, TREE_OPERAND (e
, 1));
1315 pp_c_compound_literal (pp
, e
);
1318 case COMPOUND_LITERAL_EXPR
:
1319 e
= DECL_INITIAL (COMPOUND_LITERAL_EXPR_DECL (e
));
1322 pp_initializer (pp
, e
);
1326 pp_c_identifier (pp
, "__builtin_va_arg");
1327 pp_c_left_paren (pp
);
1328 pp_assignment_expression (pp
, TREE_OPERAND (e
, 0));
1329 pp_separate_with (pp
, ',');
1330 pp_type_id (pp
, TREE_TYPE (e
));
1331 pp_c_right_paren (pp
);
1335 if (TREE_CODE (TREE_OPERAND (e
, 0)) == FUNCTION_DECL
)
1337 pp_c_id_expression (pp
, TREE_OPERAND (e
, 0));
1340 /* else fall through. */
1343 pp_primary_expression (pp
, e
);
1348 /* Print out an expression-list; E is expected to be a TREE_LIST. */
1351 pp_c_expression_list (c_pretty_printer
*pp
, tree e
)
1353 for (; e
!= NULL_TREE
; e
= TREE_CHAIN (e
))
1355 pp_expression (pp
, TREE_VALUE (e
));
1357 pp_separate_with (pp
, ',');
1361 /* Print out an expression-list in parens, as in a function call. */
1364 pp_c_call_argument_list (c_pretty_printer
*pp
, tree t
)
1366 pp_c_left_paren (pp
);
1367 if (t
&& TREE_CODE (t
) == TREE_LIST
)
1368 pp_c_expression_list (pp
, t
);
1369 pp_c_right_paren (pp
);
1372 /* unary-expression:
1376 unary-operator cast-expression
1377 sizeof unary-expression
1380 unary-operator: one of
1385 __alignof__ unary-expression
1386 __alignof__ ( type-id )
1387 __real__ unary-expression
1388 __imag__ unary-expression */
1391 pp_c_unary_expression (c_pretty_printer
*pp
, tree e
)
1393 enum tree_code code
= TREE_CODE (e
);
1396 case PREINCREMENT_EXPR
:
1397 case PREDECREMENT_EXPR
:
1398 pp_identifier (pp
, code
== PREINCREMENT_EXPR
? "++" : "--");
1399 pp_c_unary_expression (pp
, TREE_OPERAND (e
, 0));
1406 case TRUTH_NOT_EXPR
:
1408 /* String literal are used by address. */
1409 if (code
== ADDR_EXPR
&& TREE_CODE (TREE_OPERAND (e
, 0)) != STRING_CST
)
1411 else if (code
== INDIRECT_REF
)
1413 else if (code
== NEGATE_EXPR
)
1415 else if (code
== BIT_NOT_EXPR
|| code
== CONJ_EXPR
)
1417 else if (code
== TRUTH_NOT_EXPR
)
1418 pp_exclamation (pp
);
1419 pp_c_cast_expression (pp
, TREE_OPERAND (e
, 0));
1424 pp_c_identifier (pp
, code
== REALPART_EXPR
? "__real__" : "__imag__");
1425 pp_c_whitespace (pp
);
1426 pp_unary_expression (pp
, TREE_OPERAND (e
, 0));
1430 pp_postfix_expression (pp
, e
);
1437 ( type-name ) cast-expression */
1440 pp_c_cast_expression (c_pretty_printer
*pp
, tree e
)
1442 switch (TREE_CODE (e
))
1445 case FIX_TRUNC_EXPR
:
1447 pp_c_type_cast (pp
, TREE_TYPE (e
));
1448 pp_c_cast_expression (pp
, TREE_OPERAND (e
, 0));
1452 pp_unary_expression (pp
, e
);
1456 /* multiplicative-expression:
1458 multiplicative-expression * cast-expression
1459 multiplicative-expression / cast-expression
1460 multiplicative-expression % cast-expression */
1463 pp_c_multiplicative_expression (c_pretty_printer
*pp
, tree e
)
1465 enum tree_code code
= TREE_CODE (e
);
1469 case TRUNC_DIV_EXPR
:
1470 case TRUNC_MOD_EXPR
:
1471 pp_multiplicative_expression (pp
, TREE_OPERAND (e
, 0));
1472 pp_c_whitespace (pp
);
1473 if (code
== MULT_EXPR
)
1475 else if (code
== TRUNC_DIV_EXPR
)
1479 pp_c_whitespace (pp
);
1480 pp_c_cast_expression (pp
, TREE_OPERAND (e
, 1));
1484 pp_c_cast_expression (pp
, e
);
1489 /* additive-expression:
1490 multiplicative-expression
1491 additive-expression + multiplicative-expression
1492 additive-expression - multiplicative-expression */
1495 pp_c_additive_expression (c_pretty_printer
*pp
, tree e
)
1497 enum tree_code code
= TREE_CODE (e
);
1502 pp_c_additive_expression (pp
, TREE_OPERAND (e
, 0));
1503 pp_c_whitespace (pp
);
1504 if (code
== PLUS_EXPR
)
1508 pp_c_whitespace (pp
);
1509 pp_multiplicative_expression (pp
, TREE_OPERAND (e
, 1));
1513 pp_multiplicative_expression (pp
, e
);
1518 /* additive-expression:
1520 shift-expression << additive-expression
1521 shift-expression >> additive-expression */
1524 pp_c_shift_expression (c_pretty_printer
*pp
, tree e
)
1526 enum tree_code code
= TREE_CODE (e
);
1531 pp_c_shift_expression (pp
, TREE_OPERAND (e
, 0));
1532 pp_c_whitespace (pp
);
1533 pp_identifier (pp
, code
== LSHIFT_EXPR
? "<<" : ">>");
1534 pp_c_whitespace (pp
);
1535 pp_c_additive_expression (pp
, TREE_OPERAND (e
, 1));
1539 pp_c_additive_expression (pp
, e
);
1543 /* relational-expression:
1545 relational-expression < shift-expression
1546 relational-expression > shift-expression
1547 relational-expression <= shift-expression
1548 relational-expression >= shift-expression */
1551 pp_c_relational_expression (c_pretty_printer
*pp
, tree e
)
1553 enum tree_code code
= TREE_CODE (e
);
1560 pp_c_relational_expression (pp
, TREE_OPERAND (e
, 0));
1561 pp_c_whitespace (pp
);
1562 if (code
== LT_EXPR
)
1564 else if (code
== GT_EXPR
)
1566 else if (code
== LE_EXPR
)
1567 pp_identifier (pp
, "<=");
1568 else if (code
== GE_EXPR
)
1569 pp_identifier (pp
, ">=");
1570 pp_c_whitespace (pp
);
1571 pp_c_shift_expression (pp
, TREE_OPERAND (e
, 1));
1575 pp_c_shift_expression (pp
, e
);
1580 /* equality-expression:
1581 relational-expression
1582 equality-expression == relational-expression
1583 equality-equality != relational-expression */
1586 pp_c_equality_expression (c_pretty_printer
*pp
, tree e
)
1588 enum tree_code code
= TREE_CODE (e
);
1593 pp_c_equality_expression (pp
, TREE_OPERAND (e
, 0));
1594 pp_c_whitespace (pp
);
1595 pp_identifier (pp
, code
== EQ_EXPR
? "==" : "!=");
1596 pp_c_whitespace (pp
);
1597 pp_c_relational_expression (pp
, TREE_OPERAND (e
, 1));
1601 pp_c_relational_expression (pp
, e
);
1608 AND-expression & equality-equality */
1611 pp_c_and_expression (c_pretty_printer
*pp
, tree e
)
1613 if (TREE_CODE (e
) == BIT_AND_EXPR
)
1615 pp_c_and_expression (pp
, TREE_OPERAND (e
, 0));
1616 pp_c_whitespace (pp
);
1618 pp_c_whitespace (pp
);
1619 pp_c_equality_expression (pp
, TREE_OPERAND (e
, 1));
1622 pp_c_equality_expression (pp
, e
);
1625 /* exclusive-OR-expression:
1627 exclusive-OR-expression ^ AND-expression */
1630 pp_c_exclusive_or_expression (c_pretty_printer
*pp
, tree e
)
1632 if (TREE_CODE (e
) == BIT_XOR_EXPR
)
1634 pp_c_exclusive_or_expression (pp
, TREE_OPERAND (e
, 0));
1635 pp_c_maybe_whitespace (pp
);
1637 pp_c_whitespace (pp
);
1638 pp_c_and_expression (pp
, TREE_OPERAND (e
, 1));
1641 pp_c_and_expression (pp
, e
);
1644 /* inclusive-OR-expression:
1645 exclusive-OR-expression
1646 inclusive-OR-expression | exclusive-OR-expression */
1649 pp_c_inclusive_or_expression (c_pretty_printer
*pp
, tree e
)
1651 if (TREE_CODE (e
) == BIT_IOR_EXPR
)
1653 pp_c_exclusive_or_expression (pp
, TREE_OPERAND (e
, 0));
1654 pp_c_whitespace (pp
);
1656 pp_c_whitespace (pp
);
1657 pp_c_exclusive_or_expression (pp
, TREE_OPERAND (e
, 1));
1660 pp_c_exclusive_or_expression (pp
, e
);
1663 /* logical-AND-expression:
1664 inclusive-OR-expression
1665 logical-AND-expression && inclusive-OR-expression */
1668 pp_c_logical_and_expression (c_pretty_printer
*pp
, tree e
)
1670 if (TREE_CODE (e
) == TRUTH_ANDIF_EXPR
)
1672 pp_c_logical_and_expression (pp
, TREE_OPERAND (e
, 0));
1673 pp_c_whitespace (pp
);
1674 pp_identifier (pp
, "&&");
1675 pp_c_whitespace (pp
);
1676 pp_c_inclusive_or_expression (pp
, TREE_OPERAND (e
, 1));
1679 pp_c_inclusive_or_expression (pp
, e
);
1682 /* logical-OR-expression:
1683 logical-AND-expression
1684 logical-OR-expression || logical-AND-expression */
1687 pp_c_logical_or_expression (c_pretty_printer
*pp
, tree e
)
1689 if (TREE_CODE (e
) == TRUTH_ORIF_EXPR
)
1691 pp_c_logical_or_expression (pp
, TREE_OPERAND (e
, 0));
1692 pp_c_whitespace (pp
);
1693 pp_identifier (pp
, "||");
1694 pp_c_whitespace (pp
);
1695 pp_c_logical_and_expression (pp
, TREE_OPERAND (e
, 1));
1698 pp_c_logical_and_expression (pp
, e
);
1701 /* conditional-expression:
1702 logical-OR-expression
1703 logical-OR-expression ? expression : conditional-expression */
1706 pp_c_conditional_expression (c_pretty_printer
*pp
, tree e
)
1708 if (TREE_CODE (e
) == COND_EXPR
)
1710 pp_c_logical_or_expression (pp
, TREE_OPERAND (e
, 0));
1711 pp_c_whitespace (pp
);
1713 pp_c_whitespace (pp
);
1714 pp_expression (pp
, TREE_OPERAND (e
, 1));
1715 pp_c_whitespace (pp
);
1717 pp_c_whitespace (pp
);
1718 pp_c_conditional_expression (pp
, TREE_OPERAND (e
, 2));
1721 pp_c_logical_or_expression (pp
, e
);
1725 /* assignment-expression:
1726 conditional-expression
1727 unary-expression assignment-operator assignment-expression
1729 assignment-expression: one of
1730 = *= /= %= += -= >>= <<= &= ^= |= */
1733 pp_c_assignment_expression (c_pretty_printer
*pp
, tree e
)
1735 if (TREE_CODE (e
) == MODIFY_EXPR
|| TREE_CODE (e
) == INIT_EXPR
)
1737 pp_c_unary_expression (pp
, TREE_OPERAND (e
, 0));
1738 pp_c_whitespace (pp
);
1741 pp_c_expression (pp
, TREE_OPERAND (e
, 1));
1744 pp_c_conditional_expression (pp
, e
);
1748 assignment-expression
1749 expression , assignment-expression
1751 Implementation note: instead of going through the usual recursion
1752 chain, I take the liberty of dispatching nodes to the appropriate
1753 functions. This makes some redundancy, but it worths it. That also
1754 prevents a possible infinite recursion between pp_c_primary_expression ()
1755 and pp_c_expression (). */
1758 pp_c_expression (c_pretty_printer
*pp
, tree e
)
1760 switch (TREE_CODE (e
))
1763 pp_c_integer_constant (pp
, e
);
1767 pp_c_floating_constant (pp
, e
);
1771 pp_c_string_literal (pp
, e
);
1774 case IDENTIFIER_NODE
:
1783 pp_primary_expression (pp
, e
);
1786 case POSTINCREMENT_EXPR
:
1787 case POSTDECREMENT_EXPR
:
1795 case UNORDERED_EXPR
:
1804 case COMPOUND_LITERAL_EXPR
:
1806 pp_postfix_expression (pp
, e
);
1814 case TRUTH_NOT_EXPR
:
1815 case PREINCREMENT_EXPR
:
1816 case PREDECREMENT_EXPR
:
1819 pp_c_unary_expression (pp
, e
);
1823 case FIX_TRUNC_EXPR
:
1825 pp_c_cast_expression (pp
, e
);
1829 case TRUNC_MOD_EXPR
:
1830 case TRUNC_DIV_EXPR
:
1831 pp_multiplicative_expression (pp
, e
);
1836 pp_c_shift_expression (pp
, e
);
1843 pp_c_relational_expression (pp
, e
);
1847 pp_c_and_expression (pp
, e
);
1851 pp_c_exclusive_or_expression (pp
, e
);
1855 pp_c_inclusive_or_expression (pp
, e
);
1858 case TRUTH_ANDIF_EXPR
:
1859 pp_c_logical_and_expression (pp
, e
);
1862 case TRUTH_ORIF_EXPR
:
1863 pp_c_logical_or_expression (pp
, e
);
1868 pp_c_equality_expression (pp
, e
);
1872 pp_conditional_expression (pp
, e
);
1877 pp_c_additive_expression (pp
, e
);
1882 pp_assignment_expression (pp
, e
);
1886 pp_c_left_paren (pp
);
1887 pp_expression (pp
, TREE_OPERAND (e
, 0));
1888 pp_separate_with (pp
, ',');
1889 pp_assignment_expression (pp
, TREE_OPERAND (e
, 1));
1890 pp_c_right_paren (pp
);
1894 case NON_LVALUE_EXPR
:
1896 pp_expression (pp
, TREE_OPERAND (e
, 0));
1900 pp_postfix_expression (pp
, TREE_OPERAND (e
, 1));
1904 pp_unsupported_tree (pp
, e
);
1914 pp_c_statement (c_pretty_printer
*pp
, tree stmt
)
1919 if (pp_needs_newline (pp
))
1920 pp_newline_and_indent (pp
, 0);
1922 dump_generic_node (pp_base (pp
), stmt
, pp_indentation (pp
), 0, true);
1926 /* Initialize the PRETTY-PRINTER for handling C codes. */
1929 pp_c_pretty_printer_init (c_pretty_printer
*pp
)
1931 pp
->offset_list
= 0;
1933 pp
->declaration
= pp_c_declaration
;
1934 pp
->declaration_specifiers
= pp_c_declaration_specifiers
;
1935 pp
->declarator
= pp_c_declarator
;
1936 pp
->direct_declarator
= pp_c_direct_declarator
;
1937 pp
->type_specifier_seq
= pp_c_specifier_qualifier_list
;
1938 pp
->abstract_declarator
= pp_c_abstract_declarator
;
1939 pp
->direct_abstract_declarator
= pp_c_direct_abstract_declarator
;
1940 pp
->ptr_operator
= pp_c_pointer
;
1941 pp
->parameter_list
= pp_c_parameter_type_list
;
1942 pp
->type_id
= pp_c_type_id
;
1943 pp
->simple_type_specifier
= pp_c_type_specifier
;
1944 pp
->function_specifier
= pp_c_function_specifier
;
1945 pp
->storage_class_specifier
= pp_c_storage_class_specifier
;
1947 pp
->statement
= pp_c_statement
;
1949 pp
->id_expression
= pp_c_id_expression
;
1950 pp
->primary_expression
= pp_c_primary_expression
;
1951 pp
->postfix_expression
= pp_c_postfix_expression
;
1952 pp
->unary_expression
= pp_c_unary_expression
;
1953 pp
->initializer
= pp_c_initializer
;
1954 pp
->multiplicative_expression
= pp_c_multiplicative_expression
;
1955 pp
->conditional_expression
= pp_c_conditional_expression
;
1956 pp
->assignment_expression
= pp_c_assignment_expression
;
1957 pp
->expression
= pp_c_expression
;
1961 /* Print the tree T in full, on file FILE. */
1964 print_c_tree (FILE *file
, tree t
)
1966 static c_pretty_printer pp_rec
;
1967 static bool initialized
= 0;
1968 c_pretty_printer
*pp
= &pp_rec
;
1973 pp_construct (pp_base (pp
), NULL
, 0);
1974 pp_c_pretty_printer_init (pp
);
1975 pp_needs_newline (pp
) = true;
1977 pp_base (pp
)->buffer
->stream
= file
;
1979 pp_statement (pp
, t
);
1985 /* Print the tree T in full, on stderr. */
1988 debug_c_tree (tree t
)
1990 print_c_tree (stderr
, t
);
1991 fputc ('\n', stderr
);
1994 /* Output the DECL_NAME of T. If T has no DECL_NAME, output a string made
1995 up of T's memory address. */
1998 pp_c_tree_decl_identifier (c_pretty_printer
*pp
, tree t
)
2002 gcc_assert (DECL_P (t
));
2005 name
= IDENTIFIER_POINTER (DECL_NAME (t
));
2008 static char xname
[8];
2009 sprintf (xname
, "<U%4x>", ((unsigned)((unsigned long)(t
) & 0xffff)));
2013 pp_c_identifier (pp
, name
);