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 pp_c_type_specifier (pp
, t
);
324 int prec
= TYPE_PRECISION (t
);
325 t
= c_common_type_for_mode (TYPE_MODE (t
), TYPE_UNSIGNED (t
));
326 pp_c_type_specifier (pp
, t
);
327 if (TYPE_PRECISION (t
) != prec
)
330 pp_decimal_int (pp
, prec
);
337 pp_id_expression (pp
, t
);
339 pp_c_identifier (pp
, "<typedef-error>");
345 if (code
== UNION_TYPE
)
346 pp_c_identifier (pp
, "union");
347 else if (code
== RECORD_TYPE
)
348 pp_c_identifier (pp
, "struct");
349 else if (code
== ENUMERAL_TYPE
)
350 pp_c_identifier (pp
, "enum");
352 pp_c_identifier (pp
, "<tag-error>");
355 pp_id_expression (pp
, TYPE_NAME (t
));
357 pp_c_identifier (pp
, "<anonymous>");
361 pp_unsupported_tree (pp
, t
);
366 /* specifier-qualifier-list:
367 type-specifier specifier-qualifier-list-opt
368 type-qualifier specifier-qualifier-list-opt
371 Implementation note: Because of the non-linearities in array or
372 function declarations, this routine prints not just the
373 specifier-qualifier-list of such entities or types of such entities,
374 but also the 'pointer' production part of their declarators. The
375 remaining part is done by pp_declarator or pp_c_abstract_declarator. */
378 pp_c_specifier_qualifier_list (c_pretty_printer
*pp
, tree t
)
380 const enum tree_code code
= TREE_CODE (t
);
382 if (TREE_CODE (t
) != POINTER_TYPE
)
383 pp_c_type_qualifier_list (pp
, t
);
389 /* Get the types-specifier of this type. */
390 tree pointee
= strip_pointer_operator (TREE_TYPE (t
));
391 pp_c_specifier_qualifier_list (pp
, pointee
);
392 if (TREE_CODE (pointee
) == ARRAY_TYPE
393 || TREE_CODE (pointee
) == FUNCTION_TYPE
)
395 pp_c_whitespace (pp
);
396 pp_c_left_paren (pp
);
398 else if (!c_dialect_cxx ())
399 pp_c_whitespace (pp
);
400 pp_ptr_operator (pp
, t
);
406 pp_c_specifier_qualifier_list (pp
, TREE_TYPE (t
));
411 pp_c_specifier_qualifier_list (pp
, TREE_TYPE (t
));
412 if (code
== COMPLEX_TYPE
)
413 pp_c_identifier (pp
, flag_isoc99
? "_Complex" : "__complex__");
414 else if (code
== VECTOR_TYPE
)
415 pp_c_identifier (pp
, "__vector__");
419 pp_simple_type_specifier (pp
, t
);
424 /* parameter-type-list:
429 parameter-declaration
430 parameter-list , parameter-declaration
432 parameter-declaration:
433 declaration-specifiers declarator
434 declaration-specifiers abstract-declarator(opt) */
437 pp_c_parameter_type_list (c_pretty_printer
*pp
, tree t
)
439 bool want_parm_decl
= DECL_P (t
) && !(pp
->flags
& pp_c_flag_abstract
);
440 tree parms
= want_parm_decl
? DECL_ARGUMENTS (t
) : TYPE_ARG_TYPES (t
);
441 pp_c_left_paren (pp
);
442 if (parms
== void_list_node
)
443 pp_c_identifier (pp
, "void");
447 for ( ; parms
&& parms
!= void_list_node
; parms
= TREE_CHAIN (parms
))
450 pp_separate_with (pp
, ',');
452 pp_declaration_specifiers
453 (pp
, want_parm_decl
? parms
: TREE_VALUE (parms
));
455 pp_declarator (pp
, parms
);
457 pp_abstract_declarator (pp
, TREE_VALUE (parms
));
460 pp_c_right_paren (pp
);
463 /* abstract-declarator:
465 pointer(opt) direct-abstract-declarator */
468 pp_c_abstract_declarator (c_pretty_printer
*pp
, tree t
)
470 if (TREE_CODE (t
) == POINTER_TYPE
)
472 if (TREE_CODE (TREE_TYPE (t
)) == ARRAY_TYPE
473 || TREE_CODE (TREE_TYPE (t
)) == FUNCTION_TYPE
)
474 pp_c_right_paren (pp
);
478 pp_direct_abstract_declarator (pp
, t
);
481 /* direct-abstract-declarator:
482 ( abstract-declarator )
483 direct-abstract-declarator(opt) [ assignment-expression(opt) ]
484 direct-abstract-declarator(opt) [ * ]
485 direct-abstract-declarator(opt) ( parameter-type-list(opt) ) */
488 pp_c_direct_abstract_declarator (c_pretty_printer
*pp
, tree t
)
490 switch (TREE_CODE (t
))
493 pp_abstract_declarator (pp
, t
);
497 pp_c_parameter_type_list (pp
, t
);
498 pp_direct_abstract_declarator (pp
, TREE_TYPE (t
));
502 pp_c_left_bracket (pp
);
503 if (TYPE_DOMAIN (t
) && TYPE_MAX_VALUE (TYPE_DOMAIN (t
)))
504 pp_expression (pp
, TYPE_MAX_VALUE (TYPE_DOMAIN (t
)));
505 pp_c_right_bracket (pp
);
506 pp_direct_abstract_declarator (pp
, TREE_TYPE (t
));
509 case IDENTIFIER_NODE
:
523 pp_unsupported_tree (pp
, t
);
529 specifier-qualifier-list abstract-declarator(opt) */
532 pp_c_type_id (c_pretty_printer
*pp
, tree t
)
534 pp_c_specifier_qualifier_list (pp
, t
);
535 pp_abstract_declarator (pp
, t
);
538 /* storage-class-specifier:
546 pp_c_storage_class_specifier (c_pretty_printer
*pp
, tree t
)
548 if (TREE_CODE (t
) == TYPE_DECL
)
549 pp_c_identifier (pp
, "typedef");
552 if (DECL_REGISTER (t
))
553 pp_c_identifier (pp
, "register");
554 else if (TREE_STATIC (t
) && TREE_CODE (t
) == VAR_DECL
)
555 pp_c_identifier (pp
, "static");
559 /* function-specifier:
563 pp_c_function_specifier (c_pretty_printer
*pp
, tree t
)
565 if (TREE_CODE (t
) == FUNCTION_DECL
&& DECL_DECLARED_INLINE_P (t
))
566 pp_c_identifier (pp
, "inline");
569 /* declaration-specifiers:
570 storage-class-specifier declaration-specifiers(opt)
571 type-specifier declaration-specifiers(opt)
572 type-qualifier declaration-specifiers(opt)
573 function-specifier declaration-specifiers(opt) */
576 pp_c_declaration_specifiers (c_pretty_printer
*pp
, tree t
)
578 pp_storage_class_specifier (pp
, t
);
579 pp_function_specifier (pp
, t
);
580 pp_c_specifier_qualifier_list (pp
, DECL_P (t
) ? TREE_TYPE (t
) : t
);
586 direct-declarator [ type-qualifier-list(opt) assignment-expression(opt) ]
587 direct-declarator [ static type-qualifier-list(opt) assignment-expression(opt)]
588 direct-declarator [ type-qualifier-list static assignment-expression ]
589 direct-declarator [ type-qualifier-list * ]
590 direct-declarator ( parameter-type-list )
591 direct-declarator ( identifier-list(opt) ) */
594 pp_c_direct_declarator (c_pretty_printer
*pp
, tree t
)
596 switch (TREE_CODE (t
))
603 pp_c_space_for_pointer_operator (pp
, TREE_TYPE (t
));
604 pp_c_tree_decl_identifier (pp
, t
);
609 pp_abstract_declarator (pp
, TREE_TYPE (t
));
613 pp_parameter_list (pp
, t
);
614 pp_abstract_declarator (pp
, TREE_TYPE (t
));
618 pp_c_space_for_pointer_operator (pp
, TREE_TYPE (TREE_TYPE (t
)));
619 pp_c_tree_decl_identifier (pp
, t
);
620 if (pp_c_base (pp
)->flags
& pp_c_flag_abstract
)
621 pp_abstract_declarator (pp
, TREE_TYPE (t
));
624 pp_parameter_list (pp
, t
);
625 pp_abstract_declarator (pp
, TREE_TYPE (TREE_TYPE (t
)));
637 pp_unsupported_tree (pp
, t
);
644 pointer(opt) direct-declarator */
647 pp_c_declarator (c_pretty_printer
*pp
, tree t
)
649 switch (TREE_CODE (t
))
665 pp_direct_declarator (pp
, t
);
670 pp_unsupported_tree (pp
, t
);
676 declaration-specifiers init-declarator-list(opt) ; */
679 pp_c_declaration (c_pretty_printer
*pp
, tree t
)
681 pp_declaration_specifiers (pp
, t
);
682 pp_c_init_declarator (pp
, t
);
685 /* Pretty-print ATTRIBUTES using GNU C extension syntax. */
688 pp_c_attributes (c_pretty_printer
*pp
, tree attributes
)
690 if (attributes
== NULL_TREE
)
693 pp_c_identifier (pp
, "__attribute__");
694 pp_c_left_paren (pp
);
695 pp_c_left_paren (pp
);
696 for (; attributes
!= NULL_TREE
; attributes
= TREE_CHAIN (attributes
))
698 pp_tree_identifier (pp
, TREE_PURPOSE (attributes
));
699 if (TREE_VALUE (attributes
))
700 pp_c_call_argument_list (pp
, TREE_VALUE (attributes
));
702 if (TREE_CHAIN (attributes
))
703 pp_separate_with (pp
, ',');
705 pp_c_right_paren (pp
);
706 pp_c_right_paren (pp
);
709 /* function-definition:
710 declaration-specifiers declarator compound-statement */
713 pp_c_function_definition (c_pretty_printer
*pp
, tree t
)
715 pp_declaration_specifiers (pp
, t
);
716 pp_declarator (pp
, t
);
717 pp_needs_newline (pp
) = true;
718 pp_statement (pp
, DECL_SAVED_TREE (t
));
726 /* Print out a c-char. This is called solely for characters which are
727 in the *target* execution character set. We ought to convert them
728 back to the *host* execution character set before printing, but we
729 have no way to do this at present. A decent compromise is to print
730 all characters as if they were in the host execution character set,
731 and not attempt to recover any named escape characters, but render
732 all unprintables as octal escapes. If the host and target character
733 sets are the same, this produces relatively readable output. If they
734 are not the same, strings may appear as gibberish, but that's okay
735 (in fact, it may well be what the reader wants, e.g. if they are looking
736 to see if conversion to the target character set happened correctly).
738 A special case: we need to prefix \, ", and ' with backslashes. It is
739 correct to do so for the *host*'s \, ", and ', because the rest of the
740 file appears in the host character set. */
743 pp_c_char (c_pretty_printer
*pp
, int c
)
749 case '\\': pp_string (pp
, "\\\\"); break;
750 case '\'': pp_string (pp
, "\\\'"); break;
751 case '\"': pp_string (pp
, "\\\""); break;
752 default: pp_character (pp
, c
);
756 pp_scalar (pp
, "\\%03o", (unsigned) c
);
759 /* Print out a STRING literal. */
762 pp_c_string_literal (c_pretty_printer
*pp
, tree s
)
764 const char *p
= TREE_STRING_POINTER (s
);
765 int n
= TREE_STRING_LENGTH (s
) - 1;
768 for (i
= 0; i
< n
; ++i
)
769 pp_c_char (pp
, p
[i
]);
773 /* Pretty-print an INTEGER literal. */
776 pp_c_integer_constant (c_pretty_printer
*pp
, tree i
)
778 tree type
= TREE_TYPE (i
);
780 if (TREE_INT_CST_HIGH (i
) == 0)
781 pp_wide_integer (pp
, TREE_INT_CST_LOW (i
));
784 if (tree_int_cst_sgn (i
) < 0)
786 pp_character (pp
, '-');
787 i
= build_int_cst_wide (NULL_TREE
,
788 -TREE_INT_CST_LOW (i
),
789 ~TREE_INT_CST_HIGH (i
)
790 + !TREE_INT_CST_LOW (i
));
792 sprintf (pp_buffer (pp
)->digit_buffer
,
793 HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
794 TREE_INT_CST_HIGH (i
), TREE_INT_CST_LOW (i
));
795 pp_string (pp
, pp_buffer (pp
)->digit_buffer
);
797 if (TYPE_UNSIGNED (type
))
798 pp_character (pp
, 'u');
799 if (type
== long_integer_type_node
|| type
== long_unsigned_type_node
)
800 pp_character (pp
, 'l');
801 else if (type
== long_long_integer_type_node
802 || type
== long_long_unsigned_type_node
)
803 pp_string (pp
, "ll");
806 /* Print out a CHARACTER literal. */
809 pp_c_character_constant (c_pretty_printer
*pp
, tree c
)
811 tree type
= TREE_TYPE (c
);
812 if (type
== wchar_type_node
)
813 pp_character (pp
, 'L');
815 if (host_integerp (c
, TYPE_UNSIGNED (type
)))
816 pp_c_char (pp
, tree_low_cst (c
, TYPE_UNSIGNED (type
)));
818 pp_scalar (pp
, "\\x%x", (unsigned) TREE_INT_CST_LOW (c
));
822 /* Print out a BOOLEAN literal. */
825 pp_c_bool_constant (c_pretty_printer
*pp
, tree b
)
827 if (b
== boolean_false_node
)
829 if (c_dialect_cxx ())
830 pp_c_identifier (pp
, "false");
831 else if (flag_isoc99
)
832 pp_c_identifier (pp
, "_False");
834 pp_unsupported_tree (pp
, b
);
836 else if (b
== boolean_true_node
)
838 if (c_dialect_cxx ())
839 pp_c_identifier (pp
, "true");
840 else if (flag_isoc99
)
841 pp_c_identifier (pp
, "_True");
843 pp_unsupported_tree (pp
, b
);
845 else if (TREE_CODE (b
) == INTEGER_CST
)
846 pp_c_integer_constant (pp
, b
);
848 pp_unsupported_tree (pp
, b
);
851 /* Attempt to print out an ENUMERATOR. Return true on success. Else return
852 false; that means the value was obtained by a cast, in which case
853 print out the type-id part of the cast-expression -- the casted value
854 is then printed by pp_c_integer_literal. */
857 pp_c_enumeration_constant (c_pretty_printer
*pp
, tree e
)
859 bool value_is_named
= true;
860 tree type
= TREE_TYPE (e
);
863 /* Find the name of this constant. */
864 for (value
= TYPE_VALUES (type
);
865 value
!= NULL_TREE
&& !tree_int_cst_equal (TREE_VALUE (value
), e
);
866 value
= TREE_CHAIN (value
))
869 if (value
!= NULL_TREE
)
870 pp_id_expression (pp
, TREE_PURPOSE (value
));
873 /* Value must have been cast. */
874 pp_c_type_cast (pp
, type
);
875 value_is_named
= false;
878 return value_is_named
;
881 /* Print out a REAL value as a decimal-floating-constant. */
884 pp_c_floating_constant (c_pretty_printer
*pp
, tree r
)
886 real_to_decimal (pp_buffer (pp
)->digit_buffer
, &TREE_REAL_CST (r
),
887 sizeof (pp_buffer (pp
)->digit_buffer
), 0, 1);
888 pp_string (pp
, pp_buffer(pp
)->digit_buffer
);
889 if (TREE_TYPE (r
) == float_type_node
)
890 pp_character (pp
, 'f');
891 else if (TREE_TYPE (r
) == long_double_type_node
)
892 pp_character (pp
, 'l');
895 /* Pretty-print a compound literal expression. GNU extensions include
899 pp_c_compound_literal (c_pretty_printer
*pp
, tree e
)
901 tree type
= TREE_TYPE (e
);
902 pp_c_type_cast (pp
, type
);
904 switch (TREE_CODE (type
))
911 pp_c_brace_enclosed_initializer_list (pp
, e
);
915 pp_unsupported_tree (pp
, e
);
924 character-constant */
927 pp_c_constant (c_pretty_printer
*pp
, tree e
)
929 const enum tree_code code
= TREE_CODE (e
);
935 tree type
= TREE_TYPE (e
);
936 if (type
== boolean_type_node
)
937 pp_c_bool_constant (pp
, e
);
938 else if (type
== char_type_node
)
939 pp_c_character_constant (pp
, e
);
940 else if (TREE_CODE (type
) == ENUMERAL_TYPE
941 && pp_c_enumeration_constant (pp
, e
))
944 pp_c_integer_constant (pp
, e
);
949 pp_c_floating_constant (pp
, e
);
953 pp_c_string_literal (pp
, e
);
957 pp_unsupported_tree (pp
, e
);
962 /* Pretty-print an IDENTIFIER_NODE, preceded by whitespace is necessary. */
965 pp_c_identifier (c_pretty_printer
*pp
, const char *id
)
967 pp_c_maybe_whitespace (pp
);
968 pp_identifier (pp
, id
);
969 pp_base (pp
)->padding
= pp_before
;
972 /* Pretty-print a C primary-expression.
980 pp_c_primary_expression (c_pretty_printer
*pp
, tree e
)
982 switch (TREE_CODE (e
))
990 pp_c_tree_decl_identifier (pp
, e
);
993 case IDENTIFIER_NODE
:
994 pp_c_tree_identifier (pp
, e
);
998 pp_c_identifier (pp
, "<erroneous-expression>");
1002 pp_c_identifier (pp
, "<return-value>");
1008 pp_c_constant (pp
, e
);
1012 pp_c_identifier (pp
, "__builtin_memcpy");
1013 pp_c_left_paren (pp
);
1015 pp_primary_expression (pp
, TREE_OPERAND (e
, 0));
1016 pp_separate_with (pp
, ',');
1018 pp_initializer (pp
, TREE_OPERAND (e
, 1));
1019 if (TREE_OPERAND (e
, 2))
1021 pp_separate_with (pp
, ',');
1022 pp_c_expression (pp
, TREE_OPERAND (e
, 2));
1024 pp_c_right_paren (pp
);
1028 /* FIXME: Make sure we won't get into an infinie loop. */
1029 pp_c_left_paren (pp
);
1030 pp_expression (pp
, e
);
1031 pp_c_right_paren (pp
);
1036 /* Print out a C initializer -- also support C compound-literals.
1038 assignment-expression:
1039 { initializer-list }
1040 { initializer-list , } */
1043 pp_c_initializer (c_pretty_printer
*pp
, tree e
)
1045 if (TREE_CODE (e
) == CONSTRUCTOR
)
1046 pp_c_brace_enclosed_initializer_list (pp
, e
);
1048 pp_expression (pp
, e
);
1053 declarator = initializer */
1056 pp_c_init_declarator (c_pretty_printer
*pp
, tree t
)
1058 pp_declarator (pp
, t
);
1059 /* We don't want to output function definitions here. There are handled
1060 elsewhere (and the syntactic form is bogus anyway). */
1061 if (TREE_CODE (t
) != FUNCTION_DECL
&& DECL_INITIAL (t
))
1063 tree init
= DECL_INITIAL (t
);
1064 /* This C++ bit is handled here because it is easier to do so.
1065 In templates, the C++ parser builds a TREE_LIST for a
1066 direct-initialization; the TREE_PURPOSE is the variable to
1067 initialize and the TREE_VALUE is the initializer. */
1068 if (TREE_CODE (init
) == TREE_LIST
)
1070 pp_c_left_paren (pp
);
1071 pp_expression (pp
, TREE_VALUE (init
));
1072 pp_right_paren (pp
);
1079 pp_c_initializer (pp
, init
);
1084 /* initializer-list:
1085 designation(opt) initializer
1086 initializer-list , designation(opt) initializer
1093 designator-list designator
1096 [ constant-expression ]
1100 pp_c_initializer_list (c_pretty_printer
*pp
, tree e
)
1102 tree type
= TREE_TYPE (e
);
1103 const enum tree_code code
= TREE_CODE (type
);
1111 tree init
= TREE_OPERAND (e
, 0);
1112 for (; init
!= NULL_TREE
; init
= TREE_CHAIN (init
))
1114 if (code
== RECORD_TYPE
|| code
== UNION_TYPE
)
1117 pp_c_primary_expression (pp
, TREE_PURPOSE (init
));
1121 pp_c_left_bracket (pp
);
1122 if (TREE_PURPOSE (init
))
1123 pp_c_constant (pp
, TREE_PURPOSE (init
));
1124 pp_c_right_bracket (pp
);
1126 pp_c_whitespace (pp
);
1128 pp_c_whitespace (pp
);
1129 pp_initializer (pp
, TREE_VALUE (init
));
1130 if (TREE_CHAIN (init
))
1131 pp_separate_with (pp
, ',');
1137 if (TREE_CODE (e
) == VECTOR_CST
)
1138 pp_c_expression_list (pp
, TREE_VECTOR_CST_ELTS (e
));
1139 else if (TREE_CODE (e
) == CONSTRUCTOR
)
1140 pp_c_constructor_elts (pp
, CONSTRUCTOR_ELTS (e
));
1146 if (TREE_CODE (e
) == CONSTRUCTOR
)
1147 pp_c_constructor_elts (pp
, CONSTRUCTOR_ELTS (e
));
1148 else if (TREE_CODE (e
) == COMPLEX_CST
|| TREE_CODE (e
) == COMPLEX_EXPR
)
1150 const bool cst
= TREE_CODE (e
) == COMPLEX_CST
;
1151 pp_expression (pp
, cst
? TREE_REALPART (e
) : TREE_OPERAND (e
, 0));
1152 pp_separate_with (pp
, ',');
1153 pp_expression (pp
, cst
? TREE_IMAGPART (e
) : TREE_OPERAND (e
, 1));
1163 pp_unsupported_tree (pp
, type
);
1166 /* Pretty-print a brace-enclosed initializer-list. */
1169 pp_c_brace_enclosed_initializer_list (c_pretty_printer
*pp
, tree l
)
1171 pp_c_left_brace (pp
);
1172 pp_c_initializer_list (pp
, l
);
1173 pp_c_right_brace (pp
);
1177 /* This is a convenient function, used to bridge gap between C and C++
1184 pp_c_id_expression (c_pretty_printer
*pp
, tree t
)
1186 switch (TREE_CODE (t
))
1195 pp_c_tree_decl_identifier (pp
, t
);
1198 case IDENTIFIER_NODE
:
1199 pp_c_tree_identifier (pp
, t
);
1203 pp_unsupported_tree (pp
, t
);
1208 /* postfix-expression:
1210 postfix-expression [ expression ]
1211 postfix-expression ( argument-expression-list(opt) )
1212 postfix-expression . identifier
1213 postfix-expression -> identifier
1214 postfix-expression ++
1215 postfix-expression --
1216 ( type-name ) { initializer-list }
1217 ( type-name ) { initializer-list , } */
1220 pp_c_postfix_expression (c_pretty_printer
*pp
, tree e
)
1222 enum tree_code code
= TREE_CODE (e
);
1225 case POSTINCREMENT_EXPR
:
1226 case POSTDECREMENT_EXPR
:
1227 pp_postfix_expression (pp
, TREE_OPERAND (e
, 0));
1228 pp_identifier (pp
, code
== POSTINCREMENT_EXPR
? "++" : "--");
1232 pp_postfix_expression (pp
, TREE_OPERAND (e
, 0));
1233 pp_c_left_bracket (pp
);
1234 pp_expression (pp
, TREE_OPERAND (e
, 1));
1235 pp_c_right_bracket (pp
);
1239 pp_postfix_expression (pp
, TREE_OPERAND (e
, 0));
1240 pp_c_call_argument_list (pp
, TREE_OPERAND (e
, 1));
1243 case UNORDERED_EXPR
:
1244 pp_c_identifier (pp
, flag_isoc99
1246 : "__builtin_isunordered");
1250 pp_c_identifier (pp
, flag_isoc99
1252 : "!__builtin_isunordered");
1256 pp_c_identifier (pp
, flag_isoc99
1258 : "!__builtin_isgreaterequal");
1262 pp_c_identifier (pp
, flag_isoc99
1264 : "!__builtin_isgreater");
1268 pp_c_identifier (pp
, flag_isoc99
1270 : "!__builtin_islessequal");
1274 pp_c_identifier (pp
, flag_isoc99
1276 : "!__builtin_isless");
1280 pp_c_identifier (pp
, flag_isoc99
1282 : "!__builtin_islessgreater");
1286 pp_c_identifier (pp
, flag_isoc99
1288 : "__builtin_islessgreater");
1292 pp_c_left_paren (pp
);
1293 pp_expression (pp
, TREE_OPERAND (e
, 0));
1294 pp_separate_with (pp
, ',');
1295 pp_expression (pp
, TREE_OPERAND (e
, 1));
1296 pp_c_right_paren (pp
);
1300 pp_c_identifier (pp
, "__builtin_abs");
1301 pp_c_left_paren (pp
);
1302 pp_expression (pp
, TREE_OPERAND (e
, 0));
1303 pp_c_right_paren (pp
);
1308 tree object
= TREE_OPERAND (e
, 0);
1309 if (TREE_CODE (object
) == INDIRECT_REF
)
1311 pp_postfix_expression (pp
, TREE_OPERAND (object
, 0));
1316 pp_postfix_expression (pp
, object
);
1319 pp_expression (pp
, TREE_OPERAND (e
, 1));
1326 pp_c_compound_literal (pp
, e
);
1329 case COMPOUND_LITERAL_EXPR
:
1330 e
= DECL_INITIAL (COMPOUND_LITERAL_EXPR_DECL (e
));
1333 pp_initializer (pp
, e
);
1337 pp_c_identifier (pp
, "__builtin_va_arg");
1338 pp_c_left_paren (pp
);
1339 pp_assignment_expression (pp
, TREE_OPERAND (e
, 0));
1340 pp_separate_with (pp
, ',');
1341 pp_type_id (pp
, TREE_TYPE (e
));
1342 pp_c_right_paren (pp
);
1346 if (TREE_CODE (TREE_OPERAND (e
, 0)) == FUNCTION_DECL
)
1348 pp_c_id_expression (pp
, TREE_OPERAND (e
, 0));
1351 /* else fall through. */
1354 pp_primary_expression (pp
, e
);
1359 /* Print out an expression-list; E is expected to be a TREE_LIST. */
1362 pp_c_expression_list (c_pretty_printer
*pp
, tree e
)
1364 for (; e
!= NULL_TREE
; e
= TREE_CHAIN (e
))
1366 pp_expression (pp
, TREE_VALUE (e
));
1368 pp_separate_with (pp
, ',');
1372 /* Print out V, which contains the elements of a constructor. */
1375 pp_c_constructor_elts (c_pretty_printer
*pp
, VEC(constructor_elt
,gc
) *v
)
1377 unsigned HOST_WIDE_INT ix
;
1380 FOR_EACH_CONSTRUCTOR_VALUE (v
, ix
, value
)
1382 pp_expression (pp
, value
);
1383 if (ix
!= VEC_length (constructor_elt
, v
) - 1)
1384 pp_separate_with (pp
, ',');
1388 /* Print out an expression-list in parens, as in a function call. */
1391 pp_c_call_argument_list (c_pretty_printer
*pp
, tree t
)
1393 pp_c_left_paren (pp
);
1394 if (t
&& TREE_CODE (t
) == TREE_LIST
)
1395 pp_c_expression_list (pp
, t
);
1396 pp_c_right_paren (pp
);
1399 /* unary-expression:
1403 unary-operator cast-expression
1404 sizeof unary-expression
1407 unary-operator: one of
1412 __alignof__ unary-expression
1413 __alignof__ ( type-id )
1414 __real__ unary-expression
1415 __imag__ unary-expression */
1418 pp_c_unary_expression (c_pretty_printer
*pp
, tree e
)
1420 enum tree_code code
= TREE_CODE (e
);
1423 case PREINCREMENT_EXPR
:
1424 case PREDECREMENT_EXPR
:
1425 pp_identifier (pp
, code
== PREINCREMENT_EXPR
? "++" : "--");
1426 pp_c_unary_expression (pp
, TREE_OPERAND (e
, 0));
1433 case TRUTH_NOT_EXPR
:
1435 /* String literal are used by address. */
1436 if (code
== ADDR_EXPR
&& TREE_CODE (TREE_OPERAND (e
, 0)) != STRING_CST
)
1438 else if (code
== INDIRECT_REF
)
1440 else if (code
== NEGATE_EXPR
)
1442 else if (code
== BIT_NOT_EXPR
|| code
== CONJ_EXPR
)
1444 else if (code
== TRUTH_NOT_EXPR
)
1445 pp_exclamation (pp
);
1446 pp_c_cast_expression (pp
, TREE_OPERAND (e
, 0));
1451 pp_c_identifier (pp
, code
== REALPART_EXPR
? "__real__" : "__imag__");
1452 pp_c_whitespace (pp
);
1453 pp_unary_expression (pp
, TREE_OPERAND (e
, 0));
1457 pp_postfix_expression (pp
, e
);
1464 ( type-name ) cast-expression */
1467 pp_c_cast_expression (c_pretty_printer
*pp
, tree e
)
1469 switch (TREE_CODE (e
))
1472 case FIX_TRUNC_EXPR
:
1474 pp_c_type_cast (pp
, TREE_TYPE (e
));
1475 pp_c_cast_expression (pp
, TREE_OPERAND (e
, 0));
1479 pp_unary_expression (pp
, e
);
1483 /* multiplicative-expression:
1485 multiplicative-expression * cast-expression
1486 multiplicative-expression / cast-expression
1487 multiplicative-expression % cast-expression */
1490 pp_c_multiplicative_expression (c_pretty_printer
*pp
, tree e
)
1492 enum tree_code code
= TREE_CODE (e
);
1496 case TRUNC_DIV_EXPR
:
1497 case TRUNC_MOD_EXPR
:
1498 pp_multiplicative_expression (pp
, TREE_OPERAND (e
, 0));
1499 pp_c_whitespace (pp
);
1500 if (code
== MULT_EXPR
)
1502 else if (code
== TRUNC_DIV_EXPR
)
1506 pp_c_whitespace (pp
);
1507 pp_c_cast_expression (pp
, TREE_OPERAND (e
, 1));
1511 pp_c_cast_expression (pp
, e
);
1516 /* additive-expression:
1517 multiplicative-expression
1518 additive-expression + multiplicative-expression
1519 additive-expression - multiplicative-expression */
1522 pp_c_additive_expression (c_pretty_printer
*pp
, tree e
)
1524 enum tree_code code
= TREE_CODE (e
);
1529 pp_c_additive_expression (pp
, TREE_OPERAND (e
, 0));
1530 pp_c_whitespace (pp
);
1531 if (code
== PLUS_EXPR
)
1535 pp_c_whitespace (pp
);
1536 pp_multiplicative_expression (pp
, TREE_OPERAND (e
, 1));
1540 pp_multiplicative_expression (pp
, e
);
1545 /* additive-expression:
1547 shift-expression << additive-expression
1548 shift-expression >> additive-expression */
1551 pp_c_shift_expression (c_pretty_printer
*pp
, tree e
)
1553 enum tree_code code
= TREE_CODE (e
);
1558 pp_c_shift_expression (pp
, TREE_OPERAND (e
, 0));
1559 pp_c_whitespace (pp
);
1560 pp_identifier (pp
, code
== LSHIFT_EXPR
? "<<" : ">>");
1561 pp_c_whitespace (pp
);
1562 pp_c_additive_expression (pp
, TREE_OPERAND (e
, 1));
1566 pp_c_additive_expression (pp
, e
);
1570 /* relational-expression:
1572 relational-expression < shift-expression
1573 relational-expression > shift-expression
1574 relational-expression <= shift-expression
1575 relational-expression >= shift-expression */
1578 pp_c_relational_expression (c_pretty_printer
*pp
, tree e
)
1580 enum tree_code code
= TREE_CODE (e
);
1587 pp_c_relational_expression (pp
, TREE_OPERAND (e
, 0));
1588 pp_c_whitespace (pp
);
1589 if (code
== LT_EXPR
)
1591 else if (code
== GT_EXPR
)
1593 else if (code
== LE_EXPR
)
1594 pp_identifier (pp
, "<=");
1595 else if (code
== GE_EXPR
)
1596 pp_identifier (pp
, ">=");
1597 pp_c_whitespace (pp
);
1598 pp_c_shift_expression (pp
, TREE_OPERAND (e
, 1));
1602 pp_c_shift_expression (pp
, e
);
1607 /* equality-expression:
1608 relational-expression
1609 equality-expression == relational-expression
1610 equality-equality != relational-expression */
1613 pp_c_equality_expression (c_pretty_printer
*pp
, tree e
)
1615 enum tree_code code
= TREE_CODE (e
);
1620 pp_c_equality_expression (pp
, TREE_OPERAND (e
, 0));
1621 pp_c_whitespace (pp
);
1622 pp_identifier (pp
, code
== EQ_EXPR
? "==" : "!=");
1623 pp_c_whitespace (pp
);
1624 pp_c_relational_expression (pp
, TREE_OPERAND (e
, 1));
1628 pp_c_relational_expression (pp
, e
);
1635 AND-expression & equality-equality */
1638 pp_c_and_expression (c_pretty_printer
*pp
, tree e
)
1640 if (TREE_CODE (e
) == BIT_AND_EXPR
)
1642 pp_c_and_expression (pp
, TREE_OPERAND (e
, 0));
1643 pp_c_whitespace (pp
);
1645 pp_c_whitespace (pp
);
1646 pp_c_equality_expression (pp
, TREE_OPERAND (e
, 1));
1649 pp_c_equality_expression (pp
, e
);
1652 /* exclusive-OR-expression:
1654 exclusive-OR-expression ^ AND-expression */
1657 pp_c_exclusive_or_expression (c_pretty_printer
*pp
, tree e
)
1659 if (TREE_CODE (e
) == BIT_XOR_EXPR
)
1661 pp_c_exclusive_or_expression (pp
, TREE_OPERAND (e
, 0));
1662 pp_c_maybe_whitespace (pp
);
1664 pp_c_whitespace (pp
);
1665 pp_c_and_expression (pp
, TREE_OPERAND (e
, 1));
1668 pp_c_and_expression (pp
, e
);
1671 /* inclusive-OR-expression:
1672 exclusive-OR-expression
1673 inclusive-OR-expression | exclusive-OR-expression */
1676 pp_c_inclusive_or_expression (c_pretty_printer
*pp
, tree e
)
1678 if (TREE_CODE (e
) == BIT_IOR_EXPR
)
1680 pp_c_exclusive_or_expression (pp
, TREE_OPERAND (e
, 0));
1681 pp_c_whitespace (pp
);
1683 pp_c_whitespace (pp
);
1684 pp_c_exclusive_or_expression (pp
, TREE_OPERAND (e
, 1));
1687 pp_c_exclusive_or_expression (pp
, e
);
1690 /* logical-AND-expression:
1691 inclusive-OR-expression
1692 logical-AND-expression && inclusive-OR-expression */
1695 pp_c_logical_and_expression (c_pretty_printer
*pp
, tree e
)
1697 if (TREE_CODE (e
) == TRUTH_ANDIF_EXPR
)
1699 pp_c_logical_and_expression (pp
, TREE_OPERAND (e
, 0));
1700 pp_c_whitespace (pp
);
1701 pp_identifier (pp
, "&&");
1702 pp_c_whitespace (pp
);
1703 pp_c_inclusive_or_expression (pp
, TREE_OPERAND (e
, 1));
1706 pp_c_inclusive_or_expression (pp
, e
);
1709 /* logical-OR-expression:
1710 logical-AND-expression
1711 logical-OR-expression || logical-AND-expression */
1714 pp_c_logical_or_expression (c_pretty_printer
*pp
, tree e
)
1716 if (TREE_CODE (e
) == TRUTH_ORIF_EXPR
)
1718 pp_c_logical_or_expression (pp
, TREE_OPERAND (e
, 0));
1719 pp_c_whitespace (pp
);
1720 pp_identifier (pp
, "||");
1721 pp_c_whitespace (pp
);
1722 pp_c_logical_and_expression (pp
, TREE_OPERAND (e
, 1));
1725 pp_c_logical_and_expression (pp
, e
);
1728 /* conditional-expression:
1729 logical-OR-expression
1730 logical-OR-expression ? expression : conditional-expression */
1733 pp_c_conditional_expression (c_pretty_printer
*pp
, tree e
)
1735 if (TREE_CODE (e
) == COND_EXPR
)
1737 pp_c_logical_or_expression (pp
, TREE_OPERAND (e
, 0));
1738 pp_c_whitespace (pp
);
1740 pp_c_whitespace (pp
);
1741 pp_expression (pp
, TREE_OPERAND (e
, 1));
1742 pp_c_whitespace (pp
);
1744 pp_c_whitespace (pp
);
1745 pp_c_conditional_expression (pp
, TREE_OPERAND (e
, 2));
1748 pp_c_logical_or_expression (pp
, e
);
1752 /* assignment-expression:
1753 conditional-expression
1754 unary-expression assignment-operator assignment-expression
1756 assignment-expression: one of
1757 = *= /= %= += -= >>= <<= &= ^= |= */
1760 pp_c_assignment_expression (c_pretty_printer
*pp
, tree e
)
1762 if (TREE_CODE (e
) == MODIFY_EXPR
|| TREE_CODE (e
) == INIT_EXPR
)
1764 pp_c_unary_expression (pp
, TREE_OPERAND (e
, 0));
1765 pp_c_whitespace (pp
);
1768 pp_c_expression (pp
, TREE_OPERAND (e
, 1));
1771 pp_c_conditional_expression (pp
, e
);
1775 assignment-expression
1776 expression , assignment-expression
1778 Implementation note: instead of going through the usual recursion
1779 chain, I take the liberty of dispatching nodes to the appropriate
1780 functions. This makes some redundancy, but it worths it. That also
1781 prevents a possible infinite recursion between pp_c_primary_expression ()
1782 and pp_c_expression (). */
1785 pp_c_expression (c_pretty_printer
*pp
, tree e
)
1787 switch (TREE_CODE (e
))
1790 pp_c_integer_constant (pp
, e
);
1794 pp_c_floating_constant (pp
, e
);
1798 pp_c_string_literal (pp
, e
);
1801 case IDENTIFIER_NODE
:
1810 pp_primary_expression (pp
, e
);
1813 case POSTINCREMENT_EXPR
:
1814 case POSTDECREMENT_EXPR
:
1822 case UNORDERED_EXPR
:
1831 case COMPOUND_LITERAL_EXPR
:
1833 pp_postfix_expression (pp
, e
);
1841 case TRUTH_NOT_EXPR
:
1842 case PREINCREMENT_EXPR
:
1843 case PREDECREMENT_EXPR
:
1846 pp_c_unary_expression (pp
, e
);
1850 case FIX_TRUNC_EXPR
:
1852 pp_c_cast_expression (pp
, e
);
1856 case TRUNC_MOD_EXPR
:
1857 case TRUNC_DIV_EXPR
:
1858 pp_multiplicative_expression (pp
, e
);
1863 pp_c_shift_expression (pp
, e
);
1870 pp_c_relational_expression (pp
, e
);
1874 pp_c_and_expression (pp
, e
);
1878 pp_c_exclusive_or_expression (pp
, e
);
1882 pp_c_inclusive_or_expression (pp
, e
);
1885 case TRUTH_ANDIF_EXPR
:
1886 pp_c_logical_and_expression (pp
, e
);
1889 case TRUTH_ORIF_EXPR
:
1890 pp_c_logical_or_expression (pp
, e
);
1895 pp_c_equality_expression (pp
, e
);
1899 pp_conditional_expression (pp
, e
);
1904 pp_c_additive_expression (pp
, e
);
1909 pp_assignment_expression (pp
, e
);
1913 pp_c_left_paren (pp
);
1914 pp_expression (pp
, TREE_OPERAND (e
, 0));
1915 pp_separate_with (pp
, ',');
1916 pp_assignment_expression (pp
, TREE_OPERAND (e
, 1));
1917 pp_c_right_paren (pp
);
1921 case NON_LVALUE_EXPR
:
1923 pp_expression (pp
, TREE_OPERAND (e
, 0));
1927 pp_postfix_expression (pp
, TREE_OPERAND (e
, 1));
1931 pp_unsupported_tree (pp
, e
);
1941 pp_c_statement (c_pretty_printer
*pp
, tree stmt
)
1946 if (pp_needs_newline (pp
))
1947 pp_newline_and_indent (pp
, 0);
1949 dump_generic_node (pp_base (pp
), stmt
, pp_indentation (pp
), 0, true);
1953 /* Initialize the PRETTY-PRINTER for handling C codes. */
1956 pp_c_pretty_printer_init (c_pretty_printer
*pp
)
1958 pp
->offset_list
= 0;
1960 pp
->declaration
= pp_c_declaration
;
1961 pp
->declaration_specifiers
= pp_c_declaration_specifiers
;
1962 pp
->declarator
= pp_c_declarator
;
1963 pp
->direct_declarator
= pp_c_direct_declarator
;
1964 pp
->type_specifier_seq
= pp_c_specifier_qualifier_list
;
1965 pp
->abstract_declarator
= pp_c_abstract_declarator
;
1966 pp
->direct_abstract_declarator
= pp_c_direct_abstract_declarator
;
1967 pp
->ptr_operator
= pp_c_pointer
;
1968 pp
->parameter_list
= pp_c_parameter_type_list
;
1969 pp
->type_id
= pp_c_type_id
;
1970 pp
->simple_type_specifier
= pp_c_type_specifier
;
1971 pp
->function_specifier
= pp_c_function_specifier
;
1972 pp
->storage_class_specifier
= pp_c_storage_class_specifier
;
1974 pp
->statement
= pp_c_statement
;
1976 pp
->id_expression
= pp_c_id_expression
;
1977 pp
->primary_expression
= pp_c_primary_expression
;
1978 pp
->postfix_expression
= pp_c_postfix_expression
;
1979 pp
->unary_expression
= pp_c_unary_expression
;
1980 pp
->initializer
= pp_c_initializer
;
1981 pp
->multiplicative_expression
= pp_c_multiplicative_expression
;
1982 pp
->conditional_expression
= pp_c_conditional_expression
;
1983 pp
->assignment_expression
= pp_c_assignment_expression
;
1984 pp
->expression
= pp_c_expression
;
1988 /* Print the tree T in full, on file FILE. */
1991 print_c_tree (FILE *file
, tree t
)
1993 static c_pretty_printer pp_rec
;
1994 static bool initialized
= 0;
1995 c_pretty_printer
*pp
= &pp_rec
;
2000 pp_construct (pp_base (pp
), NULL
, 0);
2001 pp_c_pretty_printer_init (pp
);
2002 pp_needs_newline (pp
) = true;
2004 pp_base (pp
)->buffer
->stream
= file
;
2006 pp_statement (pp
, t
);
2012 /* Print the tree T in full, on stderr. */
2015 debug_c_tree (tree t
)
2017 print_c_tree (stderr
, t
);
2018 fputc ('\n', stderr
);
2021 /* Output the DECL_NAME of T. If T has no DECL_NAME, output a string made
2022 up of T's memory address. */
2025 pp_c_tree_decl_identifier (c_pretty_printer
*pp
, tree t
)
2029 gcc_assert (DECL_P (t
));
2032 name
= IDENTIFIER_POINTER (DECL_NAME (t
));
2035 static char xname
[8];
2036 sprintf (xname
, "<U%4x>", ((unsigned)((unsigned long)(t
) & 0xffff)));
2040 pp_c_identifier (pp
, name
);