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
)))
525 tree maxval
= TYPE_MAX_VALUE (TYPE_DOMAIN (t
));
526 tree type
= TREE_TYPE (maxval
);
528 if (host_integerp (maxval
, 0))
529 pp_wide_integer (pp
, tree_low_cst (maxval
, 0) + 1);
531 pp_expression (pp
, fold (build2 (PLUS_EXPR
, type
, maxval
,
532 build_int_cst (type
, 1))));
534 pp_c_right_bracket (pp
);
535 pp_direct_abstract_declarator (pp
, TREE_TYPE (t
));
538 case IDENTIFIER_NODE
:
552 pp_unsupported_tree (pp
, t
);
558 specifier-qualifier-list abstract-declarator(opt) */
561 pp_c_type_id (c_pretty_printer
*pp
, tree t
)
563 pp_c_specifier_qualifier_list (pp
, t
);
564 pp_abstract_declarator (pp
, t
);
567 /* storage-class-specifier:
575 pp_c_storage_class_specifier (c_pretty_printer
*pp
, tree t
)
577 if (TREE_CODE (t
) == TYPE_DECL
)
578 pp_c_identifier (pp
, "typedef");
581 if (DECL_REGISTER (t
))
582 pp_c_identifier (pp
, "register");
583 else if (TREE_STATIC (t
) && TREE_CODE (t
) == VAR_DECL
)
584 pp_c_identifier (pp
, "static");
588 /* function-specifier:
592 pp_c_function_specifier (c_pretty_printer
*pp
, tree t
)
594 if (TREE_CODE (t
) == FUNCTION_DECL
&& DECL_DECLARED_INLINE_P (t
))
595 pp_c_identifier (pp
, "inline");
598 /* declaration-specifiers:
599 storage-class-specifier declaration-specifiers(opt)
600 type-specifier declaration-specifiers(opt)
601 type-qualifier declaration-specifiers(opt)
602 function-specifier declaration-specifiers(opt) */
605 pp_c_declaration_specifiers (c_pretty_printer
*pp
, tree t
)
607 pp_storage_class_specifier (pp
, t
);
608 pp_function_specifier (pp
, t
);
609 pp_c_specifier_qualifier_list (pp
, DECL_P (t
) ? TREE_TYPE (t
) : t
);
615 direct-declarator [ type-qualifier-list(opt) assignment-expression(opt) ]
616 direct-declarator [ static type-qualifier-list(opt) assignment-expression(opt)]
617 direct-declarator [ type-qualifier-list static assignment-expression ]
618 direct-declarator [ type-qualifier-list * ]
619 direct-declarator ( parameter-type-list )
620 direct-declarator ( identifier-list(opt) ) */
623 pp_c_direct_declarator (c_pretty_printer
*pp
, tree t
)
625 switch (TREE_CODE (t
))
632 pp_c_space_for_pointer_operator (pp
, TREE_TYPE (t
));
633 pp_c_tree_decl_identifier (pp
, t
);
638 pp_abstract_declarator (pp
, TREE_TYPE (t
));
642 pp_parameter_list (pp
, t
);
643 pp_abstract_declarator (pp
, TREE_TYPE (t
));
647 pp_c_space_for_pointer_operator (pp
, TREE_TYPE (TREE_TYPE (t
)));
648 pp_c_tree_decl_identifier (pp
, t
);
649 if (pp_c_base (pp
)->flags
& pp_c_flag_abstract
)
650 pp_abstract_declarator (pp
, TREE_TYPE (t
));
653 pp_parameter_list (pp
, t
);
654 pp_abstract_declarator (pp
, TREE_TYPE (TREE_TYPE (t
)));
666 pp_unsupported_tree (pp
, t
);
673 pointer(opt) direct-declarator */
676 pp_c_declarator (c_pretty_printer
*pp
, tree t
)
678 switch (TREE_CODE (t
))
694 pp_direct_declarator (pp
, t
);
699 pp_unsupported_tree (pp
, t
);
705 declaration-specifiers init-declarator-list(opt) ; */
708 pp_c_declaration (c_pretty_printer
*pp
, tree t
)
710 pp_declaration_specifiers (pp
, t
);
711 pp_c_init_declarator (pp
, t
);
714 /* Pretty-print ATTRIBUTES using GNU C extension syntax. */
717 pp_c_attributes (c_pretty_printer
*pp
, tree attributes
)
719 if (attributes
== NULL_TREE
)
722 pp_c_identifier (pp
, "__attribute__");
723 pp_c_left_paren (pp
);
724 pp_c_left_paren (pp
);
725 for (; attributes
!= NULL_TREE
; attributes
= TREE_CHAIN (attributes
))
727 pp_tree_identifier (pp
, TREE_PURPOSE (attributes
));
728 if (TREE_VALUE (attributes
))
729 pp_c_call_argument_list (pp
, TREE_VALUE (attributes
));
731 if (TREE_CHAIN (attributes
))
732 pp_separate_with (pp
, ',');
734 pp_c_right_paren (pp
);
735 pp_c_right_paren (pp
);
738 /* function-definition:
739 declaration-specifiers declarator compound-statement */
742 pp_c_function_definition (c_pretty_printer
*pp
, tree t
)
744 pp_declaration_specifiers (pp
, t
);
745 pp_declarator (pp
, t
);
746 pp_needs_newline (pp
) = true;
747 pp_statement (pp
, DECL_SAVED_TREE (t
));
755 /* Print out a c-char. This is called solely for characters which are
756 in the *target* execution character set. We ought to convert them
757 back to the *host* execution character set before printing, but we
758 have no way to do this at present. A decent compromise is to print
759 all characters as if they were in the host execution character set,
760 and not attempt to recover any named escape characters, but render
761 all unprintables as octal escapes. If the host and target character
762 sets are the same, this produces relatively readable output. If they
763 are not the same, strings may appear as gibberish, but that's okay
764 (in fact, it may well be what the reader wants, e.g. if they are looking
765 to see if conversion to the target character set happened correctly).
767 A special case: we need to prefix \, ", and ' with backslashes. It is
768 correct to do so for the *host*'s \, ", and ', because the rest of the
769 file appears in the host character set. */
772 pp_c_char (c_pretty_printer
*pp
, int c
)
778 case '\\': pp_string (pp
, "\\\\"); break;
779 case '\'': pp_string (pp
, "\\\'"); break;
780 case '\"': pp_string (pp
, "\\\""); break;
781 default: pp_character (pp
, c
);
785 pp_scalar (pp
, "\\%03o", (unsigned) c
);
788 /* Print out a STRING literal. */
791 pp_c_string_literal (c_pretty_printer
*pp
, tree s
)
793 const char *p
= TREE_STRING_POINTER (s
);
794 int n
= TREE_STRING_LENGTH (s
) - 1;
797 for (i
= 0; i
< n
; ++i
)
798 pp_c_char (pp
, p
[i
]);
802 /* Pretty-print an INTEGER literal. */
805 pp_c_integer_constant (c_pretty_printer
*pp
, tree i
)
807 tree type
= TREE_TYPE (i
);
809 if (TREE_INT_CST_HIGH (i
) == 0)
810 pp_wide_integer (pp
, TREE_INT_CST_LOW (i
));
813 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (i
);
814 HOST_WIDE_INT high
= TREE_INT_CST_HIGH (i
);
815 if (tree_int_cst_sgn (i
) < 0)
817 pp_character (pp
, '-');
821 sprintf (pp_buffer (pp
)->digit_buffer
,
822 HOST_WIDE_INT_PRINT_DOUBLE_HEX
, high
, low
);
823 pp_string (pp
, pp_buffer (pp
)->digit_buffer
);
825 if (TYPE_UNSIGNED (type
))
826 pp_character (pp
, 'u');
827 if (type
== long_integer_type_node
|| type
== long_unsigned_type_node
)
828 pp_character (pp
, 'l');
829 else if (type
== long_long_integer_type_node
830 || type
== long_long_unsigned_type_node
)
831 pp_string (pp
, "ll");
834 /* Print out a CHARACTER literal. */
837 pp_c_character_constant (c_pretty_printer
*pp
, tree c
)
839 tree type
= TREE_TYPE (c
);
840 if (type
== wchar_type_node
)
841 pp_character (pp
, 'L');
843 if (host_integerp (c
, TYPE_UNSIGNED (type
)))
844 pp_c_char (pp
, tree_low_cst (c
, TYPE_UNSIGNED (type
)));
846 pp_scalar (pp
, "\\x%x", (unsigned) TREE_INT_CST_LOW (c
));
850 /* Print out a BOOLEAN literal. */
853 pp_c_bool_constant (c_pretty_printer
*pp
, tree b
)
855 if (b
== boolean_false_node
)
857 if (c_dialect_cxx ())
858 pp_c_identifier (pp
, "false");
859 else if (flag_isoc99
)
860 pp_c_identifier (pp
, "_False");
862 pp_unsupported_tree (pp
, b
);
864 else if (b
== boolean_true_node
)
866 if (c_dialect_cxx ())
867 pp_c_identifier (pp
, "true");
868 else if (flag_isoc99
)
869 pp_c_identifier (pp
, "_True");
871 pp_unsupported_tree (pp
, b
);
873 else if (TREE_CODE (b
) == INTEGER_CST
)
874 pp_c_integer_constant (pp
, b
);
876 pp_unsupported_tree (pp
, b
);
879 /* Attempt to print out an ENUMERATOR. Return true on success. Else return
880 false; that means the value was obtained by a cast, in which case
881 print out the type-id part of the cast-expression -- the casted value
882 is then printed by pp_c_integer_literal. */
885 pp_c_enumeration_constant (c_pretty_printer
*pp
, tree e
)
887 bool value_is_named
= true;
888 tree type
= TREE_TYPE (e
);
891 /* Find the name of this constant. */
892 for (value
= TYPE_VALUES (type
);
893 value
!= NULL_TREE
&& !tree_int_cst_equal (TREE_VALUE (value
), e
);
894 value
= TREE_CHAIN (value
))
897 if (value
!= NULL_TREE
)
898 pp_id_expression (pp
, TREE_PURPOSE (value
));
901 /* Value must have been cast. */
902 pp_c_type_cast (pp
, type
);
903 value_is_named
= false;
906 return value_is_named
;
909 /* Print out a REAL value as a decimal-floating-constant. */
912 pp_c_floating_constant (c_pretty_printer
*pp
, tree r
)
914 real_to_decimal (pp_buffer (pp
)->digit_buffer
, &TREE_REAL_CST (r
),
915 sizeof (pp_buffer (pp
)->digit_buffer
), 0, 1);
916 pp_string (pp
, pp_buffer(pp
)->digit_buffer
);
917 if (TREE_TYPE (r
) == float_type_node
)
918 pp_character (pp
, 'f');
919 else if (TREE_TYPE (r
) == long_double_type_node
)
920 pp_character (pp
, 'l');
921 else if (TREE_TYPE (r
) == dfloat128_type_node
)
922 pp_string (pp
, "dl");
923 else if (TREE_TYPE (r
) == dfloat64_type_node
)
924 pp_string (pp
, "dd");
925 else if (TREE_TYPE (r
) == dfloat32_type_node
)
926 pp_string (pp
, "df");
929 /* Pretty-print a compound literal expression. GNU extensions include
933 pp_c_compound_literal (c_pretty_printer
*pp
, tree e
)
935 tree type
= TREE_TYPE (e
);
936 pp_c_type_cast (pp
, type
);
938 switch (TREE_CODE (type
))
945 pp_c_brace_enclosed_initializer_list (pp
, e
);
949 pp_unsupported_tree (pp
, e
);
958 character-constant */
961 pp_c_constant (c_pretty_printer
*pp
, tree e
)
963 const enum tree_code code
= TREE_CODE (e
);
969 tree type
= TREE_TYPE (e
);
970 if (type
== boolean_type_node
)
971 pp_c_bool_constant (pp
, e
);
972 else if (type
== char_type_node
)
973 pp_c_character_constant (pp
, e
);
974 else if (TREE_CODE (type
) == ENUMERAL_TYPE
975 && pp_c_enumeration_constant (pp
, e
))
978 pp_c_integer_constant (pp
, e
);
983 pp_c_floating_constant (pp
, e
);
987 pp_c_string_literal (pp
, e
);
991 pp_unsupported_tree (pp
, e
);
996 /* Pretty-print an IDENTIFIER_NODE, preceded by whitespace is necessary. */
999 pp_c_identifier (c_pretty_printer
*pp
, const char *id
)
1001 pp_c_maybe_whitespace (pp
);
1002 pp_identifier (pp
, id
);
1003 pp_base (pp
)->padding
= pp_before
;
1006 /* Pretty-print a C primary-expression.
1014 pp_c_primary_expression (c_pretty_printer
*pp
, tree e
)
1016 switch (TREE_CODE (e
))
1024 pp_c_tree_decl_identifier (pp
, e
);
1027 case IDENTIFIER_NODE
:
1028 pp_c_tree_identifier (pp
, e
);
1032 pp_c_identifier (pp
, "<erroneous-expression>");
1036 pp_c_identifier (pp
, "<return-value>");
1042 pp_c_constant (pp
, e
);
1046 pp_c_identifier (pp
, "__builtin_memcpy");
1047 pp_c_left_paren (pp
);
1049 pp_primary_expression (pp
, TREE_OPERAND (e
, 0));
1050 pp_separate_with (pp
, ',');
1052 pp_initializer (pp
, TREE_OPERAND (e
, 1));
1053 if (TREE_OPERAND (e
, 2))
1055 pp_separate_with (pp
, ',');
1056 pp_c_expression (pp
, TREE_OPERAND (e
, 2));
1058 pp_c_right_paren (pp
);
1062 /* FIXME: Make sure we won't get into an infinie loop. */
1063 pp_c_left_paren (pp
);
1064 pp_expression (pp
, e
);
1065 pp_c_right_paren (pp
);
1070 /* Print out a C initializer -- also support C compound-literals.
1072 assignment-expression:
1073 { initializer-list }
1074 { initializer-list , } */
1077 pp_c_initializer (c_pretty_printer
*pp
, tree e
)
1079 if (TREE_CODE (e
) == CONSTRUCTOR
)
1080 pp_c_brace_enclosed_initializer_list (pp
, e
);
1082 pp_expression (pp
, e
);
1087 declarator = initializer */
1090 pp_c_init_declarator (c_pretty_printer
*pp
, tree t
)
1092 pp_declarator (pp
, t
);
1093 /* We don't want to output function definitions here. There are handled
1094 elsewhere (and the syntactic form is bogus anyway). */
1095 if (TREE_CODE (t
) != FUNCTION_DECL
&& DECL_INITIAL (t
))
1097 tree init
= DECL_INITIAL (t
);
1098 /* This C++ bit is handled here because it is easier to do so.
1099 In templates, the C++ parser builds a TREE_LIST for a
1100 direct-initialization; the TREE_PURPOSE is the variable to
1101 initialize and the TREE_VALUE is the initializer. */
1102 if (TREE_CODE (init
) == TREE_LIST
)
1104 pp_c_left_paren (pp
);
1105 pp_expression (pp
, TREE_VALUE (init
));
1106 pp_right_paren (pp
);
1113 pp_c_initializer (pp
, init
);
1118 /* initializer-list:
1119 designation(opt) initializer
1120 initializer-list , designation(opt) initializer
1127 designator-list designator
1130 [ constant-expression ]
1134 pp_c_initializer_list (c_pretty_printer
*pp
, tree e
)
1136 tree type
= TREE_TYPE (e
);
1137 const enum tree_code code
= TREE_CODE (type
);
1145 tree init
= TREE_OPERAND (e
, 0);
1146 for (; init
!= NULL_TREE
; init
= TREE_CHAIN (init
))
1148 if (code
== RECORD_TYPE
|| code
== UNION_TYPE
)
1151 pp_c_primary_expression (pp
, TREE_PURPOSE (init
));
1155 pp_c_left_bracket (pp
);
1156 if (TREE_PURPOSE (init
))
1157 pp_c_constant (pp
, TREE_PURPOSE (init
));
1158 pp_c_right_bracket (pp
);
1160 pp_c_whitespace (pp
);
1162 pp_c_whitespace (pp
);
1163 pp_initializer (pp
, TREE_VALUE (init
));
1164 if (TREE_CHAIN (init
))
1165 pp_separate_with (pp
, ',');
1171 if (TREE_CODE (e
) == VECTOR_CST
)
1172 pp_c_expression_list (pp
, TREE_VECTOR_CST_ELTS (e
));
1173 else if (TREE_CODE (e
) == CONSTRUCTOR
)
1174 pp_c_constructor_elts (pp
, CONSTRUCTOR_ELTS (e
));
1180 if (TREE_CODE (e
) == CONSTRUCTOR
)
1181 pp_c_constructor_elts (pp
, CONSTRUCTOR_ELTS (e
));
1182 else if (TREE_CODE (e
) == COMPLEX_CST
|| TREE_CODE (e
) == COMPLEX_EXPR
)
1184 const bool cst
= TREE_CODE (e
) == COMPLEX_CST
;
1185 pp_expression (pp
, cst
? TREE_REALPART (e
) : TREE_OPERAND (e
, 0));
1186 pp_separate_with (pp
, ',');
1187 pp_expression (pp
, cst
? TREE_IMAGPART (e
) : TREE_OPERAND (e
, 1));
1197 pp_unsupported_tree (pp
, type
);
1200 /* Pretty-print a brace-enclosed initializer-list. */
1203 pp_c_brace_enclosed_initializer_list (c_pretty_printer
*pp
, tree l
)
1205 pp_c_left_brace (pp
);
1206 pp_c_initializer_list (pp
, l
);
1207 pp_c_right_brace (pp
);
1211 /* This is a convenient function, used to bridge gap between C and C++
1218 pp_c_id_expression (c_pretty_printer
*pp
, tree t
)
1220 switch (TREE_CODE (t
))
1229 pp_c_tree_decl_identifier (pp
, t
);
1232 case IDENTIFIER_NODE
:
1233 pp_c_tree_identifier (pp
, t
);
1237 pp_unsupported_tree (pp
, t
);
1242 /* postfix-expression:
1244 postfix-expression [ expression ]
1245 postfix-expression ( argument-expression-list(opt) )
1246 postfix-expression . identifier
1247 postfix-expression -> identifier
1248 postfix-expression ++
1249 postfix-expression --
1250 ( type-name ) { initializer-list }
1251 ( type-name ) { initializer-list , } */
1254 pp_c_postfix_expression (c_pretty_printer
*pp
, tree e
)
1256 enum tree_code code
= TREE_CODE (e
);
1259 case POSTINCREMENT_EXPR
:
1260 case POSTDECREMENT_EXPR
:
1261 pp_postfix_expression (pp
, TREE_OPERAND (e
, 0));
1262 pp_identifier (pp
, code
== POSTINCREMENT_EXPR
? "++" : "--");
1266 pp_postfix_expression (pp
, TREE_OPERAND (e
, 0));
1267 pp_c_left_bracket (pp
);
1268 pp_expression (pp
, TREE_OPERAND (e
, 1));
1269 pp_c_right_bracket (pp
);
1273 pp_postfix_expression (pp
, TREE_OPERAND (e
, 0));
1274 pp_c_call_argument_list (pp
, TREE_OPERAND (e
, 1));
1277 case UNORDERED_EXPR
:
1278 pp_c_identifier (pp
, flag_isoc99
1280 : "__builtin_isunordered");
1284 pp_c_identifier (pp
, flag_isoc99
1286 : "!__builtin_isunordered");
1290 pp_c_identifier (pp
, flag_isoc99
1292 : "!__builtin_isgreaterequal");
1296 pp_c_identifier (pp
, flag_isoc99
1298 : "!__builtin_isgreater");
1302 pp_c_identifier (pp
, flag_isoc99
1304 : "!__builtin_islessequal");
1308 pp_c_identifier (pp
, flag_isoc99
1310 : "!__builtin_isless");
1314 pp_c_identifier (pp
, flag_isoc99
1316 : "!__builtin_islessgreater");
1320 pp_c_identifier (pp
, flag_isoc99
1322 : "__builtin_islessgreater");
1326 pp_c_left_paren (pp
);
1327 pp_expression (pp
, TREE_OPERAND (e
, 0));
1328 pp_separate_with (pp
, ',');
1329 pp_expression (pp
, TREE_OPERAND (e
, 1));
1330 pp_c_right_paren (pp
);
1334 pp_c_identifier (pp
, "__builtin_abs");
1335 pp_c_left_paren (pp
);
1336 pp_expression (pp
, TREE_OPERAND (e
, 0));
1337 pp_c_right_paren (pp
);
1342 tree object
= TREE_OPERAND (e
, 0);
1343 if (TREE_CODE (object
) == INDIRECT_REF
)
1345 pp_postfix_expression (pp
, TREE_OPERAND (object
, 0));
1350 pp_postfix_expression (pp
, object
);
1353 pp_expression (pp
, TREE_OPERAND (e
, 1));
1360 pp_c_compound_literal (pp
, e
);
1363 case COMPOUND_LITERAL_EXPR
:
1364 e
= DECL_INITIAL (COMPOUND_LITERAL_EXPR_DECL (e
));
1367 pp_initializer (pp
, e
);
1371 pp_c_identifier (pp
, "__builtin_va_arg");
1372 pp_c_left_paren (pp
);
1373 pp_assignment_expression (pp
, TREE_OPERAND (e
, 0));
1374 pp_separate_with (pp
, ',');
1375 pp_type_id (pp
, TREE_TYPE (e
));
1376 pp_c_right_paren (pp
);
1380 if (TREE_CODE (TREE_OPERAND (e
, 0)) == FUNCTION_DECL
)
1382 pp_c_id_expression (pp
, TREE_OPERAND (e
, 0));
1385 /* else fall through. */
1388 pp_primary_expression (pp
, e
);
1393 /* Print out an expression-list; E is expected to be a TREE_LIST. */
1396 pp_c_expression_list (c_pretty_printer
*pp
, tree e
)
1398 for (; e
!= NULL_TREE
; e
= TREE_CHAIN (e
))
1400 pp_expression (pp
, TREE_VALUE (e
));
1402 pp_separate_with (pp
, ',');
1406 /* Print out V, which contains the elements of a constructor. */
1409 pp_c_constructor_elts (c_pretty_printer
*pp
, VEC(constructor_elt
,gc
) *v
)
1411 unsigned HOST_WIDE_INT ix
;
1414 FOR_EACH_CONSTRUCTOR_VALUE (v
, ix
, value
)
1416 pp_expression (pp
, value
);
1417 if (ix
!= VEC_length (constructor_elt
, v
) - 1)
1418 pp_separate_with (pp
, ',');
1422 /* Print out an expression-list in parens, as in a function call. */
1425 pp_c_call_argument_list (c_pretty_printer
*pp
, tree t
)
1427 pp_c_left_paren (pp
);
1428 if (t
&& TREE_CODE (t
) == TREE_LIST
)
1429 pp_c_expression_list (pp
, t
);
1430 pp_c_right_paren (pp
);
1433 /* unary-expression:
1437 unary-operator cast-expression
1438 sizeof unary-expression
1441 unary-operator: one of
1446 __alignof__ unary-expression
1447 __alignof__ ( type-id )
1448 __real__ unary-expression
1449 __imag__ unary-expression */
1452 pp_c_unary_expression (c_pretty_printer
*pp
, tree e
)
1454 enum tree_code code
= TREE_CODE (e
);
1457 case PREINCREMENT_EXPR
:
1458 case PREDECREMENT_EXPR
:
1459 pp_identifier (pp
, code
== PREINCREMENT_EXPR
? "++" : "--");
1460 pp_c_unary_expression (pp
, TREE_OPERAND (e
, 0));
1467 case TRUTH_NOT_EXPR
:
1469 /* String literal are used by address. */
1470 if (code
== ADDR_EXPR
&& TREE_CODE (TREE_OPERAND (e
, 0)) != STRING_CST
)
1472 else if (code
== INDIRECT_REF
)
1474 else if (code
== NEGATE_EXPR
)
1476 else if (code
== BIT_NOT_EXPR
|| code
== CONJ_EXPR
)
1478 else if (code
== TRUTH_NOT_EXPR
)
1479 pp_exclamation (pp
);
1480 pp_c_cast_expression (pp
, TREE_OPERAND (e
, 0));
1485 pp_c_identifier (pp
, code
== REALPART_EXPR
? "__real__" : "__imag__");
1486 pp_c_whitespace (pp
);
1487 pp_unary_expression (pp
, TREE_OPERAND (e
, 0));
1491 pp_postfix_expression (pp
, e
);
1498 ( type-name ) cast-expression */
1501 pp_c_cast_expression (c_pretty_printer
*pp
, tree e
)
1503 switch (TREE_CODE (e
))
1506 case FIX_TRUNC_EXPR
:
1509 pp_c_type_cast (pp
, TREE_TYPE (e
));
1510 pp_c_cast_expression (pp
, TREE_OPERAND (e
, 0));
1514 pp_unary_expression (pp
, e
);
1518 /* multiplicative-expression:
1520 multiplicative-expression * cast-expression
1521 multiplicative-expression / cast-expression
1522 multiplicative-expression % cast-expression */
1525 pp_c_multiplicative_expression (c_pretty_printer
*pp
, tree e
)
1527 enum tree_code code
= TREE_CODE (e
);
1531 case TRUNC_DIV_EXPR
:
1532 case TRUNC_MOD_EXPR
:
1533 pp_multiplicative_expression (pp
, TREE_OPERAND (e
, 0));
1534 pp_c_whitespace (pp
);
1535 if (code
== MULT_EXPR
)
1537 else if (code
== TRUNC_DIV_EXPR
)
1541 pp_c_whitespace (pp
);
1542 pp_c_cast_expression (pp
, TREE_OPERAND (e
, 1));
1546 pp_c_cast_expression (pp
, e
);
1551 /* additive-expression:
1552 multiplicative-expression
1553 additive-expression + multiplicative-expression
1554 additive-expression - multiplicative-expression */
1557 pp_c_additive_expression (c_pretty_printer
*pp
, tree e
)
1559 enum tree_code code
= TREE_CODE (e
);
1564 pp_c_additive_expression (pp
, TREE_OPERAND (e
, 0));
1565 pp_c_whitespace (pp
);
1566 if (code
== PLUS_EXPR
)
1570 pp_c_whitespace (pp
);
1571 pp_multiplicative_expression (pp
, TREE_OPERAND (e
, 1));
1575 pp_multiplicative_expression (pp
, e
);
1580 /* additive-expression:
1582 shift-expression << additive-expression
1583 shift-expression >> additive-expression */
1586 pp_c_shift_expression (c_pretty_printer
*pp
, tree e
)
1588 enum tree_code code
= TREE_CODE (e
);
1593 pp_c_shift_expression (pp
, TREE_OPERAND (e
, 0));
1594 pp_c_whitespace (pp
);
1595 pp_identifier (pp
, code
== LSHIFT_EXPR
? "<<" : ">>");
1596 pp_c_whitespace (pp
);
1597 pp_c_additive_expression (pp
, TREE_OPERAND (e
, 1));
1601 pp_c_additive_expression (pp
, e
);
1605 /* relational-expression:
1607 relational-expression < shift-expression
1608 relational-expression > shift-expression
1609 relational-expression <= shift-expression
1610 relational-expression >= shift-expression */
1613 pp_c_relational_expression (c_pretty_printer
*pp
, tree e
)
1615 enum tree_code code
= TREE_CODE (e
);
1622 pp_c_relational_expression (pp
, TREE_OPERAND (e
, 0));
1623 pp_c_whitespace (pp
);
1624 if (code
== LT_EXPR
)
1626 else if (code
== GT_EXPR
)
1628 else if (code
== LE_EXPR
)
1629 pp_identifier (pp
, "<=");
1630 else if (code
== GE_EXPR
)
1631 pp_identifier (pp
, ">=");
1632 pp_c_whitespace (pp
);
1633 pp_c_shift_expression (pp
, TREE_OPERAND (e
, 1));
1637 pp_c_shift_expression (pp
, e
);
1642 /* equality-expression:
1643 relational-expression
1644 equality-expression == relational-expression
1645 equality-equality != relational-expression */
1648 pp_c_equality_expression (c_pretty_printer
*pp
, tree e
)
1650 enum tree_code code
= TREE_CODE (e
);
1655 pp_c_equality_expression (pp
, TREE_OPERAND (e
, 0));
1656 pp_c_whitespace (pp
);
1657 pp_identifier (pp
, code
== EQ_EXPR
? "==" : "!=");
1658 pp_c_whitespace (pp
);
1659 pp_c_relational_expression (pp
, TREE_OPERAND (e
, 1));
1663 pp_c_relational_expression (pp
, e
);
1670 AND-expression & equality-equality */
1673 pp_c_and_expression (c_pretty_printer
*pp
, tree e
)
1675 if (TREE_CODE (e
) == BIT_AND_EXPR
)
1677 pp_c_and_expression (pp
, TREE_OPERAND (e
, 0));
1678 pp_c_whitespace (pp
);
1680 pp_c_whitespace (pp
);
1681 pp_c_equality_expression (pp
, TREE_OPERAND (e
, 1));
1684 pp_c_equality_expression (pp
, e
);
1687 /* exclusive-OR-expression:
1689 exclusive-OR-expression ^ AND-expression */
1692 pp_c_exclusive_or_expression (c_pretty_printer
*pp
, tree e
)
1694 if (TREE_CODE (e
) == BIT_XOR_EXPR
)
1696 pp_c_exclusive_or_expression (pp
, TREE_OPERAND (e
, 0));
1697 pp_c_maybe_whitespace (pp
);
1699 pp_c_whitespace (pp
);
1700 pp_c_and_expression (pp
, TREE_OPERAND (e
, 1));
1703 pp_c_and_expression (pp
, e
);
1706 /* inclusive-OR-expression:
1707 exclusive-OR-expression
1708 inclusive-OR-expression | exclusive-OR-expression */
1711 pp_c_inclusive_or_expression (c_pretty_printer
*pp
, tree e
)
1713 if (TREE_CODE (e
) == BIT_IOR_EXPR
)
1715 pp_c_exclusive_or_expression (pp
, TREE_OPERAND (e
, 0));
1716 pp_c_whitespace (pp
);
1718 pp_c_whitespace (pp
);
1719 pp_c_exclusive_or_expression (pp
, TREE_OPERAND (e
, 1));
1722 pp_c_exclusive_or_expression (pp
, e
);
1725 /* logical-AND-expression:
1726 inclusive-OR-expression
1727 logical-AND-expression && inclusive-OR-expression */
1730 pp_c_logical_and_expression (c_pretty_printer
*pp
, tree e
)
1732 if (TREE_CODE (e
) == TRUTH_ANDIF_EXPR
)
1734 pp_c_logical_and_expression (pp
, TREE_OPERAND (e
, 0));
1735 pp_c_whitespace (pp
);
1736 pp_identifier (pp
, "&&");
1737 pp_c_whitespace (pp
);
1738 pp_c_inclusive_or_expression (pp
, TREE_OPERAND (e
, 1));
1741 pp_c_inclusive_or_expression (pp
, e
);
1744 /* logical-OR-expression:
1745 logical-AND-expression
1746 logical-OR-expression || logical-AND-expression */
1749 pp_c_logical_or_expression (c_pretty_printer
*pp
, tree e
)
1751 if (TREE_CODE (e
) == TRUTH_ORIF_EXPR
)
1753 pp_c_logical_or_expression (pp
, TREE_OPERAND (e
, 0));
1754 pp_c_whitespace (pp
);
1755 pp_identifier (pp
, "||");
1756 pp_c_whitespace (pp
);
1757 pp_c_logical_and_expression (pp
, TREE_OPERAND (e
, 1));
1760 pp_c_logical_and_expression (pp
, e
);
1763 /* conditional-expression:
1764 logical-OR-expression
1765 logical-OR-expression ? expression : conditional-expression */
1768 pp_c_conditional_expression (c_pretty_printer
*pp
, tree e
)
1770 if (TREE_CODE (e
) == COND_EXPR
)
1772 pp_c_logical_or_expression (pp
, TREE_OPERAND (e
, 0));
1773 pp_c_whitespace (pp
);
1775 pp_c_whitespace (pp
);
1776 pp_expression (pp
, TREE_OPERAND (e
, 1));
1777 pp_c_whitespace (pp
);
1779 pp_c_whitespace (pp
);
1780 pp_c_conditional_expression (pp
, TREE_OPERAND (e
, 2));
1783 pp_c_logical_or_expression (pp
, e
);
1787 /* assignment-expression:
1788 conditional-expression
1789 unary-expression assignment-operator assignment-expression
1791 assignment-expression: one of
1792 = *= /= %= += -= >>= <<= &= ^= |= */
1795 pp_c_assignment_expression (c_pretty_printer
*pp
, tree e
)
1797 if (TREE_CODE (e
) == MODIFY_EXPR
1798 || TREE_CODE (e
) == GIMPLE_MODIFY_STMT
1799 || TREE_CODE (e
) == INIT_EXPR
)
1801 pp_c_unary_expression (pp
, GENERIC_TREE_OPERAND (e
, 0));
1802 pp_c_whitespace (pp
);
1805 pp_c_expression (pp
, GENERIC_TREE_OPERAND (e
, 1));
1808 pp_c_conditional_expression (pp
, e
);
1812 assignment-expression
1813 expression , assignment-expression
1815 Implementation note: instead of going through the usual recursion
1816 chain, I take the liberty of dispatching nodes to the appropriate
1817 functions. This makes some redundancy, but it worths it. That also
1818 prevents a possible infinite recursion between pp_c_primary_expression ()
1819 and pp_c_expression (). */
1822 pp_c_expression (c_pretty_printer
*pp
, tree e
)
1824 switch (TREE_CODE (e
))
1827 pp_c_integer_constant (pp
, e
);
1831 pp_c_floating_constant (pp
, e
);
1835 pp_c_string_literal (pp
, e
);
1838 case IDENTIFIER_NODE
:
1847 pp_primary_expression (pp
, e
);
1850 case POSTINCREMENT_EXPR
:
1851 case POSTDECREMENT_EXPR
:
1859 case UNORDERED_EXPR
:
1868 case COMPOUND_LITERAL_EXPR
:
1870 pp_postfix_expression (pp
, e
);
1878 case TRUTH_NOT_EXPR
:
1879 case PREINCREMENT_EXPR
:
1880 case PREDECREMENT_EXPR
:
1883 pp_c_unary_expression (pp
, e
);
1887 case FIX_TRUNC_EXPR
:
1890 pp_c_cast_expression (pp
, e
);
1894 case TRUNC_MOD_EXPR
:
1895 case TRUNC_DIV_EXPR
:
1896 pp_multiplicative_expression (pp
, e
);
1901 pp_c_shift_expression (pp
, e
);
1908 pp_c_relational_expression (pp
, e
);
1912 pp_c_and_expression (pp
, e
);
1916 pp_c_exclusive_or_expression (pp
, e
);
1920 pp_c_inclusive_or_expression (pp
, e
);
1923 case TRUTH_ANDIF_EXPR
:
1924 pp_c_logical_and_expression (pp
, e
);
1927 case TRUTH_ORIF_EXPR
:
1928 pp_c_logical_or_expression (pp
, e
);
1933 pp_c_equality_expression (pp
, e
);
1937 pp_conditional_expression (pp
, e
);
1942 pp_c_additive_expression (pp
, e
);
1946 case GIMPLE_MODIFY_STMT
:
1948 pp_assignment_expression (pp
, e
);
1952 pp_c_left_paren (pp
);
1953 pp_expression (pp
, TREE_OPERAND (e
, 0));
1954 pp_separate_with (pp
, ',');
1955 pp_assignment_expression (pp
, TREE_OPERAND (e
, 1));
1956 pp_c_right_paren (pp
);
1959 case NON_LVALUE_EXPR
:
1961 pp_expression (pp
, TREE_OPERAND (e
, 0));
1965 pp_postfix_expression (pp
, TREE_OPERAND (e
, 1));
1969 pp_unsupported_tree (pp
, e
);
1979 pp_c_statement (c_pretty_printer
*pp
, tree stmt
)
1984 if (pp_needs_newline (pp
))
1985 pp_newline_and_indent (pp
, 0);
1987 dump_generic_node (pp_base (pp
), stmt
, pp_indentation (pp
), 0, true);
1991 /* Initialize the PRETTY-PRINTER for handling C codes. */
1994 pp_c_pretty_printer_init (c_pretty_printer
*pp
)
1996 pp
->offset_list
= 0;
1998 pp
->declaration
= pp_c_declaration
;
1999 pp
->declaration_specifiers
= pp_c_declaration_specifiers
;
2000 pp
->declarator
= pp_c_declarator
;
2001 pp
->direct_declarator
= pp_c_direct_declarator
;
2002 pp
->type_specifier_seq
= pp_c_specifier_qualifier_list
;
2003 pp
->abstract_declarator
= pp_c_abstract_declarator
;
2004 pp
->direct_abstract_declarator
= pp_c_direct_abstract_declarator
;
2005 pp
->ptr_operator
= pp_c_pointer
;
2006 pp
->parameter_list
= pp_c_parameter_type_list
;
2007 pp
->type_id
= pp_c_type_id
;
2008 pp
->simple_type_specifier
= pp_c_type_specifier
;
2009 pp
->function_specifier
= pp_c_function_specifier
;
2010 pp
->storage_class_specifier
= pp_c_storage_class_specifier
;
2012 pp
->statement
= pp_c_statement
;
2014 pp
->constant
= pp_c_constant
;
2015 pp
->id_expression
= pp_c_id_expression
;
2016 pp
->primary_expression
= pp_c_primary_expression
;
2017 pp
->postfix_expression
= pp_c_postfix_expression
;
2018 pp
->unary_expression
= pp_c_unary_expression
;
2019 pp
->initializer
= pp_c_initializer
;
2020 pp
->multiplicative_expression
= pp_c_multiplicative_expression
;
2021 pp
->conditional_expression
= pp_c_conditional_expression
;
2022 pp
->assignment_expression
= pp_c_assignment_expression
;
2023 pp
->expression
= pp_c_expression
;
2027 /* Print the tree T in full, on file FILE. */
2030 print_c_tree (FILE *file
, tree t
)
2032 static c_pretty_printer pp_rec
;
2033 static bool initialized
= 0;
2034 c_pretty_printer
*pp
= &pp_rec
;
2039 pp_construct (pp_base (pp
), NULL
, 0);
2040 pp_c_pretty_printer_init (pp
);
2041 pp_needs_newline (pp
) = true;
2043 pp_base (pp
)->buffer
->stream
= file
;
2045 pp_statement (pp
, t
);
2051 /* Print the tree T in full, on stderr. */
2054 debug_c_tree (tree t
)
2056 print_c_tree (stderr
, t
);
2057 fputc ('\n', stderr
);
2060 /* Output the DECL_NAME of T. If T has no DECL_NAME, output a string made
2061 up of T's memory address. */
2064 pp_c_tree_decl_identifier (c_pretty_printer
*pp
, tree t
)
2068 gcc_assert (DECL_P (t
));
2071 name
= IDENTIFIER_POINTER (DECL_NAME (t
));
2074 static char xname
[8];
2075 sprintf (xname
, "<U%4x>", ((unsigned)((unsigned long)(t
) & 0xffff)));
2079 pp_c_identifier (pp
, name
);