1 /* Subroutines common to both C and C++ pretty-printers.
2 Copyright (C) 2002, 2003, 2004, 2005, 2006 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
);
319 pp_c_type_specifier (pp
, t
);
323 int prec
= TYPE_PRECISION (t
);
324 t
= c_common_type_for_mode (TYPE_MODE (t
), TYPE_UNSIGNED (t
));
327 pp_c_type_specifier (pp
, t
);
328 if (TYPE_PRECISION (t
) != prec
)
331 pp_decimal_int (pp
, prec
);
339 pp_string (pp
, (TYPE_UNSIGNED (t
)
340 ? "<unnamed-unsigned:"
341 : "<unnamed-signed:"));
344 pp_string (pp
, "<unnamed-float:");
349 pp_decimal_int (pp
, prec
);
357 pp_id_expression (pp
, t
);
359 pp_c_identifier (pp
, "<typedef-error>");
365 if (code
== UNION_TYPE
)
366 pp_c_identifier (pp
, "union");
367 else if (code
== RECORD_TYPE
)
368 pp_c_identifier (pp
, "struct");
369 else if (code
== ENUMERAL_TYPE
)
370 pp_c_identifier (pp
, "enum");
372 pp_c_identifier (pp
, "<tag-error>");
375 pp_id_expression (pp
, TYPE_NAME (t
));
377 pp_c_identifier (pp
, "<anonymous>");
381 pp_unsupported_tree (pp
, t
);
386 /* specifier-qualifier-list:
387 type-specifier specifier-qualifier-list-opt
388 type-qualifier specifier-qualifier-list-opt
391 Implementation note: Because of the non-linearities in array or
392 function declarations, this routine prints not just the
393 specifier-qualifier-list of such entities or types of such entities,
394 but also the 'pointer' production part of their declarators. The
395 remaining part is done by pp_declarator or pp_c_abstract_declarator. */
398 pp_c_specifier_qualifier_list (c_pretty_printer
*pp
, tree t
)
400 const enum tree_code code
= TREE_CODE (t
);
402 if (TREE_CODE (t
) != POINTER_TYPE
)
403 pp_c_type_qualifier_list (pp
, t
);
409 /* Get the types-specifier of this type. */
410 tree pointee
= strip_pointer_operator (TREE_TYPE (t
));
411 pp_c_specifier_qualifier_list (pp
, pointee
);
412 if (TREE_CODE (pointee
) == ARRAY_TYPE
413 || TREE_CODE (pointee
) == FUNCTION_TYPE
)
415 pp_c_whitespace (pp
);
416 pp_c_left_paren (pp
);
418 else if (!c_dialect_cxx ())
419 pp_c_whitespace (pp
);
420 pp_ptr_operator (pp
, t
);
426 pp_c_specifier_qualifier_list (pp
, TREE_TYPE (t
));
431 pp_c_specifier_qualifier_list (pp
, TREE_TYPE (t
));
432 if (code
== COMPLEX_TYPE
)
433 pp_c_identifier (pp
, flag_isoc99
? "_Complex" : "__complex__");
434 else if (code
== VECTOR_TYPE
)
435 pp_c_identifier (pp
, "__vector__");
439 pp_simple_type_specifier (pp
, t
);
444 /* parameter-type-list:
449 parameter-declaration
450 parameter-list , parameter-declaration
452 parameter-declaration:
453 declaration-specifiers declarator
454 declaration-specifiers abstract-declarator(opt) */
457 pp_c_parameter_type_list (c_pretty_printer
*pp
, tree t
)
459 bool want_parm_decl
= DECL_P (t
) && !(pp
->flags
& pp_c_flag_abstract
);
460 tree parms
= want_parm_decl
? DECL_ARGUMENTS (t
) : TYPE_ARG_TYPES (t
);
461 pp_c_left_paren (pp
);
462 if (parms
== void_list_node
)
463 pp_c_identifier (pp
, "void");
467 for ( ; parms
&& parms
!= void_list_node
; parms
= TREE_CHAIN (parms
))
470 pp_separate_with (pp
, ',');
472 pp_declaration_specifiers
473 (pp
, want_parm_decl
? parms
: TREE_VALUE (parms
));
475 pp_declarator (pp
, parms
);
477 pp_abstract_declarator (pp
, TREE_VALUE (parms
));
480 pp_c_right_paren (pp
);
483 /* abstract-declarator:
485 pointer(opt) direct-abstract-declarator */
488 pp_c_abstract_declarator (c_pretty_printer
*pp
, tree t
)
490 if (TREE_CODE (t
) == POINTER_TYPE
)
492 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
493 || TREE_CODE (TREE_TYPE (t
)) == FUNCTION_TYPE
)
494 pp_c_right_paren (pp
);
498 pp_direct_abstract_declarator (pp
, t
);
501 /* direct-abstract-declarator:
502 ( abstract-declarator )
503 direct-abstract-declarator(opt) [ assignment-expression(opt) ]
504 direct-abstract-declarator(opt) [ * ]
505 direct-abstract-declarator(opt) ( parameter-type-list(opt) ) */
508 pp_c_direct_abstract_declarator (c_pretty_printer
*pp
, tree t
)
510 switch (TREE_CODE (t
))
513 pp_abstract_declarator (pp
, t
);
517 pp_c_parameter_type_list (pp
, t
);
518 pp_direct_abstract_declarator (pp
, TREE_TYPE (t
));
522 pp_c_left_bracket (pp
);
523 if (TYPE_DOMAIN (t
) && TYPE_MAX_VALUE (TYPE_DOMAIN (t
)))
524 pp_expression (pp
, TYPE_MAX_VALUE (TYPE_DOMAIN (t
)));
525 pp_c_right_bracket (pp
);
526 pp_direct_abstract_declarator (pp
, TREE_TYPE (t
));
529 case IDENTIFIER_NODE
:
543 pp_unsupported_tree (pp
, t
);
549 specifier-qualifier-list abstract-declarator(opt) */
552 pp_c_type_id (c_pretty_printer
*pp
, tree t
)
554 pp_c_specifier_qualifier_list (pp
, t
);
555 pp_abstract_declarator (pp
, t
);
558 /* storage-class-specifier:
566 pp_c_storage_class_specifier (c_pretty_printer
*pp
, tree t
)
568 if (TREE_CODE (t
) == TYPE_DECL
)
569 pp_c_identifier (pp
, "typedef");
572 if (DECL_REGISTER (t
))
573 pp_c_identifier (pp
, "register");
574 else if (TREE_STATIC (t
) && TREE_CODE (t
) == VAR_DECL
)
575 pp_c_identifier (pp
, "static");
579 /* function-specifier:
583 pp_c_function_specifier (c_pretty_printer
*pp
, tree t
)
585 if (TREE_CODE (t
) == FUNCTION_DECL
&& DECL_DECLARED_INLINE_P (t
))
586 pp_c_identifier (pp
, "inline");
589 /* declaration-specifiers:
590 storage-class-specifier declaration-specifiers(opt)
591 type-specifier declaration-specifiers(opt)
592 type-qualifier declaration-specifiers(opt)
593 function-specifier declaration-specifiers(opt) */
596 pp_c_declaration_specifiers (c_pretty_printer
*pp
, tree t
)
598 pp_storage_class_specifier (pp
, t
);
599 pp_function_specifier (pp
, t
);
600 pp_c_specifier_qualifier_list (pp
, DECL_P (t
) ? TREE_TYPE (t
) : t
);
606 direct-declarator [ type-qualifier-list(opt) assignment-expression(opt) ]
607 direct-declarator [ static type-qualifier-list(opt) assignment-expression(opt)]
608 direct-declarator [ type-qualifier-list static assignment-expression ]
609 direct-declarator [ type-qualifier-list * ]
610 direct-declarator ( parameter-type-list )
611 direct-declarator ( identifier-list(opt) ) */
614 pp_c_direct_declarator (c_pretty_printer
*pp
, tree t
)
616 switch (TREE_CODE (t
))
623 pp_c_space_for_pointer_operator (pp
, TREE_TYPE (t
));
624 pp_c_tree_decl_identifier (pp
, t
);
629 pp_abstract_declarator (pp
, TREE_TYPE (t
));
633 pp_parameter_list (pp
, t
);
634 pp_abstract_declarator (pp
, TREE_TYPE (t
));
638 pp_c_space_for_pointer_operator (pp
, TREE_TYPE (TREE_TYPE (t
)));
639 pp_c_tree_decl_identifier (pp
, t
);
640 if (pp_c_base (pp
)->flags
& pp_c_flag_abstract
)
641 pp_abstract_declarator (pp
, TREE_TYPE (t
));
644 pp_parameter_list (pp
, t
);
645 pp_abstract_declarator (pp
, TREE_TYPE (TREE_TYPE (t
)));
657 pp_unsupported_tree (pp
, t
);
664 pointer(opt) direct-declarator */
667 pp_c_declarator (c_pretty_printer
*pp
, tree t
)
669 switch (TREE_CODE (t
))
685 pp_direct_declarator (pp
, t
);
690 pp_unsupported_tree (pp
, t
);
696 declaration-specifiers init-declarator-list(opt) ; */
699 pp_c_declaration (c_pretty_printer
*pp
, tree t
)
701 pp_declaration_specifiers (pp
, t
);
702 pp_c_init_declarator (pp
, t
);
705 /* Pretty-print ATTRIBUTES using GNU C extension syntax. */
708 pp_c_attributes (c_pretty_printer
*pp
, tree attributes
)
710 if (attributes
== NULL_TREE
)
713 pp_c_identifier (pp
, "__attribute__");
714 pp_c_left_paren (pp
);
715 pp_c_left_paren (pp
);
716 for (; attributes
!= NULL_TREE
; attributes
= TREE_CHAIN (attributes
))
718 pp_tree_identifier (pp
, TREE_PURPOSE (attributes
));
719 if (TREE_VALUE (attributes
))
720 pp_c_call_argument_list (pp
, TREE_VALUE (attributes
));
722 if (TREE_CHAIN (attributes
))
723 pp_separate_with (pp
, ',');
725 pp_c_right_paren (pp
);
726 pp_c_right_paren (pp
);
729 /* function-definition:
730 declaration-specifiers declarator compound-statement */
733 pp_c_function_definition (c_pretty_printer
*pp
, tree t
)
735 pp_declaration_specifiers (pp
, t
);
736 pp_declarator (pp
, t
);
737 pp_needs_newline (pp
) = true;
738 pp_statement (pp
, DECL_SAVED_TREE (t
));
746 /* Print out a c-char. This is called solely for characters which are
747 in the *target* execution character set. We ought to convert them
748 back to the *host* execution character set before printing, but we
749 have no way to do this at present. A decent compromise is to print
750 all characters as if they were in the host execution character set,
751 and not attempt to recover any named escape characters, but render
752 all unprintables as octal escapes. If the host and target character
753 sets are the same, this produces relatively readable output. If they
754 are not the same, strings may appear as gibberish, but that's okay
755 (in fact, it may well be what the reader wants, e.g. if they are looking
756 to see if conversion to the target character set happened correctly).
758 A special case: we need to prefix \, ", and ' with backslashes. It is
759 correct to do so for the *host*'s \, ", and ', because the rest of the
760 file appears in the host character set. */
763 pp_c_char (c_pretty_printer
*pp
, int c
)
769 case '\\': pp_string (pp
, "\\\\"); break;
770 case '\'': pp_string (pp
, "\\\'"); break;
771 case '\"': pp_string (pp
, "\\\""); break;
772 default: pp_character (pp
, c
);
776 pp_scalar (pp
, "\\%03o", (unsigned) c
);
779 /* Print out a STRING literal. */
782 pp_c_string_literal (c_pretty_printer
*pp
, tree s
)
784 const char *p
= TREE_STRING_POINTER (s
);
785 int n
= TREE_STRING_LENGTH (s
) - 1;
788 for (i
= 0; i
< n
; ++i
)
789 pp_c_char (pp
, p
[i
]);
793 /* Pretty-print an INTEGER literal. */
796 pp_c_integer_constant (c_pretty_printer
*pp
, tree i
)
798 tree type
= TREE_TYPE (i
);
800 if (TREE_INT_CST_HIGH (i
) == 0)
801 pp_wide_integer (pp
, TREE_INT_CST_LOW (i
));
804 if (tree_int_cst_sgn (i
) < 0)
806 pp_character (pp
, '-');
807 i
= build_int_cst_wide (NULL_TREE
,
808 -TREE_INT_CST_LOW (i
),
809 ~TREE_INT_CST_HIGH (i
)
810 + !TREE_INT_CST_LOW (i
));
812 sprintf (pp_buffer (pp
)->digit_buffer
,
813 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
814 TREE_INT_CST_HIGH (i
), TREE_INT_CST_LOW (i
));
815 pp_string (pp
, pp_buffer (pp
)->digit_buffer
);
817 if (TYPE_UNSIGNED (type
))
818 pp_character (pp
, 'u');
819 if (type
== long_integer_type_node
|| type
== long_unsigned_type_node
)
820 pp_character (pp
, 'l');
821 else if (type
== long_long_integer_type_node
822 || type
== long_long_unsigned_type_node
)
823 pp_string (pp
, "ll");
826 /* Print out a CHARACTER literal. */
829 pp_c_character_constant (c_pretty_printer
*pp
, tree c
)
831 tree type
= TREE_TYPE (c
);
832 if (type
== wchar_type_node
)
833 pp_character (pp
, 'L');
835 if (host_integerp (c
, TYPE_UNSIGNED (type
)))
836 pp_c_char (pp
, tree_low_cst (c
, TYPE_UNSIGNED (type
)));
838 pp_scalar (pp
, "\\x%x", (unsigned) TREE_INT_CST_LOW (c
));
842 /* Print out a BOOLEAN literal. */
845 pp_c_bool_constant (c_pretty_printer
*pp
, tree b
)
847 if (b
== boolean_false_node
)
849 if (c_dialect_cxx ())
850 pp_c_identifier (pp
, "false");
851 else if (flag_isoc99
)
852 pp_c_identifier (pp
, "_False");
854 pp_unsupported_tree (pp
, b
);
856 else if (b
== boolean_true_node
)
858 if (c_dialect_cxx ())
859 pp_c_identifier (pp
, "true");
860 else if (flag_isoc99
)
861 pp_c_identifier (pp
, "_True");
863 pp_unsupported_tree (pp
, b
);
865 else if (TREE_CODE (b
) == INTEGER_CST
)
866 pp_c_integer_constant (pp
, b
);
868 pp_unsupported_tree (pp
, b
);
871 /* Attempt to print out an ENUMERATOR. Return true on success. Else return
872 false; that means the value was obtained by a cast, in which case
873 print out the type-id part of the cast-expression -- the casted value
874 is then printed by pp_c_integer_literal. */
877 pp_c_enumeration_constant (c_pretty_printer
*pp
, tree e
)
879 bool value_is_named
= true;
880 tree type
= TREE_TYPE (e
);
883 /* Find the name of this constant. */
884 for (value
= TYPE_VALUES (type
);
885 value
!= NULL_TREE
&& !tree_int_cst_equal (TREE_VALUE (value
), e
);
886 value
= TREE_CHAIN (value
))
889 if (value
!= NULL_TREE
)
890 pp_id_expression (pp
, TREE_PURPOSE (value
));
893 /* Value must have been cast. */
894 pp_c_type_cast (pp
, type
);
895 value_is_named
= false;
898 return value_is_named
;
901 /* Print out a REAL value as a decimal-floating-constant. */
904 pp_c_floating_constant (c_pretty_printer
*pp
, tree r
)
906 real_to_decimal (pp_buffer (pp
)->digit_buffer
, &TREE_REAL_CST (r
),
907 sizeof (pp_buffer (pp
)->digit_buffer
), 0, 1);
908 pp_string (pp
, pp_buffer(pp
)->digit_buffer
);
909 if (TREE_TYPE (r
) == float_type_node
)
910 pp_character (pp
, 'f');
911 else if (TREE_TYPE (r
) == long_double_type_node
)
912 pp_character (pp
, 'l');
913 else if (TREE_TYPE (r
) == dfloat128_type_node
)
914 pp_string (pp
, "dl");
915 else if (TREE_TYPE (r
) == dfloat64_type_node
)
916 pp_string (pp
, "dd");
917 else if (TREE_TYPE (r
) == dfloat32_type_node
)
918 pp_string (pp
, "df");
921 /* Pretty-print a compound literal expression. GNU extensions include
925 pp_c_compound_literal (c_pretty_printer
*pp
, tree e
)
927 tree type
= TREE_TYPE (e
);
928 pp_c_type_cast (pp
, type
);
930 switch (TREE_CODE (type
))
937 pp_c_brace_enclosed_initializer_list (pp
, e
);
941 pp_unsupported_tree (pp
, e
);
950 character-constant */
953 pp_c_constant (c_pretty_printer
*pp
, tree e
)
955 const enum tree_code code
= TREE_CODE (e
);
961 tree type
= TREE_TYPE (e
);
962 if (type
== boolean_type_node
)
963 pp_c_bool_constant (pp
, e
);
964 else if (type
== char_type_node
)
965 pp_c_character_constant (pp
, e
);
966 else if (TREE_CODE (type
) == ENUMERAL_TYPE
967 && pp_c_enumeration_constant (pp
, e
))
970 pp_c_integer_constant (pp
, e
);
975 pp_c_floating_constant (pp
, e
);
979 pp_c_string_literal (pp
, e
);
983 pp_unsupported_tree (pp
, e
);
988 /* Pretty-print an IDENTIFIER_NODE, preceded by whitespace is necessary. */
991 pp_c_identifier (c_pretty_printer
*pp
, const char *id
)
993 pp_c_maybe_whitespace (pp
);
994 pp_identifier (pp
, id
);
995 pp_base (pp
)->padding
= pp_before
;
998 /* Pretty-print a C primary-expression.
1006 pp_c_primary_expression (c_pretty_printer
*pp
, tree e
)
1008 switch (TREE_CODE (e
))
1016 pp_c_tree_decl_identifier (pp
, e
);
1019 case IDENTIFIER_NODE
:
1020 pp_c_tree_identifier (pp
, e
);
1024 pp_c_identifier (pp
, "<erroneous-expression>");
1028 pp_c_identifier (pp
, "<return-value>");
1034 pp_c_constant (pp
, e
);
1038 pp_c_identifier (pp
, "__builtin_memcpy");
1039 pp_c_left_paren (pp
);
1041 pp_primary_expression (pp
, TREE_OPERAND (e
, 0));
1042 pp_separate_with (pp
, ',');
1044 pp_initializer (pp
, TREE_OPERAND (e
, 1));
1045 if (TREE_OPERAND (e
, 2))
1047 pp_separate_with (pp
, ',');
1048 pp_c_expression (pp
, TREE_OPERAND (e
, 2));
1050 pp_c_right_paren (pp
);
1054 /* FIXME: Make sure we won't get into an infinie loop. */
1055 pp_c_left_paren (pp
);
1056 pp_expression (pp
, e
);
1057 pp_c_right_paren (pp
);
1062 /* Print out a C initializer -- also support C compound-literals.
1064 assignment-expression:
1065 { initializer-list }
1066 { initializer-list , } */
1069 pp_c_initializer (c_pretty_printer
*pp
, tree e
)
1071 if (TREE_CODE (e
) == CONSTRUCTOR
)
1072 pp_c_brace_enclosed_initializer_list (pp
, e
);
1074 pp_expression (pp
, e
);
1079 declarator = initializer */
1082 pp_c_init_declarator (c_pretty_printer
*pp
, tree t
)
1084 pp_declarator (pp
, t
);
1085 /* We don't want to output function definitions here. There are handled
1086 elsewhere (and the syntactic form is bogus anyway). */
1087 if (TREE_CODE (t
) != FUNCTION_DECL
&& DECL_INITIAL (t
))
1089 tree init
= DECL_INITIAL (t
);
1090 /* This C++ bit is handled here because it is easier to do so.
1091 In templates, the C++ parser builds a TREE_LIST for a
1092 direct-initialization; the TREE_PURPOSE is the variable to
1093 initialize and the TREE_VALUE is the initializer. */
1094 if (TREE_CODE (init
) == TREE_LIST
)
1096 pp_c_left_paren (pp
);
1097 pp_expression (pp
, TREE_VALUE (init
));
1098 pp_right_paren (pp
);
1105 pp_c_initializer (pp
, init
);
1110 /* initializer-list:
1111 designation(opt) initializer
1112 initializer-list , designation(opt) initializer
1119 designator-list designator
1122 [ constant-expression ]
1126 pp_c_initializer_list (c_pretty_printer
*pp
, tree e
)
1128 tree type
= TREE_TYPE (e
);
1129 const enum tree_code code
= TREE_CODE (type
);
1137 tree init
= TREE_OPERAND (e
, 0);
1138 for (; init
!= NULL_TREE
; init
= TREE_CHAIN (init
))
1140 if (code
== RECORD_TYPE
|| code
== UNION_TYPE
)
1143 pp_c_primary_expression (pp
, TREE_PURPOSE (init
));
1147 pp_c_left_bracket (pp
);
1148 if (TREE_PURPOSE (init
))
1149 pp_c_constant (pp
, TREE_PURPOSE (init
));
1150 pp_c_right_bracket (pp
);
1152 pp_c_whitespace (pp
);
1154 pp_c_whitespace (pp
);
1155 pp_initializer (pp
, TREE_VALUE (init
));
1156 if (TREE_CHAIN (init
))
1157 pp_separate_with (pp
, ',');
1163 if (TREE_CODE (e
) == VECTOR_CST
)
1164 pp_c_expression_list (pp
, TREE_VECTOR_CST_ELTS (e
));
1165 else if (TREE_CODE (e
) == CONSTRUCTOR
)
1166 pp_c_constructor_elts (pp
, CONSTRUCTOR_ELTS (e
));
1172 if (TREE_CODE (e
) == CONSTRUCTOR
)
1173 pp_c_constructor_elts (pp
, CONSTRUCTOR_ELTS (e
));
1174 else if (TREE_CODE (e
) == COMPLEX_CST
|| TREE_CODE (e
) == COMPLEX_EXPR
)
1176 const bool cst
= TREE_CODE (e
) == COMPLEX_CST
;
1177 pp_expression (pp
, cst
? TREE_REALPART (e
) : TREE_OPERAND (e
, 0));
1178 pp_separate_with (pp
, ',');
1179 pp_expression (pp
, cst
? TREE_IMAGPART (e
) : TREE_OPERAND (e
, 1));
1189 pp_unsupported_tree (pp
, type
);
1192 /* Pretty-print a brace-enclosed initializer-list. */
1195 pp_c_brace_enclosed_initializer_list (c_pretty_printer
*pp
, tree l
)
1197 pp_c_left_brace (pp
);
1198 pp_c_initializer_list (pp
, l
);
1199 pp_c_right_brace (pp
);
1203 /* This is a convenient function, used to bridge gap between C and C++
1210 pp_c_id_expression (c_pretty_printer
*pp
, tree t
)
1212 switch (TREE_CODE (t
))
1221 pp_c_tree_decl_identifier (pp
, t
);
1224 case IDENTIFIER_NODE
:
1225 pp_c_tree_identifier (pp
, t
);
1229 pp_unsupported_tree (pp
, t
);
1234 /* postfix-expression:
1236 postfix-expression [ expression ]
1237 postfix-expression ( argument-expression-list(opt) )
1238 postfix-expression . identifier
1239 postfix-expression -> identifier
1240 postfix-expression ++
1241 postfix-expression --
1242 ( type-name ) { initializer-list }
1243 ( type-name ) { initializer-list , } */
1246 pp_c_postfix_expression (c_pretty_printer
*pp
, tree e
)
1248 enum tree_code code
= TREE_CODE (e
);
1251 case POSTINCREMENT_EXPR
:
1252 case POSTDECREMENT_EXPR
:
1253 pp_postfix_expression (pp
, TREE_OPERAND (e
, 0));
1254 pp_identifier (pp
, code
== POSTINCREMENT_EXPR
? "++" : "--");
1258 pp_postfix_expression (pp
, TREE_OPERAND (e
, 0));
1259 pp_c_left_bracket (pp
);
1260 pp_expression (pp
, TREE_OPERAND (e
, 1));
1261 pp_c_right_bracket (pp
);
1265 pp_postfix_expression (pp
, TREE_OPERAND (e
, 0));
1266 pp_c_call_argument_list (pp
, TREE_OPERAND (e
, 1));
1269 case UNORDERED_EXPR
:
1270 pp_c_identifier (pp
, flag_isoc99
1272 : "__builtin_isunordered");
1276 pp_c_identifier (pp
, flag_isoc99
1278 : "!__builtin_isunordered");
1282 pp_c_identifier (pp
, flag_isoc99
1284 : "!__builtin_isgreaterequal");
1288 pp_c_identifier (pp
, flag_isoc99
1290 : "!__builtin_isgreater");
1294 pp_c_identifier (pp
, flag_isoc99
1296 : "!__builtin_islessequal");
1300 pp_c_identifier (pp
, flag_isoc99
1302 : "!__builtin_isless");
1306 pp_c_identifier (pp
, flag_isoc99
1308 : "!__builtin_islessgreater");
1312 pp_c_identifier (pp
, flag_isoc99
1314 : "__builtin_islessgreater");
1318 pp_c_left_paren (pp
);
1319 pp_expression (pp
, TREE_OPERAND (e
, 0));
1320 pp_separate_with (pp
, ',');
1321 pp_expression (pp
, TREE_OPERAND (e
, 1));
1322 pp_c_right_paren (pp
);
1326 pp_c_identifier (pp
, "__builtin_abs");
1327 pp_c_left_paren (pp
);
1328 pp_expression (pp
, TREE_OPERAND (e
, 0));
1329 pp_c_right_paren (pp
);
1334 tree object
= TREE_OPERAND (e
, 0);
1335 if (TREE_CODE (object
) == INDIRECT_REF
)
1337 pp_postfix_expression (pp
, TREE_OPERAND (object
, 0));
1342 pp_postfix_expression (pp
, object
);
1345 pp_expression (pp
, TREE_OPERAND (e
, 1));
1352 pp_c_compound_literal (pp
, e
);
1355 case COMPOUND_LITERAL_EXPR
:
1356 e
= DECL_INITIAL (COMPOUND_LITERAL_EXPR_DECL (e
));
1359 pp_initializer (pp
, e
);
1363 pp_c_identifier (pp
, "__builtin_va_arg");
1364 pp_c_left_paren (pp
);
1365 pp_assignment_expression (pp
, TREE_OPERAND (e
, 0));
1366 pp_separate_with (pp
, ',');
1367 pp_type_id (pp
, TREE_TYPE (e
));
1368 pp_c_right_paren (pp
);
1372 if (TREE_CODE (TREE_OPERAND (e
, 0)) == FUNCTION_DECL
)
1374 pp_c_id_expression (pp
, TREE_OPERAND (e
, 0));
1377 /* else fall through. */
1380 pp_primary_expression (pp
, e
);
1385 /* Print out an expression-list; E is expected to be a TREE_LIST. */
1388 pp_c_expression_list (c_pretty_printer
*pp
, tree e
)
1390 for (; e
!= NULL_TREE
; e
= TREE_CHAIN (e
))
1392 pp_expression (pp
, TREE_VALUE (e
));
1394 pp_separate_with (pp
, ',');
1398 /* Print out V, which contains the elements of a constructor. */
1401 pp_c_constructor_elts (c_pretty_printer
*pp
, VEC(constructor_elt
,gc
) *v
)
1403 unsigned HOST_WIDE_INT ix
;
1406 FOR_EACH_CONSTRUCTOR_VALUE (v
, ix
, value
)
1408 pp_expression (pp
, value
);
1409 if (ix
!= VEC_length (constructor_elt
, v
) - 1)
1410 pp_separate_with (pp
, ',');
1414 /* Print out an expression-list in parens, as in a function call. */
1417 pp_c_call_argument_list (c_pretty_printer
*pp
, tree t
)
1419 pp_c_left_paren (pp
);
1420 if (t
&& TREE_CODE (t
) == TREE_LIST
)
1421 pp_c_expression_list (pp
, t
);
1422 pp_c_right_paren (pp
);
1425 /* unary-expression:
1429 unary-operator cast-expression
1430 sizeof unary-expression
1433 unary-operator: one of
1438 __alignof__ unary-expression
1439 __alignof__ ( type-id )
1440 __real__ unary-expression
1441 __imag__ unary-expression */
1444 pp_c_unary_expression (c_pretty_printer
*pp
, tree e
)
1446 enum tree_code code
= TREE_CODE (e
);
1449 case PREINCREMENT_EXPR
:
1450 case PREDECREMENT_EXPR
:
1451 pp_identifier (pp
, code
== PREINCREMENT_EXPR
? "++" : "--");
1452 pp_c_unary_expression (pp
, TREE_OPERAND (e
, 0));
1459 case TRUTH_NOT_EXPR
:
1461 /* String literal are used by address. */
1462 if (code
== ADDR_EXPR
&& TREE_CODE (TREE_OPERAND (e
, 0)) != STRING_CST
)
1464 else if (code
== INDIRECT_REF
)
1466 else if (code
== NEGATE_EXPR
)
1468 else if (code
== BIT_NOT_EXPR
|| code
== CONJ_EXPR
)
1470 else if (code
== TRUTH_NOT_EXPR
)
1471 pp_exclamation (pp
);
1472 pp_c_cast_expression (pp
, TREE_OPERAND (e
, 0));
1477 pp_c_identifier (pp
, code
== REALPART_EXPR
? "__real__" : "__imag__");
1478 pp_c_whitespace (pp
);
1479 pp_unary_expression (pp
, TREE_OPERAND (e
, 0));
1483 pp_postfix_expression (pp
, e
);
1490 ( type-name ) cast-expression */
1493 pp_c_cast_expression (c_pretty_printer
*pp
, tree e
)
1495 switch (TREE_CODE (e
))
1498 case FIX_TRUNC_EXPR
:
1501 pp_c_type_cast (pp
, TREE_TYPE (e
));
1502 pp_c_cast_expression (pp
, TREE_OPERAND (e
, 0));
1506 pp_unary_expression (pp
, e
);
1510 /* multiplicative-expression:
1512 multiplicative-expression * cast-expression
1513 multiplicative-expression / cast-expression
1514 multiplicative-expression % cast-expression */
1517 pp_c_multiplicative_expression (c_pretty_printer
*pp
, tree e
)
1519 enum tree_code code
= TREE_CODE (e
);
1523 case TRUNC_DIV_EXPR
:
1524 case TRUNC_MOD_EXPR
:
1525 pp_multiplicative_expression (pp
, TREE_OPERAND (e
, 0));
1526 pp_c_whitespace (pp
);
1527 if (code
== MULT_EXPR
)
1529 else if (code
== TRUNC_DIV_EXPR
)
1533 pp_c_whitespace (pp
);
1534 pp_c_cast_expression (pp
, TREE_OPERAND (e
, 1));
1538 pp_c_cast_expression (pp
, e
);
1543 /* additive-expression:
1544 multiplicative-expression
1545 additive-expression + multiplicative-expression
1546 additive-expression - multiplicative-expression */
1549 pp_c_additive_expression (c_pretty_printer
*pp
, tree e
)
1551 enum tree_code code
= TREE_CODE (e
);
1556 pp_c_additive_expression (pp
, TREE_OPERAND (e
, 0));
1557 pp_c_whitespace (pp
);
1558 if (code
== PLUS_EXPR
)
1562 pp_c_whitespace (pp
);
1563 pp_multiplicative_expression (pp
, TREE_OPERAND (e
, 1));
1567 pp_multiplicative_expression (pp
, e
);
1572 /* additive-expression:
1574 shift-expression << additive-expression
1575 shift-expression >> additive-expression */
1578 pp_c_shift_expression (c_pretty_printer
*pp
, tree e
)
1580 enum tree_code code
= TREE_CODE (e
);
1585 pp_c_shift_expression (pp
, TREE_OPERAND (e
, 0));
1586 pp_c_whitespace (pp
);
1587 pp_identifier (pp
, code
== LSHIFT_EXPR
? "<<" : ">>");
1588 pp_c_whitespace (pp
);
1589 pp_c_additive_expression (pp
, TREE_OPERAND (e
, 1));
1593 pp_c_additive_expression (pp
, e
);
1597 /* relational-expression:
1599 relational-expression < shift-expression
1600 relational-expression > shift-expression
1601 relational-expression <= shift-expression
1602 relational-expression >= shift-expression */
1605 pp_c_relational_expression (c_pretty_printer
*pp
, tree e
)
1607 enum tree_code code
= TREE_CODE (e
);
1614 pp_c_relational_expression (pp
, TREE_OPERAND (e
, 0));
1615 pp_c_whitespace (pp
);
1616 if (code
== LT_EXPR
)
1618 else if (code
== GT_EXPR
)
1620 else if (code
== LE_EXPR
)
1621 pp_identifier (pp
, "<=");
1622 else if (code
== GE_EXPR
)
1623 pp_identifier (pp
, ">=");
1624 pp_c_whitespace (pp
);
1625 pp_c_shift_expression (pp
, TREE_OPERAND (e
, 1));
1629 pp_c_shift_expression (pp
, e
);
1634 /* equality-expression:
1635 relational-expression
1636 equality-expression == relational-expression
1637 equality-equality != relational-expression */
1640 pp_c_equality_expression (c_pretty_printer
*pp
, tree e
)
1642 enum tree_code code
= TREE_CODE (e
);
1647 pp_c_equality_expression (pp
, TREE_OPERAND (e
, 0));
1648 pp_c_whitespace (pp
);
1649 pp_identifier (pp
, code
== EQ_EXPR
? "==" : "!=");
1650 pp_c_whitespace (pp
);
1651 pp_c_relational_expression (pp
, TREE_OPERAND (e
, 1));
1655 pp_c_relational_expression (pp
, e
);
1662 AND-expression & equality-equality */
1665 pp_c_and_expression (c_pretty_printer
*pp
, tree e
)
1667 if (TREE_CODE (e
) == BIT_AND_EXPR
)
1669 pp_c_and_expression (pp
, TREE_OPERAND (e
, 0));
1670 pp_c_whitespace (pp
);
1672 pp_c_whitespace (pp
);
1673 pp_c_equality_expression (pp
, TREE_OPERAND (e
, 1));
1676 pp_c_equality_expression (pp
, e
);
1679 /* exclusive-OR-expression:
1681 exclusive-OR-expression ^ AND-expression */
1684 pp_c_exclusive_or_expression (c_pretty_printer
*pp
, tree e
)
1686 if (TREE_CODE (e
) == BIT_XOR_EXPR
)
1688 pp_c_exclusive_or_expression (pp
, TREE_OPERAND (e
, 0));
1689 pp_c_maybe_whitespace (pp
);
1691 pp_c_whitespace (pp
);
1692 pp_c_and_expression (pp
, TREE_OPERAND (e
, 1));
1695 pp_c_and_expression (pp
, e
);
1698 /* inclusive-OR-expression:
1699 exclusive-OR-expression
1700 inclusive-OR-expression | exclusive-OR-expression */
1703 pp_c_inclusive_or_expression (c_pretty_printer
*pp
, tree e
)
1705 if (TREE_CODE (e
) == BIT_IOR_EXPR
)
1707 pp_c_exclusive_or_expression (pp
, TREE_OPERAND (e
, 0));
1708 pp_c_whitespace (pp
);
1710 pp_c_whitespace (pp
);
1711 pp_c_exclusive_or_expression (pp
, TREE_OPERAND (e
, 1));
1714 pp_c_exclusive_or_expression (pp
, e
);
1717 /* logical-AND-expression:
1718 inclusive-OR-expression
1719 logical-AND-expression && inclusive-OR-expression */
1722 pp_c_logical_and_expression (c_pretty_printer
*pp
, tree e
)
1724 if (TREE_CODE (e
) == TRUTH_ANDIF_EXPR
)
1726 pp_c_logical_and_expression (pp
, TREE_OPERAND (e
, 0));
1727 pp_c_whitespace (pp
);
1728 pp_identifier (pp
, "&&");
1729 pp_c_whitespace (pp
);
1730 pp_c_inclusive_or_expression (pp
, TREE_OPERAND (e
, 1));
1733 pp_c_inclusive_or_expression (pp
, e
);
1736 /* logical-OR-expression:
1737 logical-AND-expression
1738 logical-OR-expression || logical-AND-expression */
1741 pp_c_logical_or_expression (c_pretty_printer
*pp
, tree e
)
1743 if (TREE_CODE (e
) == TRUTH_ORIF_EXPR
)
1745 pp_c_logical_or_expression (pp
, TREE_OPERAND (e
, 0));
1746 pp_c_whitespace (pp
);
1747 pp_identifier (pp
, "||");
1748 pp_c_whitespace (pp
);
1749 pp_c_logical_and_expression (pp
, TREE_OPERAND (e
, 1));
1752 pp_c_logical_and_expression (pp
, e
);
1755 /* conditional-expression:
1756 logical-OR-expression
1757 logical-OR-expression ? expression : conditional-expression */
1760 pp_c_conditional_expression (c_pretty_printer
*pp
, tree e
)
1762 if (TREE_CODE (e
) == COND_EXPR
)
1764 pp_c_logical_or_expression (pp
, TREE_OPERAND (e
, 0));
1765 pp_c_whitespace (pp
);
1767 pp_c_whitespace (pp
);
1768 pp_expression (pp
, TREE_OPERAND (e
, 1));
1769 pp_c_whitespace (pp
);
1771 pp_c_whitespace (pp
);
1772 pp_c_conditional_expression (pp
, TREE_OPERAND (e
, 2));
1775 pp_c_logical_or_expression (pp
, e
);
1779 /* assignment-expression:
1780 conditional-expression
1781 unary-expression assignment-operator assignment-expression
1783 assignment-expression: one of
1784 = *= /= %= += -= >>= <<= &= ^= |= */
1787 pp_c_assignment_expression (c_pretty_printer
*pp
, tree e
)
1789 if (TREE_CODE (e
) == MODIFY_EXPR
|| TREE_CODE (e
) == INIT_EXPR
)
1791 pp_c_unary_expression (pp
, TREE_OPERAND (e
, 0));
1792 pp_c_whitespace (pp
);
1795 pp_c_expression (pp
, TREE_OPERAND (e
, 1));
1798 pp_c_conditional_expression (pp
, e
);
1802 assignment-expression
1803 expression , assignment-expression
1805 Implementation note: instead of going through the usual recursion
1806 chain, I take the liberty of dispatching nodes to the appropriate
1807 functions. This makes some redundancy, but it worths it. That also
1808 prevents a possible infinite recursion between pp_c_primary_expression ()
1809 and pp_c_expression (). */
1812 pp_c_expression (c_pretty_printer
*pp
, tree e
)
1814 switch (TREE_CODE (e
))
1817 pp_c_integer_constant (pp
, e
);
1821 pp_c_floating_constant (pp
, e
);
1825 pp_c_string_literal (pp
, e
);
1828 case IDENTIFIER_NODE
:
1837 pp_primary_expression (pp
, e
);
1840 case POSTINCREMENT_EXPR
:
1841 case POSTDECREMENT_EXPR
:
1849 case UNORDERED_EXPR
:
1858 case COMPOUND_LITERAL_EXPR
:
1860 pp_postfix_expression (pp
, e
);
1868 case TRUTH_NOT_EXPR
:
1869 case PREINCREMENT_EXPR
:
1870 case PREDECREMENT_EXPR
:
1873 pp_c_unary_expression (pp
, e
);
1877 case FIX_TRUNC_EXPR
:
1880 pp_c_cast_expression (pp
, e
);
1884 case TRUNC_MOD_EXPR
:
1885 case TRUNC_DIV_EXPR
:
1886 pp_multiplicative_expression (pp
, e
);
1891 pp_c_shift_expression (pp
, e
);
1898 pp_c_relational_expression (pp
, e
);
1902 pp_c_and_expression (pp
, e
);
1906 pp_c_exclusive_or_expression (pp
, e
);
1910 pp_c_inclusive_or_expression (pp
, e
);
1913 case TRUTH_ANDIF_EXPR
:
1914 pp_c_logical_and_expression (pp
, e
);
1917 case TRUTH_ORIF_EXPR
:
1918 pp_c_logical_or_expression (pp
, e
);
1923 pp_c_equality_expression (pp
, e
);
1927 pp_conditional_expression (pp
, e
);
1932 pp_c_additive_expression (pp
, e
);
1937 pp_assignment_expression (pp
, e
);
1941 pp_c_left_paren (pp
);
1942 pp_expression (pp
, TREE_OPERAND (e
, 0));
1943 pp_separate_with (pp
, ',');
1944 pp_assignment_expression (pp
, TREE_OPERAND (e
, 1));
1945 pp_c_right_paren (pp
);
1948 case NON_LVALUE_EXPR
:
1950 pp_expression (pp
, TREE_OPERAND (e
, 0));
1954 pp_postfix_expression (pp
, TREE_OPERAND (e
, 1));
1958 pp_unsupported_tree (pp
, e
);
1968 pp_c_statement (c_pretty_printer
*pp
, tree stmt
)
1973 if (pp_needs_newline (pp
))
1974 pp_newline_and_indent (pp
, 0);
1976 dump_generic_node (pp_base (pp
), stmt
, pp_indentation (pp
), 0, true);
1980 /* Initialize the PRETTY-PRINTER for handling C codes. */
1983 pp_c_pretty_printer_init (c_pretty_printer
*pp
)
1985 pp
->offset_list
= 0;
1987 pp
->declaration
= pp_c_declaration
;
1988 pp
->declaration_specifiers
= pp_c_declaration_specifiers
;
1989 pp
->declarator
= pp_c_declarator
;
1990 pp
->direct_declarator
= pp_c_direct_declarator
;
1991 pp
->type_specifier_seq
= pp_c_specifier_qualifier_list
;
1992 pp
->abstract_declarator
= pp_c_abstract_declarator
;
1993 pp
->direct_abstract_declarator
= pp_c_direct_abstract_declarator
;
1994 pp
->ptr_operator
= pp_c_pointer
;
1995 pp
->parameter_list
= pp_c_parameter_type_list
;
1996 pp
->type_id
= pp_c_type_id
;
1997 pp
->simple_type_specifier
= pp_c_type_specifier
;
1998 pp
->function_specifier
= pp_c_function_specifier
;
1999 pp
->storage_class_specifier
= pp_c_storage_class_specifier
;
2001 pp
->statement
= pp_c_statement
;
2003 pp
->constant
= pp_c_constant
;
2004 pp
->id_expression
= pp_c_id_expression
;
2005 pp
->primary_expression
= pp_c_primary_expression
;
2006 pp
->postfix_expression
= pp_c_postfix_expression
;
2007 pp
->unary_expression
= pp_c_unary_expression
;
2008 pp
->initializer
= pp_c_initializer
;
2009 pp
->multiplicative_expression
= pp_c_multiplicative_expression
;
2010 pp
->conditional_expression
= pp_c_conditional_expression
;
2011 pp
->assignment_expression
= pp_c_assignment_expression
;
2012 pp
->expression
= pp_c_expression
;
2016 /* Print the tree T in full, on file FILE. */
2019 print_c_tree (FILE *file
, tree t
)
2021 static c_pretty_printer pp_rec
;
2022 static bool initialized
= 0;
2023 c_pretty_printer
*pp
= &pp_rec
;
2028 pp_construct (pp_base (pp
), NULL
, 0);
2029 pp_c_pretty_printer_init (pp
);
2030 pp_needs_newline (pp
) = true;
2032 pp_base (pp
)->buffer
->stream
= file
;
2034 pp_statement (pp
, t
);
2040 /* Print the tree T in full, on stderr. */
2043 debug_c_tree (tree t
)
2045 print_c_tree (stderr
, t
);
2046 fputc ('\n', stderr
);
2049 /* Output the DECL_NAME of T. If T has no DECL_NAME, output a string made
2050 up of T's memory address. */
2053 pp_c_tree_decl_identifier (c_pretty_printer
*pp
, tree t
)
2057 gcc_assert (DECL_P (t
));
2060 name
= IDENTIFIER_POINTER (DECL_NAME (t
));
2063 static char xname
[8];
2064 sprintf (xname
, "<U%4x>", ((unsigned)((unsigned long)(t
) & 0xffff)));
2068 pp_c_identifier (pp
, name
);