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;
140 /* APPLE LOCAL begin blocks */
142 pp_c_caret (c_pretty_printer *pp)
145 pp_base (pp)->padding = pp_none;
147 /* APPLE LOCAL end blocks */
150 pp_c_arrow (c_pretty_printer *pp)
153 pp_base (pp)->padding = pp_none;
157 pp_c_semicolon (c_pretty_printer *pp)
160 pp_base (pp)->padding = pp_none;
164 pp_c_complement (c_pretty_printer *pp)
167 pp_base (pp)->padding = pp_none;
171 pp_c_exclamation (c_pretty_printer *pp)
174 pp_base (pp)->padding = pp_none;
177 /* Print out the external representation of CV-QUALIFIER. */
180 pp_c_cv_qualifier (c_pretty_printer *pp, const char *cv)
182 const char *p = pp_last_position_in_text (pp);
183 /* The C programming language does not have references, but it is much
184 simpler to handle those here rather than going through the same
185 logic in the C++ pretty-printer. */
186 if (p != NULL && (*p == '*' || *p == '&'))
187 pp_c_whitespace (pp);
188 pp_c_identifier (pp, cv);
191 /* Pretty-print T using the type-cast notation '( type-name )'. */
194 pp_c_type_cast (c_pretty_printer *pp, tree t)
196 pp_c_left_paren (pp);
198 pp_c_right_paren (pp);
201 /* We're about to pretty-print a pointer type as indicated by T.
202 Output a whitespace, if needed, preparing for subsequent output. */
205 pp_c_space_for_pointer_operator (c_pretty_printer *pp, tree t)
207 if (POINTER_TYPE_P (t))
209 tree pointee = strip_pointer_operator (TREE_TYPE (t));
210 if (TREE_CODE (pointee) != ARRAY_TYPE
211 && TREE_CODE (pointee) != FUNCTION_TYPE)
212 pp_c_whitespace (pp);
219 /* C++ cv-qualifiers are called type-qualifiers in C. Print out the
220 cv-qualifiers of T. If T is a declaration then it is the cv-qualifier
221 of its type. Take care of possible extensions.
225 type-qualifier-list type-qualifier
230 __restrict__ -- GNU C
234 pp_c_type_qualifier_list (c_pretty_printer *pp, tree t)
241 qualifiers = TYPE_QUALS (t);
242 if (qualifiers & TYPE_QUAL_CONST)
243 pp_c_cv_qualifier (pp, "const");
244 if (qualifiers & TYPE_QUAL_VOLATILE)
245 pp_c_cv_qualifier (pp, "volatile");
246 if (qualifiers & TYPE_QUAL_RESTRICT)
247 pp_c_cv_qualifier (pp, flag_isoc99 ? "restrict" : "__restrict__");
251 * type-qualifier-list(opt)
252 * type-qualifier-list(opt) pointer */
255 pp_c_pointer (c_pretty_printer *pp, tree t)
257 if (!TYPE_P (t) && TREE_CODE (t) != TYPE_DECL)
259 switch (TREE_CODE (t))
262 /* It is easier to handle C++ reference types here. */
264 if (TREE_CODE (TREE_TYPE (t)) == POINTER_TYPE)
265 pp_c_pointer (pp, TREE_TYPE (t));
266 if (TREE_CODE (t) == POINTER_TYPE)
270 pp_c_type_qualifier_list (pp, t);
272 /* APPLE LOCAL begin blocks */
273 case BLOCK_POINTER_TYPE:
275 pp_c_type_qualifier_list (pp, t);
277 /* APPLE LOCAL end blocks */
279 /* ??? This node is now in GENERIC and so shouldn't be here. But
280 we'll fix that later. */
282 pp_declaration (pp, DECL_EXPR_DECL (t));
283 pp_needs_newline (pp) = true;
287 pp_unsupported_tree (pp, t);
304 struct-or-union-specifier
309 simple-type-specifier:
314 pp_c_type_specifier (c_pretty_printer *pp, tree t)
316 const enum tree_code code = TREE_CODE (t);
320 pp_c_identifier (pp, "<type-error>");
323 case IDENTIFIER_NODE:
324 pp_c_tree_decl_identifier (pp, t);
334 pp_c_type_specifier (pp, t);
338 int prec = TYPE_PRECISION (t);
339 t = c_common_type_for_mode (TYPE_MODE (t), TYPE_UNSIGNED (t));
342 pp_c_type_specifier (pp, t);
343 if (TYPE_PRECISION (t) != prec)
346 pp_decimal_int (pp, prec);
354 pp_string (pp, (TYPE_UNSIGNED (t)
355 ? "<unnamed-unsigned:"
356 : "<unnamed-signed:"));
359 pp_string (pp, "<unnamed-float:");
364 pp_decimal_int (pp, prec);
372 pp_id_expression (pp, t);
374 pp_c_identifier (pp, "<typedef-error>");
380 if (code == UNION_TYPE)
381 pp_c_identifier (pp, "union");
382 else if (code == RECORD_TYPE)
383 pp_c_identifier (pp, "struct");
384 else if (code == ENUMERAL_TYPE)
385 pp_c_identifier (pp, "enum");
387 pp_c_identifier (pp, "<tag-error>");
390 pp_id_expression (pp, TYPE_NAME (t));
392 pp_c_identifier (pp, "<anonymous>");
396 pp_unsupported_tree (pp, t);
401 /* specifier-qualifier-list:
402 type-specifier specifier-qualifier-list-opt
403 type-qualifier specifier-qualifier-list-opt
406 Implementation note: Because of the non-linearities in array or
407 function declarations, this routine prints not just the
408 specifier-qualifier-list of such entities or types of such entities,
409 but also the 'pointer' production part of their declarators. The
410 remaining part is done by pp_declarator or pp_c_abstract_declarator. */
413 pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t)
415 const enum tree_code code = TREE_CODE (t);
417 if (TREE_CODE (t) != POINTER_TYPE)
418 pp_c_type_qualifier_list (pp, t);
423 /* APPLE LOCAL blocks */
424 case BLOCK_POINTER_TYPE:
426 /* Get the types-specifier of this type. */
427 tree pointee = strip_pointer_operator (TREE_TYPE (t));
428 pp_c_specifier_qualifier_list (pp, pointee);
429 if (TREE_CODE (pointee) == ARRAY_TYPE
430 || TREE_CODE (pointee) == FUNCTION_TYPE)
432 pp_c_whitespace (pp);
433 pp_c_left_paren (pp);
435 else if (!c_dialect_cxx ())
436 pp_c_whitespace (pp);
437 pp_ptr_operator (pp, t);
443 pp_c_specifier_qualifier_list (pp, TREE_TYPE (t));
448 pp_c_specifier_qualifier_list (pp, TREE_TYPE (t));
449 if (code == COMPLEX_TYPE)
450 pp_c_identifier (pp, flag_isoc99 ? "_Complex" : "__complex__");
451 else if (code == VECTOR_TYPE)
452 pp_c_identifier (pp, "__vector__");
456 pp_simple_type_specifier (pp, t);
461 /* parameter-type-list:
466 parameter-declaration
467 parameter-list , parameter-declaration
469 parameter-declaration:
470 declaration-specifiers declarator
471 declaration-specifiers abstract-declarator(opt) */
474 pp_c_parameter_type_list (c_pretty_printer *pp, tree t)
476 bool want_parm_decl = DECL_P (t) && !(pp->flags & pp_c_flag_abstract);
477 tree parms = want_parm_decl ? DECL_ARGUMENTS (t) : TYPE_ARG_TYPES (t);
478 pp_c_left_paren (pp);
479 if (parms == void_list_node)
480 pp_c_identifier (pp, "void");
484 for ( ; parms && parms != void_list_node; parms = TREE_CHAIN (parms))
487 pp_separate_with (pp, ',');
489 pp_declaration_specifiers
490 (pp, want_parm_decl ? parms : TREE_VALUE (parms));
492 pp_declarator (pp, parms);
494 pp_abstract_declarator (pp, TREE_VALUE (parms));
497 pp_c_right_paren (pp);
500 /* abstract-declarator:
502 pointer(opt) direct-abstract-declarator */
505 pp_c_abstract_declarator (c_pretty_printer *pp, tree t)
507 /* APPLE LOCAL begin blocks */
508 if (TREE_CODE (t) == POINTER_TYPE ||
509 TREE_CODE (t) == BLOCK_POINTER_TYPE)
510 /* APPLE LOCAL end blocks */
512 if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE
513 || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
514 pp_c_right_paren (pp);
518 pp_direct_abstract_declarator (pp, t);
521 /* direct-abstract-declarator:
522 ( abstract-declarator )
523 direct-abstract-declarator(opt) [ assignment-expression(opt) ]
524 direct-abstract-declarator(opt) [ * ]
525 direct-abstract-declarator(opt) ( parameter-type-list(opt) ) */
528 pp_c_direct_abstract_declarator (c_pretty_printer *pp, tree t)
530 switch (TREE_CODE (t))
533 /* APPLE LOCAL blocks */
534 case BLOCK_POINTER_TYPE:
535 pp_abstract_declarator (pp, t);
539 pp_c_parameter_type_list (pp, t);
540 pp_direct_abstract_declarator (pp, TREE_TYPE (t));
544 pp_c_left_bracket (pp);
545 if (TYPE_DOMAIN (t) && TYPE_MAX_VALUE (TYPE_DOMAIN (t)))
547 tree maxval = TYPE_MAX_VALUE (TYPE_DOMAIN (t));
548 tree type = TREE_TYPE (maxval);
550 if (host_integerp (maxval, 0))
551 pp_wide_integer (pp, tree_low_cst (maxval, 0) + 1);
553 pp_expression (pp, fold (build2 (PLUS_EXPR, type, maxval,
554 build_int_cst (type, 1))));
556 pp_c_right_bracket (pp);
557 pp_direct_abstract_declarator (pp, TREE_TYPE (t));
560 case IDENTIFIER_NODE:
574 pp_unsupported_tree (pp, t);
580 specifier-qualifier-list abstract-declarator(opt) */
583 pp_c_type_id (c_pretty_printer *pp, tree t)
585 pp_c_specifier_qualifier_list (pp, t);
586 pp_abstract_declarator (pp, t);
589 /* storage-class-specifier:
597 pp_c_storage_class_specifier (c_pretty_printer *pp, tree t)
599 if (TREE_CODE (t) == TYPE_DECL)
600 pp_c_identifier (pp, "typedef");
603 if (DECL_REGISTER (t))
604 pp_c_identifier (pp, "register");
605 else if (TREE_STATIC (t) && TREE_CODE (t) == VAR_DECL)
606 pp_c_identifier (pp, "static");
610 /* function-specifier:
614 pp_c_function_specifier (c_pretty_printer *pp, tree t)
616 if (TREE_CODE (t) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (t))
617 pp_c_identifier (pp, "inline");
620 /* declaration-specifiers:
621 storage-class-specifier declaration-specifiers(opt)
622 type-specifier declaration-specifiers(opt)
623 type-qualifier declaration-specifiers(opt)
624 function-specifier declaration-specifiers(opt) */
627 pp_c_declaration_specifiers (c_pretty_printer *pp, tree t)
629 pp_storage_class_specifier (pp, t);
630 pp_function_specifier (pp, t);
631 pp_c_specifier_qualifier_list (pp, DECL_P (t) ? TREE_TYPE (t) : t);
637 direct-declarator [ type-qualifier-list(opt) assignment-expression(opt) ]
638 direct-declarator [ static type-qualifier-list(opt) assignment-expression(opt)]
639 direct-declarator [ type-qualifier-list static assignment-expression ]
640 direct-declarator [ type-qualifier-list * ]
641 direct-declarator ( parameter-type-list )
642 direct-declarator ( identifier-list(opt) ) */
645 pp_c_direct_declarator (c_pretty_printer *pp, tree t)
647 switch (TREE_CODE (t))
654 pp_c_space_for_pointer_operator (pp, TREE_TYPE (t));
655 pp_c_tree_decl_identifier (pp, t);
660 /* APPLE LOCAL blocks */
661 case BLOCK_POINTER_TYPE:
662 pp_abstract_declarator (pp, TREE_TYPE (t));
666 pp_parameter_list (pp, t);
667 pp_abstract_declarator (pp, TREE_TYPE (t));
671 pp_c_space_for_pointer_operator (pp, TREE_TYPE (TREE_TYPE (t)));
672 pp_c_tree_decl_identifier (pp, t);
673 if (pp_c_base (pp)->flags & pp_c_flag_abstract)
674 pp_abstract_declarator (pp, TREE_TYPE (t));
677 pp_parameter_list (pp, t);
678 pp_abstract_declarator (pp, TREE_TYPE (TREE_TYPE (t)));
690 pp_unsupported_tree (pp, t);
697 pointer(opt) direct-declarator */
700 pp_c_declarator (c_pretty_printer *pp, tree t)
702 switch (TREE_CODE (t))
718 pp_direct_declarator (pp, t);
723 pp_unsupported_tree (pp, t);
729 declaration-specifiers init-declarator-list(opt) ; */
732 pp_c_declaration (c_pretty_printer *pp, tree t)
734 pp_declaration_specifiers (pp, t);
735 pp_c_init_declarator (pp, t);
738 /* Pretty-print ATTRIBUTES using GNU C extension syntax. */
741 pp_c_attributes (c_pretty_printer *pp, tree attributes)
743 if (attributes == NULL_TREE)
746 pp_c_identifier (pp, "__attribute__");
747 pp_c_left_paren (pp);
748 pp_c_left_paren (pp);
749 for (; attributes != NULL_TREE; attributes = TREE_CHAIN (attributes))
751 pp_tree_identifier (pp, TREE_PURPOSE (attributes));
752 if (TREE_VALUE (attributes))
753 pp_c_call_argument_list (pp, TREE_VALUE (attributes));
755 if (TREE_CHAIN (attributes))
756 pp_separate_with (pp, ',');
758 pp_c_right_paren (pp);
759 pp_c_right_paren (pp);
762 /* function-definition:
763 declaration-specifiers declarator compound-statement */
766 pp_c_function_definition (c_pretty_printer *pp, tree t)
768 pp_declaration_specifiers (pp, t);
769 pp_declarator (pp, t);
770 pp_needs_newline (pp) = true;
771 pp_statement (pp, DECL_SAVED_TREE (t));
779 /* Print out a c-char. This is called solely for characters which are
780 in the *target* execution character set. We ought to convert them
781 back to the *host* execution character set before printing, but we
782 have no way to do this at present. A decent compromise is to print
783 all characters as if they were in the host execution character set,
784 and not attempt to recover any named escape characters, but render
785 all unprintables as octal escapes. If the host and target character
786 sets are the same, this produces relatively readable output. If they
787 are not the same, strings may appear as gibberish, but that's okay
788 (in fact, it may well be what the reader wants, e.g. if they are looking
789 to see if conversion to the target character set happened correctly).
791 A special case: we need to prefix \, ", and ' with backslashes. It is
792 correct to do so for the *host*'s \, ", and ', because the rest of the
793 file appears in the host character set. */
796 pp_c_char (c_pretty_printer *pp, int c)
802 case '\\': pp_string (pp, "\\\\"); break;
803 case '\'': pp_string (pp, "\\\'"); break;
804 case '\"': pp_string (pp, "\\\""); break;
805 default: pp_character (pp, c);
809 pp_scalar (pp, "\\%03o", (unsigned) c);
812 /* Print out a STRING literal. */
815 pp_c_string_literal (c_pretty_printer *pp, tree s)
817 const char *p = TREE_STRING_POINTER (s);
818 int n = TREE_STRING_LENGTH (s) - 1;
821 for (i = 0; i < n; ++i)
822 pp_c_char (pp, p[i]);
826 /* Pretty-print an INTEGER literal. */
829 pp_c_integer_constant (c_pretty_printer *pp, tree i)
831 tree type = TREE_TYPE (i);
833 if (TREE_INT_CST_HIGH (i) == 0)
834 pp_wide_integer (pp, TREE_INT_CST_LOW (i));
837 if (tree_int_cst_sgn (i) < 0)
839 pp_character (pp, '-');
840 i = build_int_cst_wide (NULL_TREE,
841 -TREE_INT_CST_LOW (i),
842 ~TREE_INT_CST_HIGH (i)
843 + !TREE_INT_CST_LOW (i));
845 sprintf (pp_buffer (pp)->digit_buffer,
846 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
847 TREE_INT_CST_HIGH (i), TREE_INT_CST_LOW (i));
848 pp_string (pp, pp_buffer (pp)->digit_buffer);
850 if (TYPE_UNSIGNED (type))
851 pp_character (pp, 'u');
852 if (type == long_integer_type_node || type == long_unsigned_type_node)
853 pp_character (pp, 'l');
854 else if (type == long_long_integer_type_node
855 || type == long_long_unsigned_type_node)
856 pp_string (pp, "ll");
859 /* Print out a CHARACTER literal. */
862 pp_c_character_constant (c_pretty_printer *pp, tree c)
864 tree type = TREE_TYPE (c);
865 if (type == wchar_type_node)
866 pp_character (pp, 'L');
868 if (host_integerp (c, TYPE_UNSIGNED (type)))
869 pp_c_char (pp, tree_low_cst (c, TYPE_UNSIGNED (type)));
871 pp_scalar (pp, "\\x%x", (unsigned) TREE_INT_CST_LOW (c));
875 /* Print out a BOOLEAN literal. */
878 pp_c_bool_constant (c_pretty_printer *pp, tree b)
880 if (b == boolean_false_node)
882 if (c_dialect_cxx ())
883 pp_c_identifier (pp, "false");
884 else if (flag_isoc99)
885 pp_c_identifier (pp, "_False");
887 pp_unsupported_tree (pp, b);
889 else if (b == boolean_true_node)
891 if (c_dialect_cxx ())
892 pp_c_identifier (pp, "true");
893 else if (flag_isoc99)
894 pp_c_identifier (pp, "_True");
896 pp_unsupported_tree (pp, b);
898 else if (TREE_CODE (b) == INTEGER_CST)
899 pp_c_integer_constant (pp, b);
901 pp_unsupported_tree (pp, b);
904 /* Attempt to print out an ENUMERATOR. Return true on success. Else return
905 false; that means the value was obtained by a cast, in which case
906 print out the type-id part of the cast-expression -- the casted value
907 is then printed by pp_c_integer_literal. */
910 pp_c_enumeration_constant (c_pretty_printer *pp, tree e)
912 bool value_is_named = true;
913 tree type = TREE_TYPE (e);
916 /* Find the name of this constant. */
917 for (value = TYPE_VALUES (type);
918 value != NULL_TREE && !tree_int_cst_equal (TREE_VALUE (value), e);
919 value = TREE_CHAIN (value))
922 if (value != NULL_TREE)
923 pp_id_expression (pp, TREE_PURPOSE (value));
926 /* Value must have been cast. */
927 pp_c_type_cast (pp, type);
928 value_is_named = false;
931 return value_is_named;
934 /* Print out a REAL value as a decimal-floating-constant. */
937 pp_c_floating_constant (c_pretty_printer *pp, tree r)
939 real_to_decimal (pp_buffer (pp)->digit_buffer, &TREE_REAL_CST (r),
940 sizeof (pp_buffer (pp)->digit_buffer), 0, 1);
941 pp_string (pp, pp_buffer(pp)->digit_buffer);
942 if (TREE_TYPE (r) == float_type_node)
943 pp_character (pp, 'f');
944 else if (TREE_TYPE (r) == long_double_type_node)
945 pp_character (pp, 'l');
946 else if (TREE_TYPE (r) == dfloat128_type_node)
947 pp_string (pp, "dl");
948 else if (TREE_TYPE (r) == dfloat64_type_node)
949 pp_string (pp, "dd");
950 else if (TREE_TYPE (r) == dfloat32_type_node)
951 pp_string (pp, "df");
954 /* Pretty-print a compound literal expression. GNU extensions include
958 pp_c_compound_literal (c_pretty_printer *pp, tree e)
960 tree type = TREE_TYPE (e);
961 pp_c_type_cast (pp, type);
963 switch (TREE_CODE (type))
970 pp_c_brace_enclosed_initializer_list (pp, e);
974 pp_unsupported_tree (pp, e);
983 character-constant */
986 pp_c_constant (c_pretty_printer *pp, tree e)
988 const enum tree_code code = TREE_CODE (e);
994 tree type = TREE_TYPE (e);
995 if (type == boolean_type_node)
996 pp_c_bool_constant (pp, e);
997 else if (type == char_type_node)
998 pp_c_character_constant (pp, e);
999 else if (TREE_CODE (type) == ENUMERAL_TYPE
1000 && pp_c_enumeration_constant (pp, e))
1003 pp_c_integer_constant (pp, e);
1008 pp_c_floating_constant (pp, e);
1012 pp_c_string_literal (pp, e);
1016 pp_unsupported_tree (pp, e);
1021 /* Pretty-print an IDENTIFIER_NODE, preceded by whitespace is necessary. */
1024 pp_c_identifier (c_pretty_printer *pp, const char *id)
1026 pp_c_maybe_whitespace (pp);
1027 pp_identifier (pp, id);
1028 pp_base (pp)->padding = pp_before;
1031 /* Pretty-print a C primary-expression.
1039 pp_c_primary_expression (c_pretty_printer *pp, tree e)
1041 switch (TREE_CODE (e))
1049 pp_c_tree_decl_identifier (pp, e);
1052 case IDENTIFIER_NODE:
1053 pp_c_tree_identifier (pp, e);
1057 pp_c_identifier (pp, "<erroneous-expression>");
1061 pp_c_identifier (pp, "<return-value>");
1067 pp_c_constant (pp, e);
1071 pp_c_identifier (pp, "__builtin_memcpy");
1072 pp_c_left_paren (pp);
1074 pp_primary_expression (pp, TREE_OPERAND (e, 0));
1075 pp_separate_with (pp, ',');
1077 pp_initializer (pp, TREE_OPERAND (e, 1));
1078 if (TREE_OPERAND (e, 2))
1080 pp_separate_with (pp, ',');
1081 pp_c_expression (pp, TREE_OPERAND (e, 2));
1083 pp_c_right_paren (pp);
1087 /* FIXME: Make sure we won't get into an infinie loop. */
1088 pp_c_left_paren (pp);
1089 pp_expression (pp, e);
1090 pp_c_right_paren (pp);
1095 /* Print out a C initializer -- also support C compound-literals.
1097 assignment-expression:
1098 { initializer-list }
1099 { initializer-list , } */
1102 pp_c_initializer (c_pretty_printer *pp, tree e)
1104 if (TREE_CODE (e) == CONSTRUCTOR)
1105 pp_c_brace_enclosed_initializer_list (pp, e);
1107 pp_expression (pp, e);
1112 declarator = initializer */
1115 pp_c_init_declarator (c_pretty_printer *pp, tree t)
1117 pp_declarator (pp, t);
1118 /* We don't want to output function definitions here. There are handled
1119 elsewhere (and the syntactic form is bogus anyway). */
1120 if (TREE_CODE (t) != FUNCTION_DECL && DECL_INITIAL (t))
1122 tree init = DECL_INITIAL (t);
1123 /* This C++ bit is handled here because it is easier to do so.
1124 In templates, the C++ parser builds a TREE_LIST for a
1125 direct-initialization; the TREE_PURPOSE is the variable to
1126 initialize and the TREE_VALUE is the initializer. */
1127 if (TREE_CODE (init) == TREE_LIST)
1129 pp_c_left_paren (pp);
1130 pp_expression (pp, TREE_VALUE (init));
1131 pp_right_paren (pp);
1138 pp_c_initializer (pp, init);
1143 /* initializer-list:
1144 designation(opt) initializer
1145 initializer-list , designation(opt) initializer
1152 designator-list designator
1155 [ constant-expression ]
1159 pp_c_initializer_list (c_pretty_printer *pp, tree e)
1161 tree type = TREE_TYPE (e);
1162 const enum tree_code code = TREE_CODE (type);
1170 tree init = TREE_OPERAND (e, 0);
1171 for (; init != NULL_TREE; init = TREE_CHAIN (init))
1173 if (code == RECORD_TYPE || code == UNION_TYPE)
1176 pp_c_primary_expression (pp, TREE_PURPOSE (init));
1180 pp_c_left_bracket (pp);
1181 if (TREE_PURPOSE (init))
1182 pp_c_constant (pp, TREE_PURPOSE (init));
1183 pp_c_right_bracket (pp);
1185 pp_c_whitespace (pp);
1187 pp_c_whitespace (pp);
1188 pp_initializer (pp, TREE_VALUE (init));
1189 if (TREE_CHAIN (init))
1190 pp_separate_with (pp, ',');
1196 if (TREE_CODE (e) == VECTOR_CST)
1197 pp_c_expression_list (pp, TREE_VECTOR_CST_ELTS (e));
1198 else if (TREE_CODE (e) == CONSTRUCTOR)
1199 pp_c_constructor_elts (pp, CONSTRUCTOR_ELTS (e));
1205 if (TREE_CODE (e) == CONSTRUCTOR)
1206 pp_c_constructor_elts (pp, CONSTRUCTOR_ELTS (e));
1207 else if (TREE_CODE (e) == COMPLEX_CST || TREE_CODE (e) == COMPLEX_EXPR)
1209 const bool cst = TREE_CODE (e) == COMPLEX_CST;
1210 pp_expression (pp, cst ? TREE_REALPART (e) : TREE_OPERAND (e, 0));
1211 pp_separate_with (pp, ',');
1212 pp_expression (pp, cst ? TREE_IMAGPART (e) : TREE_OPERAND (e, 1));
1222 pp_unsupported_tree (pp, type);
1225 /* Pretty-print a brace-enclosed initializer-list. */
1228 pp_c_brace_enclosed_initializer_list (c_pretty_printer *pp, tree l)
1230 pp_c_left_brace (pp);
1231 pp_c_initializer_list (pp, l);
1232 pp_c_right_brace (pp);
1236 /* This is a convenient function, used to bridge gap between C and C++
1243 pp_c_id_expression (c_pretty_printer *pp, tree t)
1245 switch (TREE_CODE (t))
1254 pp_c_tree_decl_identifier (pp, t);
1257 case IDENTIFIER_NODE:
1258 pp_c_tree_identifier (pp, t);
1262 pp_unsupported_tree (pp, t);
1267 /* postfix-expression:
1269 postfix-expression [ expression ]
1270 postfix-expression ( argument-expression-list(opt) )
1271 postfix-expression . identifier
1272 postfix-expression -> identifier
1273 postfix-expression ++
1274 postfix-expression --
1275 ( type-name ) { initializer-list }
1276 ( type-name ) { initializer-list , } */
1279 pp_c_postfix_expression (c_pretty_printer *pp, tree e)
1281 enum tree_code code = TREE_CODE (e);
1284 case POSTINCREMENT_EXPR:
1285 case POSTDECREMENT_EXPR:
1286 pp_postfix_expression (pp, TREE_OPERAND (e, 0));
1287 pp_identifier (pp, code == POSTINCREMENT_EXPR ? "++" : "--");
1291 pp_postfix_expression (pp, TREE_OPERAND (e, 0));
1292 pp_c_left_bracket (pp);
1293 pp_expression (pp, TREE_OPERAND (e, 1));
1294 pp_c_right_bracket (pp);
1298 pp_postfix_expression (pp, TREE_OPERAND (e, 0));
1299 pp_c_call_argument_list (pp, TREE_OPERAND (e, 1));
1302 case UNORDERED_EXPR:
1303 pp_c_identifier (pp, flag_isoc99
1305 : "__builtin_isunordered");
1309 pp_c_identifier (pp, flag_isoc99
1311 : "!__builtin_isunordered");
1315 pp_c_identifier (pp, flag_isoc99
1317 : "!__builtin_isgreaterequal");
1321 pp_c_identifier (pp, flag_isoc99
1323 : "!__builtin_isgreater");
1327 pp_c_identifier (pp, flag_isoc99
1329 : "!__builtin_islessequal");
1333 pp_c_identifier (pp, flag_isoc99
1335 : "!__builtin_isless");
1339 pp_c_identifier (pp, flag_isoc99
1341 : "!__builtin_islessgreater");
1345 pp_c_identifier (pp, flag_isoc99
1347 : "__builtin_islessgreater");
1351 pp_c_left_paren (pp);
1352 pp_expression (pp, TREE_OPERAND (e, 0));
1353 pp_separate_with (pp, ',');
1354 pp_expression (pp, TREE_OPERAND (e, 1));
1355 pp_c_right_paren (pp);
1359 pp_c_identifier (pp, "__builtin_abs");
1360 pp_c_left_paren (pp);
1361 pp_expression (pp, TREE_OPERAND (e, 0));
1362 pp_c_right_paren (pp);
1367 tree object = TREE_OPERAND (e, 0);
1368 if (TREE_CODE (object) == INDIRECT_REF)
1370 pp_postfix_expression (pp, TREE_OPERAND (object, 0));
1375 pp_postfix_expression (pp, object);
1378 pp_expression (pp, TREE_OPERAND (e, 1));
1385 pp_c_compound_literal (pp, e);
1388 case COMPOUND_LITERAL_EXPR:
1389 e = DECL_INITIAL (COMPOUND_LITERAL_EXPR_DECL (e));
1392 pp_initializer (pp, e);
1396 pp_c_identifier (pp, "__builtin_va_arg");
1397 pp_c_left_paren (pp);
1398 pp_assignment_expression (pp, TREE_OPERAND (e, 0));
1399 pp_separate_with (pp, ',');
1400 pp_type_id (pp, TREE_TYPE (e));
1401 pp_c_right_paren (pp);
1405 if (TREE_CODE (TREE_OPERAND (e, 0)) == FUNCTION_DECL)
1407 pp_c_id_expression (pp, TREE_OPERAND (e, 0));
1410 /* else fall through. */
1413 pp_primary_expression (pp, e);
1418 /* Print out an expression-list; E is expected to be a TREE_LIST. */
1421 pp_c_expression_list (c_pretty_printer *pp, tree e)
1423 for (; e != NULL_TREE; e = TREE_CHAIN (e))
1425 pp_expression (pp, TREE_VALUE (e));
1427 pp_separate_with (pp, ',');
1431 /* Print out V, which contains the elements of a constructor. */
1434 pp_c_constructor_elts (c_pretty_printer *pp, VEC(constructor_elt,gc) *v)
1436 unsigned HOST_WIDE_INT ix;
1439 FOR_EACH_CONSTRUCTOR_VALUE (v, ix, value)
1441 pp_expression (pp, value);
1442 if (ix != VEC_length (constructor_elt, v) - 1)
1443 pp_separate_with (pp, ',');
1447 /* Print out an expression-list in parens, as in a function call. */
1450 pp_c_call_argument_list (c_pretty_printer *pp, tree t)
1452 pp_c_left_paren (pp);
1453 if (t && TREE_CODE (t) == TREE_LIST)
1454 pp_c_expression_list (pp, t);
1455 pp_c_right_paren (pp);
1458 /* unary-expression:
1462 unary-operator cast-expression
1463 sizeof unary-expression
1466 unary-operator: one of
1471 __alignof__ unary-expression
1472 __alignof__ ( type-id )
1473 __real__ unary-expression
1474 __imag__ unary-expression */
1477 pp_c_unary_expression (c_pretty_printer *pp, tree e)
1479 enum tree_code code = TREE_CODE (e);
1482 case PREINCREMENT_EXPR:
1483 case PREDECREMENT_EXPR:
1484 pp_identifier (pp, code == PREINCREMENT_EXPR ? "++" : "--");
1485 pp_c_unary_expression (pp, TREE_OPERAND (e, 0));
1492 case TRUTH_NOT_EXPR:
1494 /* String literal are used by address. */
1495 if (code == ADDR_EXPR && TREE_CODE (TREE_OPERAND (e, 0)) != STRING_CST)
1497 else if (code == INDIRECT_REF)
1499 else if (code == NEGATE_EXPR)
1501 else if (code == BIT_NOT_EXPR || code == CONJ_EXPR)
1503 else if (code == TRUTH_NOT_EXPR)
1504 pp_exclamation (pp);
1505 pp_c_cast_expression (pp, TREE_OPERAND (e, 0));
1510 pp_c_identifier (pp, code == REALPART_EXPR ? "__real__" : "__imag__");
1511 pp_c_whitespace (pp);
1512 pp_unary_expression (pp, TREE_OPERAND (e, 0));
1516 pp_postfix_expression (pp, e);
1523 ( type-name ) cast-expression */
1526 pp_c_cast_expression (c_pretty_printer *pp, tree e)
1528 switch (TREE_CODE (e))
1531 case FIX_TRUNC_EXPR:
1534 pp_c_type_cast (pp, TREE_TYPE (e));
1535 pp_c_cast_expression (pp, TREE_OPERAND (e, 0));
1539 pp_unary_expression (pp, e);
1543 /* multiplicative-expression:
1545 multiplicative-expression * cast-expression
1546 multiplicative-expression / cast-expression
1547 multiplicative-expression % cast-expression */
1550 pp_c_multiplicative_expression (c_pretty_printer *pp, tree e)
1552 enum tree_code code = TREE_CODE (e);
1556 case TRUNC_DIV_EXPR:
1557 case TRUNC_MOD_EXPR:
1558 pp_multiplicative_expression (pp, TREE_OPERAND (e, 0));
1559 pp_c_whitespace (pp);
1560 if (code == MULT_EXPR)
1562 else if (code == TRUNC_DIV_EXPR)
1566 pp_c_whitespace (pp);
1567 pp_c_cast_expression (pp, TREE_OPERAND (e, 1));
1571 pp_c_cast_expression (pp, e);
1576 /* additive-expression:
1577 multiplicative-expression
1578 additive-expression + multiplicative-expression
1579 additive-expression - multiplicative-expression */
1582 pp_c_additive_expression (c_pretty_printer *pp, tree e)
1584 enum tree_code code = TREE_CODE (e);
1589 pp_c_additive_expression (pp, TREE_OPERAND (e, 0));
1590 pp_c_whitespace (pp);
1591 if (code == PLUS_EXPR)
1595 pp_c_whitespace (pp);
1596 pp_multiplicative_expression (pp, TREE_OPERAND (e, 1));
1600 pp_multiplicative_expression (pp, e);
1605 /* additive-expression:
1607 shift-expression << additive-expression
1608 shift-expression >> additive-expression */
1611 pp_c_shift_expression (c_pretty_printer *pp, tree e)
1613 enum tree_code code = TREE_CODE (e);
1618 pp_c_shift_expression (pp, TREE_OPERAND (e, 0));
1619 pp_c_whitespace (pp);
1620 pp_identifier (pp, code == LSHIFT_EXPR ? "<<" : ">>");
1621 pp_c_whitespace (pp);
1622 pp_c_additive_expression (pp, TREE_OPERAND (e, 1));
1626 pp_c_additive_expression (pp, e);
1630 /* relational-expression:
1632 relational-expression < shift-expression
1633 relational-expression > shift-expression
1634 relational-expression <= shift-expression
1635 relational-expression >= shift-expression */
1638 pp_c_relational_expression (c_pretty_printer *pp, tree e)
1640 enum tree_code code = TREE_CODE (e);
1647 pp_c_relational_expression (pp, TREE_OPERAND (e, 0));
1648 pp_c_whitespace (pp);
1649 if (code == LT_EXPR)
1651 else if (code == GT_EXPR)
1653 else if (code == LE_EXPR)
1654 pp_identifier (pp, "<=");
1655 else if (code == GE_EXPR)
1656 pp_identifier (pp, ">=");
1657 pp_c_whitespace (pp);
1658 pp_c_shift_expression (pp, TREE_OPERAND (e, 1));
1662 pp_c_shift_expression (pp, e);
1667 /* equality-expression:
1668 relational-expression
1669 equality-expression == relational-expression
1670 equality-equality != relational-expression */
1673 pp_c_equality_expression (c_pretty_printer *pp, tree e)
1675 enum tree_code code = TREE_CODE (e);
1680 pp_c_equality_expression (pp, TREE_OPERAND (e, 0));
1681 pp_c_whitespace (pp);
1682 pp_identifier (pp, code == EQ_EXPR ? "==" : "!=");
1683 pp_c_whitespace (pp);
1684 pp_c_relational_expression (pp, TREE_OPERAND (e, 1));
1688 pp_c_relational_expression (pp, e);
1695 AND-expression & equality-equality */
1698 pp_c_and_expression (c_pretty_printer *pp, tree e)
1700 if (TREE_CODE (e) == BIT_AND_EXPR)
1702 pp_c_and_expression (pp, TREE_OPERAND (e, 0));
1703 pp_c_whitespace (pp);
1705 pp_c_whitespace (pp);
1706 pp_c_equality_expression (pp, TREE_OPERAND (e, 1));
1709 pp_c_equality_expression (pp, e);
1712 /* exclusive-OR-expression:
1714 exclusive-OR-expression ^ AND-expression */
1717 pp_c_exclusive_or_expression (c_pretty_printer *pp, tree e)
1719 if (TREE_CODE (e) == BIT_XOR_EXPR)
1721 pp_c_exclusive_or_expression (pp, TREE_OPERAND (e, 0));
1722 pp_c_maybe_whitespace (pp);
1724 pp_c_whitespace (pp);
1725 pp_c_and_expression (pp, TREE_OPERAND (e, 1));
1728 pp_c_and_expression (pp, e);
1731 /* inclusive-OR-expression:
1732 exclusive-OR-expression
1733 inclusive-OR-expression | exclusive-OR-expression */
1736 pp_c_inclusive_or_expression (c_pretty_printer *pp, tree e)
1738 if (TREE_CODE (e) == BIT_IOR_EXPR)
1740 pp_c_exclusive_or_expression (pp, TREE_OPERAND (e, 0));
1741 pp_c_whitespace (pp);
1743 pp_c_whitespace (pp);
1744 pp_c_exclusive_or_expression (pp, TREE_OPERAND (e, 1));
1747 pp_c_exclusive_or_expression (pp, e);
1750 /* logical-AND-expression:
1751 inclusive-OR-expression
1752 logical-AND-expression && inclusive-OR-expression */
1755 pp_c_logical_and_expression (c_pretty_printer *pp, tree e)
1757 if (TREE_CODE (e) == TRUTH_ANDIF_EXPR)
1759 pp_c_logical_and_expression (pp, TREE_OPERAND (e, 0));
1760 pp_c_whitespace (pp);
1761 pp_identifier (pp, "&&");
1762 pp_c_whitespace (pp);
1763 pp_c_inclusive_or_expression (pp, TREE_OPERAND (e, 1));
1766 pp_c_inclusive_or_expression (pp, e);
1769 /* logical-OR-expression:
1770 logical-AND-expression
1771 logical-OR-expression || logical-AND-expression */
1774 pp_c_logical_or_expression (c_pretty_printer *pp, tree e)
1776 if (TREE_CODE (e) == TRUTH_ORIF_EXPR)
1778 pp_c_logical_or_expression (pp, TREE_OPERAND (e, 0));
1779 pp_c_whitespace (pp);
1780 pp_identifier (pp, "||");
1781 pp_c_whitespace (pp);
1782 pp_c_logical_and_expression (pp, TREE_OPERAND (e, 1));
1785 pp_c_logical_and_expression (pp, e);
1788 /* conditional-expression:
1789 logical-OR-expression
1790 logical-OR-expression ? expression : conditional-expression */
1793 pp_c_conditional_expression (c_pretty_printer *pp, tree e)
1795 if (TREE_CODE (e) == COND_EXPR)
1797 pp_c_logical_or_expression (pp, TREE_OPERAND (e, 0));
1798 pp_c_whitespace (pp);
1800 pp_c_whitespace (pp);
1801 pp_expression (pp, TREE_OPERAND (e, 1));
1802 pp_c_whitespace (pp);
1804 pp_c_whitespace (pp);
1805 pp_c_conditional_expression (pp, TREE_OPERAND (e, 2));
1808 pp_c_logical_or_expression (pp, e);
1812 /* assignment-expression:
1813 conditional-expression
1814 unary-expression assignment-operator assignment-expression
1816 assignment-expression: one of
1817 = *= /= %= += -= >>= <<= &= ^= |= */
1820 pp_c_assignment_expression (c_pretty_printer *pp, tree e)
1822 if (TREE_CODE (e) == MODIFY_EXPR || TREE_CODE (e) == INIT_EXPR)
1824 pp_c_unary_expression (pp, TREE_OPERAND (e, 0));
1825 pp_c_whitespace (pp);
1828 pp_c_expression (pp, TREE_OPERAND (e, 1));
1831 pp_c_conditional_expression (pp, e);
1835 assignment-expression
1836 expression , assignment-expression
1838 Implementation note: instead of going through the usual recursion
1839 chain, I take the liberty of dispatching nodes to the appropriate
1840 functions. This makes some redundancy, but it worths it. That also
1841 prevents a possible infinite recursion between pp_c_primary_expression ()
1842 and pp_c_expression (). */
1845 pp_c_expression (c_pretty_printer *pp, tree e)
1847 switch (TREE_CODE (e))
1850 pp_c_integer_constant (pp, e);
1854 pp_c_floating_constant (pp, e);
1858 pp_c_string_literal (pp, e);
1861 case IDENTIFIER_NODE:
1870 pp_primary_expression (pp, e);
1873 case POSTINCREMENT_EXPR:
1874 case POSTDECREMENT_EXPR:
1882 case UNORDERED_EXPR:
1891 case COMPOUND_LITERAL_EXPR:
1893 pp_postfix_expression (pp, e);
1901 case TRUTH_NOT_EXPR:
1902 case PREINCREMENT_EXPR:
1903 case PREDECREMENT_EXPR:
1906 pp_c_unary_expression (pp, e);
1910 case FIX_TRUNC_EXPR:
1913 pp_c_cast_expression (pp, e);
1917 case TRUNC_MOD_EXPR:
1918 case TRUNC_DIV_EXPR:
1919 pp_multiplicative_expression (pp, e);
1924 pp_c_shift_expression (pp, e);
1931 pp_c_relational_expression (pp, e);
1935 pp_c_and_expression (pp, e);
1939 pp_c_exclusive_or_expression (pp, e);
1943 pp_c_inclusive_or_expression (pp, e);
1946 case TRUTH_ANDIF_EXPR:
1947 pp_c_logical_and_expression (pp, e);
1950 case TRUTH_ORIF_EXPR:
1951 pp_c_logical_or_expression (pp, e);
1956 pp_c_equality_expression (pp, e);
1960 pp_conditional_expression (pp, e);
1965 pp_c_additive_expression (pp, e);
1970 pp_assignment_expression (pp, e);
1974 pp_c_left_paren (pp);
1975 pp_expression (pp, TREE_OPERAND (e, 0));
1976 pp_separate_with (pp, ',');
1977 pp_assignment_expression (pp, TREE_OPERAND (e, 1));
1978 pp_c_right_paren (pp);
1981 case NON_LVALUE_EXPR:
1983 pp_expression (pp, TREE_OPERAND (e, 0));
1987 pp_postfix_expression (pp, TREE_OPERAND (e, 1));
1991 pp_unsupported_tree (pp, e);
2001 pp_c_statement (c_pretty_printer *pp, tree stmt)
2006 if (pp_needs_newline (pp))
2007 pp_newline_and_indent (pp, 0);
2009 dump_generic_node (pp_base (pp), stmt, pp_indentation (pp), 0, true);
2013 /* Initialize the PRETTY-PRINTER for handling C codes. */
2016 pp_c_pretty_printer_init (c_pretty_printer *pp)
2018 pp->offset_list = 0;
2020 pp->declaration = pp_c_declaration;
2021 pp->declaration_specifiers = pp_c_declaration_specifiers;
2022 pp->declarator = pp_c_declarator;
2023 pp->direct_declarator = pp_c_direct_declarator;
2024 pp->type_specifier_seq = pp_c_specifier_qualifier_list;
2025 pp->abstract_declarator = pp_c_abstract_declarator;
2026 pp->direct_abstract_declarator = pp_c_direct_abstract_declarator;
2027 pp->ptr_operator = pp_c_pointer;
2028 pp->parameter_list = pp_c_parameter_type_list;
2029 pp->type_id = pp_c_type_id;
2030 pp->simple_type_specifier = pp_c_type_specifier;
2031 pp->function_specifier = pp_c_function_specifier;
2032 pp->storage_class_specifier = pp_c_storage_class_specifier;
2034 pp->statement = pp_c_statement;
2036 pp->constant = pp_c_constant;
2037 pp->id_expression = pp_c_id_expression;
2038 pp->primary_expression = pp_c_primary_expression;
2039 pp->postfix_expression = pp_c_postfix_expression;
2040 pp->unary_expression = pp_c_unary_expression;
2041 pp->initializer = pp_c_initializer;
2042 pp->multiplicative_expression = pp_c_multiplicative_expression;
2043 pp->conditional_expression = pp_c_conditional_expression;
2044 pp->assignment_expression = pp_c_assignment_expression;
2045 pp->expression = pp_c_expression;
2049 /* Print the tree T in full, on file FILE. */
2052 print_c_tree (FILE *file, tree t)
2054 static c_pretty_printer pp_rec;
2055 static bool initialized = 0;
2056 c_pretty_printer *pp = &pp_rec;
2061 pp_construct (pp_base (pp), NULL, 0);
2062 pp_c_pretty_printer_init (pp);
2063 pp_needs_newline (pp) = true;
2065 pp_base (pp)->buffer->stream = file;
2067 pp_statement (pp, t);
2073 /* Print the tree T in full, on stderr. */
2076 debug_c_tree (tree t)
2078 print_c_tree (stderr, t);
2079 fputc ('\n', stderr);
2082 /* Output the DECL_NAME of T. If T has no DECL_NAME, output a string made
2083 up of T's memory address. */
2086 pp_c_tree_decl_identifier (c_pretty_printer *pp, tree t)
2090 gcc_assert (DECL_P (t));
2093 name = IDENTIFIER_POINTER (DECL_NAME (t));
2096 static char xname[8];
2097 sprintf (xname, "<U%4x>", ((unsigned)((unsigned long)(t) & 0xffff)));
2101 pp_c_identifier (pp, name);