1 /* Implementation of subroutines for the GNU C++ pretty-printer.
2 Copyright (C) 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, 59 Temple Place - Suite 330, Boston, MA
24 #include "coretypes.h"
27 #include "cxx-pretty-print.h"
31 static void pp_cxx_unqualified_id (cxx_pretty_printer *, tree);
32 static void pp_cxx_nested_name_specifier (cxx_pretty_printer *, tree);
33 static void pp_cxx_qualified_id (cxx_pretty_printer *, tree);
34 static void pp_cxx_assignment_expression (cxx_pretty_printer *, tree);
35 static void pp_cxx_expression (cxx_pretty_printer *, tree);
36 static void pp_cxx_template_argument_list (cxx_pretty_printer *, tree);
37 static void pp_cxx_type_specifier_seq (cxx_pretty_printer *, tree);
38 static void pp_cxx_ptr_operator (cxx_pretty_printer *, tree);
39 static void pp_cxx_type_id (cxx_pretty_printer *, tree);
40 static void pp_cxx_direct_abstract_declarator (cxx_pretty_printer *, tree);
41 static void pp_cxx_declarator (cxx_pretty_printer *, tree);
42 static void pp_cxx_parameter_declaration_clause (cxx_pretty_printer *, tree);
43 static void pp_cxx_abstract_declarator (cxx_pretty_printer *, tree);
44 static void pp_cxx_statement (cxx_pretty_printer *, tree);
45 static void pp_cxx_template_parameter (cxx_pretty_printer *, tree);
49 pp_cxx_nonconsecutive_character (cxx_pretty_printer *pp, int c)
51 const char *p = pp_last_position_in_text (pp);
53 if (p != NULL && *p == c)
54 pp_cxx_whitespace (pp);
56 pp_base (pp)->padding = pp_none;
59 #define pp_cxx_storage_class_specifier(PP, T) \
60 pp_c_storage_class_specifier (pp_c_base (PP), T)
61 #define pp_cxx_expression_list(PP, T) \
62 pp_c_expression_list (pp_c_base (PP), T)
63 #define pp_cxx_space_for_pointer_operator(PP, T) \
64 pp_c_space_for_pointer_operator (pp_c_base (PP), T)
65 #define pp_cxx_init_declarator(PP, T) \
66 pp_c_init_declarator (pp_c_base (PP), T)
67 #define pp_cxx_call_argument_list(PP, T) \
68 pp_c_call_argument_list (pp_c_base (PP), T)
71 pp_cxx_colon_colon (cxx_pretty_printer *pp)
74 pp_base (pp)->padding = pp_none;
78 pp_cxx_begin_template_argument_list (cxx_pretty_printer *pp)
80 pp_cxx_nonconsecutive_character (pp, '<');
84 pp_cxx_end_template_argument_list (cxx_pretty_printer *pp)
86 pp_cxx_nonconsecutive_character (pp, '>');
90 pp_cxx_separate_with (cxx_pretty_printer *pp, int c)
92 pp_separate_with (pp, c);
93 pp_base (pp)->padding = pp_none;
99 is_destructor_name (tree name)
101 return name == complete_dtor_identifier
102 || name == base_dtor_identifier
103 || name == deleting_dtor_identifier;
106 /* conversion-function-id:
107 operator conversion-type-id
110 type-specifier-seq conversion-declarator(opt)
112 conversion-declarator:
113 ptr-operator conversion-declarator(opt) */
116 pp_cxx_conversion_function_id (cxx_pretty_printer *pp, tree t)
118 pp_cxx_identifier (pp, "operator");
119 pp_cxx_type_specifier_seq (pp, TREE_TYPE (t));
123 pp_cxx_template_id (cxx_pretty_printer *pp, tree t)
125 pp_cxx_unqualified_id (pp, TREE_OPERAND (t, 0));
126 pp_cxx_begin_template_argument_list (pp);
127 pp_cxx_template_argument_list (pp, TREE_OPERAND (t, 1));
128 pp_cxx_end_template_argument_list (pp);
134 conversion-function-id
139 pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t)
141 enum tree_code code = TREE_CODE (t);
145 pp_cxx_identifier (pp, "<return-value>");
162 case IDENTIFIER_NODE:
164 pp_cxx_identifier (pp, "<unnamed>");
165 else if (IDENTIFIER_TYPENAME_P (t))
166 pp_cxx_conversion_function_id (pp, t);
169 if (is_destructor_name (t))
172 /* FIXME: Why is this necessary? */
174 t = constructor_name (TREE_TYPE (t));
176 pp_cxx_tree_identifier (pp, t);
180 case TEMPLATE_ID_EXPR:
181 pp_cxx_template_id (pp, t);
185 pp_cxx_unqualified_id (pp, BASELINK_FUNCTIONS (t));
191 pp_cxx_unqualified_id (pp, TYPE_NAME (t));
194 case TEMPLATE_TYPE_PARM:
195 case TEMPLATE_TEMPLATE_PARM:
196 if (TYPE_IDENTIFIER (t))
197 pp_cxx_unqualified_id (pp, TYPE_IDENTIFIER (t));
199 pp_cxx_canonical_template_parameter (pp, t);
202 case TEMPLATE_PARM_INDEX:
203 pp_cxx_unqualified_id (pp, TEMPLATE_PARM_DECL (t));
207 pp_unsupported_tree (pp, t);
212 /* Pretty-print out the token sequence ":: template" in template codes
213 where it is needed to "inline declare" the (following) member as
214 a template. This situation arises when SCOPE of T is dependent
215 on template parameters. */
218 pp_cxx_template_keyword_if_needed (cxx_pretty_printer *pp, tree scope, tree t)
220 if (TREE_CODE (t) == TEMPLATE_ID_EXPR
221 && TYPE_P (scope) && dependent_type_p (scope))
222 pp_cxx_identifier (pp, "template");
225 /* nested-name-specifier:
226 class-or-namespace-name :: nested-name-specifier(opt)
227 class-or-namespace-name :: template nested-name-specifier */
230 pp_cxx_nested_name_specifier (cxx_pretty_printer *pp, tree t)
232 if (t != NULL && t != pp->enclosing_scope)
234 tree scope = TYPE_P (t) ? TYPE_CONTEXT (t) : DECL_CONTEXT (t);
235 pp_cxx_nested_name_specifier (pp, scope);
236 pp_cxx_template_keyword_if_needed (pp, scope, t);
237 pp_cxx_unqualified_id (pp, t);
238 pp_cxx_colon_colon (pp);
243 nested-name-specifier template(opt) unqualified-id */
246 pp_cxx_qualified_id (cxx_pretty_printer *pp, tree t)
248 switch (TREE_CODE (t))
250 /* A pointer-to-member is always qualified. */
252 pp_cxx_nested_name_specifier (pp, PTRMEM_CST_CLASS (t));
253 pp_cxx_unqualified_id (pp, PTRMEM_CST_MEMBER (t));
256 /* In Standard C++, functions cannot possibly be used as
257 nested-name-specifiers. However, there are situations where
258 is "makes sense" to output the surrounding function name for the
259 purpose of emphasizing on the scope kind. Just printing the
260 function name might not be sufficient as it may be overloaded; so,
261 we decorate the function with its signature too.
262 FIXME: This is probably the wrong pretty-printing for conversion
263 functions and some function templates. */
267 if (DECL_FUNCTION_MEMBER_P (t))
268 pp_cxx_nested_name_specifier (pp, DECL_CONTEXT (t));
269 pp_cxx_unqualified_id
270 (pp, DECL_CONSTRUCTOR_P (t) ? DECL_CONTEXT (t) : t);
271 pp_cxx_parameter_declaration_clause (pp, TREE_TYPE (t));
276 pp_cxx_nested_name_specifier (pp, TREE_OPERAND (t, 0));
277 pp_cxx_unqualified_id (pp, TREE_OPERAND (t, 1));
282 tree scope = TYPE_P (t) ? TYPE_CONTEXT (t) : DECL_CONTEXT (t);
283 if (scope != pp->enclosing_scope)
285 pp_cxx_nested_name_specifier (pp, scope);
286 pp_cxx_template_keyword_if_needed (pp, scope, t);
288 pp_cxx_unqualified_id (pp, t);
299 pp_cxx_id_expression (cxx_pretty_printer *pp, tree t)
301 if (TREE_CODE (t) == OVERLOAD)
303 if (DECL_P (t) && DECL_CONTEXT (t))
304 pp_cxx_qualified_id (pp, t);
306 pp_cxx_unqualified_id (pp, t);
309 /* primary-expression:
313 :: operator-function-id
319 pp_cxx_primary_expression (cxx_pretty_printer *pp, tree t)
321 switch (TREE_CODE (t))
326 pp_c_constant (pp_c_base (pp), t);
330 t = BASELINK_FUNCTIONS (t);
338 pp_cxx_id_expression (pp, t);
342 case TEMPLATE_TYPE_PARM:
343 case TEMPLATE_TEMPLATE_PARM:
344 case TEMPLATE_PARM_INDEX:
345 pp_cxx_unqualified_id (pp, t);
349 pp_cxx_left_paren (pp);
350 pp_cxx_statement (pp, STMT_EXPR_STMT (t));
351 pp_cxx_right_paren (pp);
355 pp_c_primary_expression (pp_c_base (pp), t);
360 /* postfix-expression:
362 postfix-expression [ expression ]
363 postfix-expression ( expression-list(opt) )
364 simple-type-specifier ( expression-list(opt) )
365 typename ::(opt) nested-name-specifier identifier ( expression-list(opt) )
366 typename ::(opt) nested-name-specifier template(opt)
367 template-id ( expression-list(opt) )
368 postfix-expression . template(opt) ::(opt) id-expression
369 postfix-expression -> template(opt) ::(opt) id-expression
370 postfix-expression . pseudo-destructor-name
371 postfix-expression -> pseudo-destructor-name
372 postfix-expression ++
373 postfix-expression --
374 dynamic_cast < type-id > ( expression )
375 static_cast < type-id > ( expression )
376 reinterpret_cast < type-id > ( expression )
377 const_cast < type-id > ( expression )
378 typeid ( expression )
379 typeif ( type-id ) */
382 pp_cxx_postfix_expression (cxx_pretty_printer *pp, tree t)
384 enum tree_code code = TREE_CODE (t);
391 tree fun = TREE_OPERAND (t, 0);
392 tree args = TREE_OPERAND (t, 1);
393 tree saved_scope = pp->enclosing_scope;
395 if (TREE_CODE (fun) == ADDR_EXPR)
396 fun = TREE_OPERAND (fun, 0);
398 /* In templates, where there is no way to tell whether a given
399 call uses an actual member function. So the parser builds
400 FUN as a COMPONENT_REF or a plain IDENTIFIER_NODE until
401 instantiation time. */
402 if (TREE_CODE (fun) != FUNCTION_DECL)
404 else if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fun))
406 tree object = code == AGGR_INIT_EXPR && AGGR_INIT_VIA_CTOR_P (t)
407 ? TREE_OPERAND (t, 2)
410 while (TREE_CODE (object) == NOP_EXPR)
411 object = TREE_OPERAND (object, 0);
413 if (TREE_CODE (object) == ADDR_EXPR)
414 object = TREE_OPERAND (object, 0);
416 if (TREE_CODE (TREE_TYPE (object)) != POINTER_TYPE)
418 pp_cxx_postfix_expression (pp, object);
423 pp_cxx_postfix_expression (pp, object);
426 args = TREE_CHAIN (args);
427 pp->enclosing_scope = strip_pointer_operator (TREE_TYPE (object));
430 pp_cxx_postfix_expression (pp, fun);
431 pp->enclosing_scope = saved_scope;
432 pp_cxx_call_argument_list (pp, args);
434 if (code == AGGR_INIT_EXPR && AGGR_INIT_VIA_CTOR_P (t))
436 pp_cxx_separate_with (pp, ',');
437 pp_cxx_postfix_expression (pp, TREE_OPERAND (t, 2));
450 pp_cxx_primary_expression (pp, t);
453 case DYNAMIC_CAST_EXPR:
454 case STATIC_CAST_EXPR:
455 case REINTERPRET_CAST_EXPR:
456 case CONST_CAST_EXPR:
457 if (code == DYNAMIC_CAST_EXPR)
458 pp_cxx_identifier (pp, "dynamic_cast");
459 else if (code == STATIC_CAST_EXPR)
460 pp_cxx_identifier (pp, "static_cast");
461 else if (code == REINTERPRET_CAST_EXPR)
462 pp_cxx_identifier (pp, "reinterpret_cast");
464 pp_cxx_identifier (pp, "const_cast");
465 pp_cxx_begin_template_argument_list (pp);
466 pp_cxx_type_id (pp, TREE_TYPE (t));
467 pp_cxx_end_template_argument_list (pp);
469 pp_cxx_expression (pp, TREE_OPERAND (t, 0));
473 case EMPTY_CLASS_EXPR:
474 pp_cxx_type_id (pp, TREE_TYPE (t));
480 t = TREE_OPERAND (t, 0);
481 pp_cxx_identifier (pp, "typeid");
484 pp_cxx_type_id (pp, t);
486 pp_cxx_expression (pp, t);
490 case PSEUDO_DTOR_EXPR:
491 pp_cxx_postfix_expression (pp, TREE_OPERAND (t, 0));
493 pp_cxx_qualified_id (pp, TREE_OPERAND (t, 1));
494 pp_cxx_colon_colon (pp);
496 pp_cxx_unqualified_id (pp, TREE_OPERAND (t, 2));
500 pp_cxx_postfix_expression (pp, TREE_OPERAND (t, 0));
505 pp_c_postfix_expression (pp_c_base (pp), t);
511 ::(opt) new new-placement(opt) new-type-id new-initializer(opt)
512 ::(opt) new new-placement(opt) ( type-id ) new-initializer(opt)
518 type-specifier-seq new-declarator(opt)
521 ptr-operator new-declarator(opt)
522 direct-new-declarator
524 direct-new-declarator
526 direct-new-declarator [ constant-expression ]
529 ( expression-list(opt) ) */
532 pp_cxx_new_expression (cxx_pretty_printer *pp, tree t)
534 enum tree_code code = TREE_CODE (t);
539 if (NEW_EXPR_USE_GLOBAL (t))
540 pp_cxx_colon_colon (pp);
541 pp_cxx_identifier (pp, "new");
542 if (TREE_OPERAND (t, 0))
544 pp_cxx_call_argument_list (pp, TREE_OPERAND (t, 0));
547 /* FIXME: array-types are built with one more element. */
548 pp_cxx_type_id (pp, TREE_OPERAND (t, 1));
549 if (TREE_OPERAND (t, 2))
552 t = TREE_OPERAND (t, 2);
553 if (TREE_CODE (t) == TREE_LIST)
554 pp_c_expression_list (pp_c_base (pp), t);
555 else if (t == void_zero_node)
556 ; /* OK, empty initializer list. */
558 pp_cxx_expression (pp, t);
564 pp_unsupported_tree (pp, t);
568 /* delete-expression:
569 ::(opt) delete cast-expression
570 ::(opt) delete [ ] cast-expression */
573 pp_cxx_delete_expression (cxx_pretty_printer *pp, tree t)
575 enum tree_code code = TREE_CODE (t);
579 case VEC_DELETE_EXPR:
580 if (DELETE_EXPR_USE_GLOBAL (t))
581 pp_cxx_colon_colon (pp);
582 pp_cxx_identifier (pp, "delete");
583 if (code == VEC_DELETE_EXPR)
585 pp_left_bracket (pp);
586 pp_right_bracket (pp);
588 pp_c_cast_expression (pp_c_base (pp), TREE_OPERAND (t, 0));
592 pp_unsupported_tree (pp, t);
600 unary-operator cast-expression
601 sizeof unary-expression
606 unary-operator: one of
610 __alignof__ unary-expression
611 __alignof__ ( type-id ) */
614 pp_cxx_unary_expression (cxx_pretty_printer *pp, tree t)
616 enum tree_code code = TREE_CODE (t);
621 pp_cxx_new_expression (pp, t);
625 case VEC_DELETE_EXPR:
626 pp_cxx_delete_expression (pp, t);
631 pp_cxx_identifier (pp, code == SIZEOF_EXPR ? "sizeof" : "__alignof__");
632 pp_cxx_whitespace (pp);
633 if (TYPE_P (TREE_OPERAND (t, 0)))
635 pp_cxx_left_paren (pp);
636 pp_cxx_type_id (pp, TREE_OPERAND (t, 0));
637 pp_cxx_right_paren (pp);
640 pp_unary_expression (pp, TREE_OPERAND (t, 0));
644 pp_c_unary_expression (pp_c_base (pp), t);
651 ( type-id ) cast-expression */
654 pp_cxx_cast_expression (cxx_pretty_printer *pp, tree t)
656 switch (TREE_CODE (t))
659 pp_cxx_type_id (pp, TREE_TYPE (t));
660 pp_cxx_call_argument_list (pp, TREE_OPERAND (t, 0));
664 pp_c_cast_expression (pp_c_base (pp), t);
671 pm-expression .* cast-expression
672 pm-expression ->* cast-expression */
675 pp_cxx_pm_expression (cxx_pretty_printer *pp, tree t)
677 switch (TREE_CODE (t))
679 /* Handle unfortunate OFFESET_REF overloading here. */
681 if (TYPE_P (TREE_OPERAND (t, 0)))
683 pp_cxx_qualified_id (pp, t);
686 /* Else fall through. */
689 pp_cxx_pm_expression (pp, TREE_OPERAND (t, 0));
692 pp_cxx_cast_expression (pp, TREE_OPERAND (t, 1));
697 pp_cxx_cast_expression (pp, t);
702 /* multiplicative-expression:
704 multiplicative-expression * pm-expression
705 multiplicative-expression / pm-expression
706 multiplicative-expression % pm-expression */
709 pp_cxx_multiplicative_expression (cxx_pretty_printer *pp, tree e)
711 enum tree_code code = TREE_CODE (e);
717 pp_cxx_multiplicative_expression (pp, TREE_OPERAND (e, 0));
719 if (code == MULT_EXPR)
721 else if (code == TRUNC_DIV_EXPR)
726 pp_cxx_pm_expression (pp, TREE_OPERAND (e, 1));
730 pp_cxx_pm_expression (pp, e);
735 /* conditional-expression:
736 logical-or-expression
737 logical-or-expression ? expression : assignment-expression */
740 pp_cxx_conditional_expression (cxx_pretty_printer *pp, tree e)
742 if (TREE_CODE (e) == COND_EXPR)
744 pp_c_logical_or_expression (pp_c_base (pp), TREE_OPERAND (e, 0));
748 pp_cxx_expression (pp, TREE_OPERAND (e, 1));
750 pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 2));
753 pp_c_logical_or_expression (pp_c_base (pp), e);
756 /* Pretty-print a compound assignment operator token as indicated by T. */
759 pp_cxx_assignment_operator (cxx_pretty_printer *pp, tree t)
763 switch (TREE_CODE (t))
786 op = tree_code_name[TREE_CODE (t)];
790 pp_cxx_identifier (pp, op);
794 /* assignment-expression:
795 conditional-expression
796 logical-or-expression assignment-operator assignment-expression
800 throw assignment-expression(opt)
802 assignment-operator: one of
803 = *= /= %= += -= >>= <<= &= ^= |= */
806 pp_cxx_assignment_expression (cxx_pretty_printer *pp, tree e)
808 switch (TREE_CODE (e))
812 pp_c_logical_or_expression (pp_c_base (pp), TREE_OPERAND (e, 0));
816 pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 1));
820 pp_cxx_identifier (pp, "throw");
821 if (TREE_OPERAND (e, 0))
822 pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 0));
826 pp_c_logical_or_expression (pp_c_base (pp), TREE_OPERAND (e, 0));
827 pp_cxx_assignment_operator (pp, TREE_OPERAND (e, 1));
828 pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 2));
832 pp_cxx_conditional_expression (pp, e);
838 pp_cxx_expression (cxx_pretty_printer *pp, tree t)
840 switch (TREE_CODE (t))
845 pp_c_constant (pp_c_base (pp), t);
849 pp_cxx_unqualified_id (pp, t);
857 pp_cxx_qualified_id (pp, t);
869 case TEMPLATE_TYPE_PARM:
870 case TEMPLATE_PARM_INDEX:
871 case TEMPLATE_TEMPLATE_PARM:
873 pp_cxx_primary_expression (pp, t);
877 case DYNAMIC_CAST_EXPR:
878 case STATIC_CAST_EXPR:
879 case REINTERPRET_CAST_EXPR:
880 case CONST_CAST_EXPR:
884 case EMPTY_CLASS_EXPR:
886 case PSEUDO_DTOR_EXPR:
889 pp_cxx_postfix_expression (pp, t);
894 pp_cxx_new_expression (pp, t);
898 case VEC_DELETE_EXPR:
899 pp_cxx_delete_expression (pp, t);
904 pp_cxx_unary_expression (pp, t);
908 pp_cxx_cast_expression (pp, t);
914 pp_cxx_pm_expression (pp, t);
920 pp_cxx_multiplicative_expression (pp, t);
924 pp_cxx_conditional_expression (pp, t);
931 pp_cxx_assignment_expression (pp, t);
934 case NON_DEPENDENT_EXPR:
935 case MUST_NOT_THROW_EXPR:
936 pp_cxx_expression (pp, t);
940 pp_c_expression (pp_c_base (pp), t);
948 /* function-specifier:
954 pp_cxx_function_specifier (cxx_pretty_printer *pp, tree t)
956 switch (TREE_CODE (t))
959 if (DECL_VIRTUAL_P (t))
960 pp_cxx_identifier (pp, "virtual");
961 else if (DECL_CONSTRUCTOR_P (t) && DECL_NONCONVERTING_P (t))
962 pp_cxx_identifier (pp, "explicit");
964 pp_c_function_specifier (pp_c_base (pp), t);
971 /* decl-specifier-seq:
972 decl-specifier-seq(opt) decl-specifier
975 storage-class-specifier
982 pp_cxx_decl_specifier_seq (cxx_pretty_printer *pp, tree t)
984 switch (TREE_CODE (t))
990 pp_cxx_storage_class_specifier (pp, t);
991 pp_cxx_decl_specifier_seq (pp, TREE_TYPE (t));
995 pp_cxx_identifier (pp, "typedef");
996 pp_cxx_decl_specifier_seq (pp, TREE_TYPE (t));
1000 if (TYPE_PTRMEMFUNC_P (t))
1002 tree pfm = TYPE_PTRMEMFUNC_FN_TYPE (t);
1003 pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (pfm)));
1004 pp_cxx_whitespace (pp);
1005 pp_cxx_ptr_operator (pp, t);
1010 /* Constructors don't have return types. And conversion functions
1011 do not have a type-specifier in their return types. */
1012 if (DECL_CONSTRUCTOR_P (t) || DECL_CONV_FN_P (t))
1013 pp_cxx_function_specifier (pp, t);
1014 else if (DECL_NONSTATIC_MEMBER_FUNCTION_P (t))
1015 pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (t)));
1018 pp_c_declaration_specifiers (pp_c_base (pp), t);
1023 /* simple-type-specifier:
1024 ::(opt) nested-name-specifier(opt) type-name
1025 ::(opt) nested-name-specifier(opt) template(opt) template-id
1039 pp_cxx_simple_type_specifier (cxx_pretty_printer *pp, tree t)
1041 switch (TREE_CODE (t))
1046 pp_cxx_qualified_id (pp, t);
1049 case TEMPLATE_TYPE_PARM:
1050 case TEMPLATE_TEMPLATE_PARM:
1051 case TEMPLATE_PARM_INDEX:
1052 pp_cxx_unqualified_id (pp, t);
1056 pp_cxx_identifier (pp, "typename");
1057 pp_cxx_nested_name_specifier (pp, TYPE_CONTEXT (t));
1058 pp_cxx_unqualified_id (pp, TYPE_NAME (t));
1062 pp_c_type_specifier (pp_c_base (pp), t);
1067 /* type-specifier-seq:
1068 type-specifier type-specifier-seq(opt)
1071 simple-type-specifier
1074 elaborated-type-specifier
1078 pp_cxx_type_specifier_seq (cxx_pretty_printer *pp, tree t)
1080 switch (TREE_CODE (t))
1083 case TEMPLATE_TYPE_PARM:
1084 case TEMPLATE_TEMPLATE_PARM:
1086 case BOUND_TEMPLATE_TEMPLATE_PARM:
1087 pp_cxx_cv_qualifier_seq (pp, t);
1088 pp_cxx_simple_type_specifier (pp, t);
1092 pp_cxx_type_specifier_seq (pp, TREE_TYPE (t));
1093 pp_cxx_space_for_pointer_operator (pp, TREE_TYPE (t));
1094 pp_cxx_nested_name_specifier (pp, TYPE_METHOD_BASETYPE (t));
1098 if (!(TREE_CODE (t) == FUNCTION_DECL && DECL_CONSTRUCTOR_P (t)))
1099 pp_c_specifier_qualifier_list (pp_c_base (pp), t);
1104 * cv-qualifier-seq(opt)
1106 ::(opt) nested-name-specifier * cv-qualifier-seq(opt) */
1109 pp_cxx_ptr_operator (cxx_pretty_printer *pp, tree t)
1111 if (!TYPE_P (t) && TREE_CODE (t) != TYPE_DECL)
1113 switch (TREE_CODE (t))
1115 case REFERENCE_TYPE:
1117 if (TREE_CODE (TREE_TYPE (t)) == POINTER_TYPE
1118 || TYPE_PTR_TO_MEMBER_P (TREE_TYPE (t)))
1119 pp_cxx_ptr_operator (pp, TREE_TYPE (t));
1120 if (TREE_CODE (t) == POINTER_TYPE)
1123 pp_cxx_cv_qualifier_seq (pp, t);
1130 if (TYPE_PTRMEMFUNC_P (t))
1132 pp_cxx_left_paren (pp);
1133 pp_cxx_nested_name_specifier (pp, TYPE_PTRMEMFUNC_OBJECT_TYPE (t));
1138 if (TYPE_PTR_TO_MEMBER_P (t))
1140 if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
1141 pp_cxx_left_paren (pp);
1142 pp_cxx_nested_name_specifier (pp, TYPE_PTRMEM_CLASS_TYPE (t));
1144 pp_cxx_cv_qualifier_seq (pp, t);
1147 /* else fall through. */
1150 pp_unsupported_tree (pp, t);
1156 pp_cxx_implicit_parameter_type (tree mf)
1158 return TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (mf))));
1162 parameter-declaration:
1163 decl-specifier-seq declarator
1164 decl-specifier-seq declarator = assignment-expression
1165 decl-specifier-seq abstract-declarator(opt)
1166 decl-specifier-seq abstract-declarator(opt) assignment-expression */
1169 pp_cxx_parameter_declaration (cxx_pretty_printer *pp, tree t)
1171 pp_cxx_decl_specifier_seq (pp, t);
1173 pp_cxx_abstract_declarator (pp, t);
1175 pp_cxx_declarator (pp, t);
1178 /* parameter-declaration-clause:
1179 parameter-declaration-list(opt) ...(opt)
1180 parameter-declaration-list , ...
1182 parameter-declaration-list:
1183 parameter-declaration
1184 parameter-declaration-list , parameter-declaration */
1187 pp_cxx_parameter_declaration_clause (cxx_pretty_printer *pp, tree t)
1189 tree args = TYPE_P (t) ? NULL : FUNCTION_FIRST_USER_PARM (t);
1191 TYPE_P (t) ? TYPE_ARG_TYPES (t) : FUNCTION_FIRST_USER_PARMTYPE (t);
1192 const bool abstract = args == NULL
1193 || pp_c_base (pp)->flags & pp_c_flag_abstract;
1196 /* Skip artificial parameter for nonstatic member functions. */
1197 if (TREE_CODE (t) == METHOD_TYPE)
1198 types = TREE_CHAIN (types);
1200 pp_cxx_left_paren (pp);
1201 for (; args; args = TREE_CHAIN (args), types = TREE_CHAIN (types))
1204 pp_cxx_separate_with (pp, ',');
1206 pp_cxx_parameter_declaration (pp, abstract ? TREE_VALUE (types) : args);
1207 if (!abstract && pp_c_base (pp)->flags & pp_cxx_flag_default_argument)
1209 pp_cxx_whitespace (pp);
1211 pp_cxx_whitespace (pp);
1212 pp_cxx_assignment_expression (pp, TREE_PURPOSE (types));
1215 pp_cxx_right_paren (pp);
1218 /* exception-specification:
1219 throw ( type-id-list(opt) )
1223 type-id-list , type-id */
1226 pp_cxx_exception_specification (cxx_pretty_printer *pp, tree t)
1228 tree ex_spec = TYPE_RAISES_EXCEPTIONS (t);
1230 if (!TYPE_NOTHROW_P (t) && ex_spec == NULL)
1232 pp_cxx_identifier (pp, "throw");
1233 pp_cxx_left_paren (pp);
1234 for (; ex_spec && TREE_VALUE (ex_spec); ex_spec = TREE_CHAIN (ex_spec))
1236 pp_cxx_type_id (pp, TREE_VALUE (ex_spec));
1237 if (TREE_CHAIN (ex_spec))
1238 pp_cxx_separate_with (pp, ',');
1240 pp_cxx_right_paren (pp);
1243 /* direct-declarator:
1245 direct-declarator ( parameter-declaration-clause ) cv-qualifier-seq(opt)
1246 exception-specification(opt)
1247 direct-declaration [ constant-expression(opt) ]
1251 pp_cxx_direct_declarator (cxx_pretty_printer *pp, tree t)
1253 switch (TREE_CODE (t))
1261 pp_cxx_space_for_pointer_operator (pp, TREE_TYPE (t));
1262 pp_cxx_id_expression (pp, DECL_NAME (t));
1264 pp_cxx_abstract_declarator (pp, TREE_TYPE (t));
1268 pp_cxx_space_for_pointer_operator (pp, TREE_TYPE (TREE_TYPE (t)));
1269 pp_cxx_id_expression (pp, t);
1270 pp_cxx_parameter_declaration_clause (pp, t);
1272 if (DECL_NONSTATIC_MEMBER_FUNCTION_P (t))
1274 pp_base (pp)->padding = pp_before;
1275 pp_cxx_cv_qualifier_seq (pp, pp_cxx_implicit_parameter_type (t));
1278 pp_cxx_exception_specification (pp, TREE_TYPE (t));
1283 case TEMPLATE_TYPE_PARM:
1284 case TEMPLATE_PARM_INDEX:
1285 case TEMPLATE_TEMPLATE_PARM:
1289 pp_c_direct_declarator (pp_c_base (pp), t);
1296 ptr-operator declarator */
1299 pp_cxx_declarator (cxx_pretty_printer *pp, tree t)
1301 pp_cxx_direct_declarator (pp, t);
1304 /* ctor-initializer:
1305 : mem-initializer-list
1307 mem-initializer-list:
1309 mem-initializer , mem-initializer-list
1312 mem-initializer-id ( expression-list(opt) )
1315 ::(opt) nested-name-specifier(opt) class-name
1319 pp_cxx_ctor_initializer (cxx_pretty_printer *pp, tree t)
1321 t = TREE_OPERAND (t, 0);
1322 pp_cxx_whitespace (pp);
1324 pp_cxx_whitespace (pp);
1325 for (; t; t = TREE_CHAIN (t))
1327 pp_cxx_primary_expression (pp, TREE_PURPOSE (t));
1328 pp_cxx_call_argument_list (pp, TREE_VALUE (t));
1330 pp_cxx_separate_with (pp, ',');
1334 /* function-definition:
1335 decl-specifier-seq(opt) declarator ctor-initializer(opt) function-body
1336 decl-specifier-seq(opt) declarator function-try-block */
1339 pp_cxx_function_definition (cxx_pretty_printer *pp, tree t)
1341 tree saved_scope = pp->enclosing_scope;
1342 pp_cxx_decl_specifier_seq (pp, t);
1343 pp_cxx_declarator (pp, t);
1344 pp_needs_newline (pp) = true;
1345 pp->enclosing_scope = DECL_CONTEXT (t);
1346 if (DECL_SAVED_TREE (t))
1347 pp_cxx_statement (pp, DECL_SAVED_TREE (t));
1350 pp_cxx_semicolon (pp);
1351 pp_needs_newline (pp) = true;
1354 pp->enclosing_scope = saved_scope;
1357 /* abstract-declarator:
1358 ptr-operator abstract-declarator(opt)
1359 direct-abstract-declarator */
1362 pp_cxx_abstract_declarator (cxx_pretty_printer *pp, tree t)
1364 if (TYPE_PTRMEM_P (t) || TYPE_PTRMEMFUNC_P (t))
1365 pp_cxx_right_paren (pp);
1366 else if (POINTER_TYPE_P (t))
1368 if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE
1369 || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
1370 pp_cxx_right_paren (pp);
1373 pp_cxx_direct_abstract_declarator (pp, t);
1376 /* direct-abstract-declarator:
1377 direct-abstract-declarator(opt) ( parameter-declaration-clause )
1378 cv-qualifier-seq(opt) exception-specification(opt)
1379 direct-abstract-declarator(opt) [ constant-expression(opt) ]
1380 ( abstract-declarator ) */
1383 pp_cxx_direct_abstract_declarator (cxx_pretty_printer *pp, tree t)
1385 switch (TREE_CODE (t))
1387 case REFERENCE_TYPE:
1388 pp_cxx_abstract_declarator (pp, t);
1392 if (TYPE_PTRMEMFUNC_P (t))
1393 pp_cxx_direct_abstract_declarator (pp, TYPE_PTRMEMFUNC_FN_TYPE (t));
1398 pp_cxx_parameter_declaration_clause (pp, t);
1399 pp_cxx_direct_abstract_declarator (pp, TREE_TYPE (t));
1400 if (TREE_CODE (t) == METHOD_TYPE)
1402 pp_base (pp)->padding = pp_before;
1403 pp_cxx_cv_qualifier_seq
1404 (pp, TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t))));
1406 pp_cxx_exception_specification (pp, t);
1410 case TEMPLATE_TYPE_PARM:
1411 case TEMPLATE_TEMPLATE_PARM:
1412 case BOUND_TEMPLATE_TEMPLATE_PARM:
1413 case UNBOUND_CLASS_TEMPLATE:
1417 pp_c_direct_abstract_declarator (pp_c_base (pp), t);
1423 type-specifier-seq abstract-declarator(opt) */
1426 pp_cxx_type_id (cxx_pretty_printer *pp, tree t)
1428 pp_flags saved_flags = pp_c_base (pp)->flags;
1429 pp_c_base (pp)->flags |= pp_c_flag_abstract;
1431 switch (TREE_CODE (t))
1438 case BOUND_TEMPLATE_TEMPLATE_PARM:
1439 case UNBOUND_CLASS_TEMPLATE:
1440 case TEMPLATE_TEMPLATE_PARM:
1441 case TEMPLATE_TYPE_PARM:
1442 case TEMPLATE_PARM_INDEX:
1445 case TEMPLATE_ID_EXPR:
1446 pp_cxx_type_specifier_seq (pp, t);
1450 pp_c_type_id (pp_c_base (pp), t);
1454 pp_c_base (pp)->flags = saved_flags;
1457 /* template-argument-list:
1459 template-argument-list, template-argument
1462 assignment-expression
1467 pp_cxx_template_argument_list (cxx_pretty_printer *pp, tree t)
1472 for (i = 0; i < TREE_VEC_LENGTH (t); ++i)
1474 tree arg = TREE_VEC_ELT (t, i);
1476 pp_cxx_separate_with (pp, ',');
1477 if (TYPE_P (arg) || (TREE_CODE (arg) == TEMPLATE_DECL
1478 && TYPE_P (DECL_TEMPLATE_RESULT (arg))))
1479 pp_cxx_type_id (pp, arg);
1481 pp_cxx_expression (pp, arg);
1487 pp_cxx_exception_declaration (cxx_pretty_printer *pp, tree t)
1489 t = DECL_EXPR_DECL (t);
1490 pp_cxx_type_specifier_seq (pp, t);
1492 pp_cxx_abstract_declarator (pp, t);
1494 pp_cxx_declarator (pp, t);
1500 pp_cxx_statement (cxx_pretty_printer *pp, tree t)
1502 switch (TREE_CODE (t))
1504 case CTOR_INITIALIZER:
1505 pp_cxx_ctor_initializer (pp, t);
1509 pp_cxx_identifier (pp, "using");
1510 pp_cxx_identifier (pp, "namespace");
1511 pp_cxx_qualified_id (pp, USING_STMT_NAMESPACE (t));
1515 pp_cxx_identifier (pp, "using");
1516 pp_cxx_nested_name_specifier (pp, DECL_INITIAL (t));
1517 pp_cxx_unqualified_id (pp, DECL_NAME (t));
1524 try compound-statement handler-seq */
1526 pp_maybe_newline_and_indent (pp, 0);
1527 pp_cxx_identifier (pp, "try");
1528 pp_newline_and_indent (pp, 3);
1529 pp_cxx_statement (pp, TRY_STMTS (t));
1530 pp_newline_and_indent (pp, -3);
1534 pp_cxx_statement (pp, TRY_HANDLERS (t));
1539 handler handler-seq(opt)
1542 catch ( exception-declaration ) compound-statement
1544 exception-declaration:
1545 type-specifier-seq declarator
1546 type-specifier-seq abstract-declarator
1549 pp_cxx_identifier (pp, "catch");
1550 pp_cxx_left_paren (pp);
1551 pp_cxx_exception_declaration (pp, HANDLER_PARMS (t));
1552 pp_cxx_right_paren (pp);
1553 pp_indentation (pp) += 3;
1554 pp_needs_newline (pp) = true;
1555 pp_cxx_statement (pp, HANDLER_BODY (t));
1556 pp_indentation (pp) -= 3;
1557 pp_needs_newline (pp) = true;
1560 /* selection-statement:
1561 if ( expression ) statement
1562 if ( expression ) statement else statement */
1564 pp_cxx_identifier (pp, "if");
1565 pp_cxx_whitespace (pp);
1566 pp_cxx_left_paren (pp);
1567 pp_cxx_expression (pp, IF_COND (t));
1568 pp_cxx_right_paren (pp);
1569 pp_newline_and_indent (pp, 2);
1570 pp_cxx_statement (pp, THEN_CLAUSE (t));
1571 pp_newline_and_indent (pp, -2);
1572 if (ELSE_CLAUSE (t))
1574 tree else_clause = ELSE_CLAUSE (t);
1575 pp_cxx_identifier (pp, "else");
1576 if (TREE_CODE (else_clause) == IF_STMT)
1577 pp_cxx_whitespace (pp);
1579 pp_newline_and_indent (pp, 2);
1580 pp_cxx_statement (pp, else_clause);
1581 if (TREE_CODE (else_clause) != IF_STMT)
1582 pp_newline_and_indent (pp, -2);
1587 pp_cxx_identifier (pp, "switch");
1589 pp_cxx_left_paren (pp);
1590 pp_cxx_expression (pp, SWITCH_STMT_COND (t));
1591 pp_cxx_right_paren (pp);
1592 pp_indentation (pp) += 3;
1593 pp_needs_newline (pp) = true;
1594 pp_cxx_statement (pp, SWITCH_STMT_BODY (t));
1595 pp_newline_and_indent (pp, -3);
1598 /* iteration-statement:
1599 while ( expression ) statement
1600 do statement while ( expression ) ;
1601 for ( expression(opt) ; expression(opt) ; expression(opt) ) statement
1602 for ( declaration expression(opt) ; expression(opt) ) statement */
1604 pp_cxx_identifier (pp, "while");
1606 pp_cxx_left_paren (pp);
1607 pp_cxx_expression (pp, WHILE_COND (t));
1608 pp_cxx_right_paren (pp);
1609 pp_newline_and_indent (pp, 3);
1610 pp_cxx_statement (pp, WHILE_BODY (t));
1611 pp_indentation (pp) -= 3;
1612 pp_needs_newline (pp) = true;
1616 pp_cxx_identifier (pp, "do");
1617 pp_newline_and_indent (pp, 3);
1618 pp_cxx_statement (pp, DO_BODY (t));
1619 pp_newline_and_indent (pp, -3);
1620 pp_cxx_identifier (pp, "while");
1622 pp_cxx_left_paren (pp);
1623 pp_cxx_expression (pp, DO_COND (t));
1624 pp_cxx_right_paren (pp);
1625 pp_cxx_semicolon (pp);
1626 pp_needs_newline (pp) = true;
1630 pp_cxx_identifier (pp, "for");
1632 pp_cxx_left_paren (pp);
1633 if (FOR_INIT_STMT (t))
1634 pp_cxx_statement (pp, FOR_INIT_STMT (t));
1636 pp_cxx_semicolon (pp);
1637 pp_needs_newline (pp) = false;
1638 pp_cxx_whitespace (pp);
1640 pp_cxx_expression (pp, FOR_COND (t));
1641 pp_cxx_semicolon (pp);
1642 pp_needs_newline (pp) = false;
1643 pp_cxx_whitespace (pp);
1645 pp_cxx_expression (pp, FOR_EXPR (t));
1646 pp_cxx_right_paren (pp);
1647 pp_newline_and_indent (pp, 3);
1648 pp_cxx_statement (pp, FOR_BODY (t));
1649 pp_indentation (pp) -= 3;
1650 pp_needs_newline (pp) = true;
1656 return expression(opt) ; */
1659 pp_identifier (pp, TREE_CODE (t) == BREAK_STMT ? "break" : "continue");
1660 pp_cxx_semicolon (pp);
1661 pp_needs_newline (pp) = true;
1664 /* expression-statement:
1665 expression(opt) ; */
1667 pp_cxx_expression (pp, EXPR_STMT_EXPR (t));
1668 pp_cxx_semicolon (pp);
1669 pp_needs_newline (pp) = true;
1673 pp_cxx_identifier (pp, "try");
1674 pp_newline_and_indent (pp, 2);
1675 pp_cxx_statement (pp, CLEANUP_BODY (t));
1676 pp_newline_and_indent (pp, -2);
1677 pp_cxx_identifier (pp, CLEANUP_EH_ONLY (t) ? "catch" : "finally");
1678 pp_newline_and_indent (pp, 2);
1679 pp_cxx_statement (pp, CLEANUP_EXPR (t));
1680 pp_newline_and_indent (pp, -2);
1684 pp_c_statement (pp_c_base (pp), t);
1689 /* original-namespace-definition:
1690 namespace identifier { namespace-body }
1692 As an edge case, we also handle unnamed namespace definition here. */
1695 pp_cxx_original_namespace_definition (cxx_pretty_printer *pp, tree t)
1697 pp_cxx_identifier (pp, "namespace");
1699 pp_cxx_unqualified_id (pp, t);
1700 pp_cxx_whitespace (pp);
1701 pp_cxx_left_brace (pp);
1702 /* We do not print the namespace-body. */
1703 pp_cxx_whitespace (pp);
1704 pp_cxx_right_brace (pp);
1710 namespace-alias-definition:
1711 namespace identifier = qualified-namespace-specifier ;
1713 qualified-namespace-specifier:
1714 ::(opt) nested-name-specifier(opt) namespace-name */
1717 pp_cxx_namespace_alias_definition (cxx_pretty_printer *pp, tree t)
1719 pp_cxx_identifier (pp, "namespace");
1720 pp_cxx_unqualified_id (pp, t);
1721 pp_cxx_whitespace (pp);
1723 pp_cxx_whitespace (pp);
1724 pp_cxx_qualified_id (pp, DECL_NAMESPACE_ALIAS (t));
1725 pp_cxx_semicolon (pp);
1728 /* simple-declaration:
1729 decl-specifier-seq(opt) init-declarator-list(opt) */
1732 pp_cxx_simple_declaration (cxx_pretty_printer *pp, tree t)
1734 pp_cxx_decl_specifier_seq (pp, t);
1735 pp_cxx_init_declarator (pp, t);
1736 pp_cxx_semicolon (pp);
1737 pp_needs_newline (pp) = true;
1741 template-parameter-list:
1743 template-parameter-list , template-parameter */
1746 pp_cxx_template_parameter_list (cxx_pretty_printer *pp, tree t)
1748 const int n = TREE_VEC_LENGTH (t);
1750 for (i = 0; i < n; ++i)
1753 pp_cxx_separate_with (pp, ',');
1754 pp_cxx_template_parameter (pp, TREE_VEC_ELT (t, i));
1758 /* template-parameter:
1760 parameter-declaration
1763 class identifier(opt)
1764 class identifier(op) = type-id
1765 typename identifier(opt)
1766 typename identifier(opt) = type-id
1767 template < template-parameter-list > class identifier(opt)
1768 template < template-parameter-list > class identifier(opt) = template-name
1772 pp_cxx_template_parameter (cxx_pretty_printer *pp, tree t)
1774 tree parameter = TREE_VALUE (t);
1775 switch (TREE_CODE (parameter))
1778 pp_cxx_identifier (pp, "class");
1779 if (DECL_NAME (parameter))
1780 pp_cxx_tree_identifier (pp, DECL_NAME (parameter));
1781 /* FIXME: Chech if we should print also default argument. */
1785 pp_cxx_parameter_declaration (pp, parameter);
1792 pp_unsupported_tree (pp, t);
1797 /* Pretty-print a template parameter in the canonical form
1798 "template-parameter-<level>-<position in parameter list>". */
1801 pp_cxx_canonical_template_parameter (cxx_pretty_printer *pp, tree parm)
1803 const enum tree_code code = TREE_CODE (parm);
1805 /* Brings type template parameters to the canonical forms. */
1806 if (code == TEMPLATE_TYPE_PARM || code == TEMPLATE_TEMPLATE_PARM
1807 || code == BOUND_TEMPLATE_TEMPLATE_PARM)
1808 parm = TEMPLATE_TYPE_PARM_INDEX (parm);
1810 pp_cxx_begin_template_argument_list (pp);
1811 pp_cxx_identifier (pp, "template-parameter-");
1812 pp_wide_integer (pp, TEMPLATE_PARM_LEVEL (parm));
1814 pp_wide_integer (pp, TEMPLATE_PARM_IDX (parm) + 1);
1815 pp_cxx_end_template_argument_list (pp);
1819 template-declaration:
1820 export(opt) template < template-parameter-list > declaration */
1823 pp_cxx_template_declaration (cxx_pretty_printer *pp, tree t)
1825 tree tmpl = most_general_template (t);
1829 pp_maybe_newline_and_indent (pp, 0);
1830 for (level = DECL_TEMPLATE_PARMS (tmpl); level; level = TREE_CHAIN (level))
1832 pp_cxx_identifier (pp, "template");
1833 pp_cxx_begin_template_argument_list (pp);
1834 pp_cxx_template_parameter_list (pp, TREE_VALUE (level));
1835 pp_cxx_end_template_argument_list (pp);
1836 pp_newline_and_indent (pp, 3);
1839 if (TREE_CODE (t) == FUNCTION_DECL && DECL_SAVED_TREE (t))
1840 pp_cxx_function_definition (pp, t);
1842 pp_cxx_simple_declaration (pp, t);
1846 pp_cxx_explicit_specialization (cxx_pretty_printer *pp, tree t)
1848 pp_unsupported_tree (pp, t);
1852 pp_cxx_explicit_instantiation (cxx_pretty_printer *pp, tree t)
1854 pp_unsupported_tree (pp, t);
1861 template-declaration
1862 explicit-instantiation
1863 explicit-specialization
1864 linkage-specification
1865 namespace-definition
1870 namespace-alias-definition
1874 pp_cxx_declaration (cxx_pretty_printer *pp, tree t)
1876 if (!DECL_LANG_SPECIFIC (t))
1877 pp_cxx_simple_declaration (pp, t);
1878 else if (DECL_USE_TEMPLATE (t))
1879 switch (DECL_USE_TEMPLATE (t))
1882 pp_cxx_template_declaration (pp, t);
1886 pp_cxx_explicit_specialization (pp, t);
1890 pp_cxx_explicit_instantiation (pp, t);
1896 else switch (TREE_CODE (t))
1900 pp_cxx_simple_declaration (pp, t);
1904 if (DECL_SAVED_TREE (t))
1905 pp_cxx_function_definition (pp, t);
1907 pp_cxx_simple_declaration (pp, t);
1910 case NAMESPACE_DECL:
1911 if (DECL_NAMESPACE_ALIAS (t))
1912 pp_cxx_namespace_alias_definition (pp, t);
1914 pp_cxx_original_namespace_definition (pp, t);
1918 pp_unsupported_tree (pp, t);
1924 typedef c_pretty_print_fn pp_fun;
1926 /* Initialization of a C++ pretty-printer object. */
1929 pp_cxx_pretty_printer_init (cxx_pretty_printer *pp)
1931 pp_c_pretty_printer_init (pp_c_base (pp));
1932 pp_set_line_maximum_length (pp, 0);
1934 pp->c_base.declaration = (pp_fun) pp_cxx_declaration;
1935 pp->c_base.declaration_specifiers = (pp_fun) pp_cxx_decl_specifier_seq;
1936 pp->c_base.function_specifier = (pp_fun) pp_cxx_function_specifier;
1937 pp->c_base.type_specifier_seq = (pp_fun) pp_cxx_type_specifier_seq;
1938 pp->c_base.declarator = (pp_fun) pp_cxx_declarator;
1939 pp->c_base.direct_declarator = (pp_fun) pp_cxx_direct_declarator;
1940 pp->c_base.parameter_list = (pp_fun) pp_cxx_parameter_declaration_clause;
1941 pp->c_base.type_id = (pp_fun) pp_cxx_type_id;
1942 pp->c_base.abstract_declarator = (pp_fun) pp_cxx_abstract_declarator;
1943 pp->c_base.direct_abstract_declarator =
1944 (pp_fun) pp_cxx_direct_abstract_declarator;
1945 pp->c_base.simple_type_specifier = (pp_fun)pp_cxx_simple_type_specifier;
1947 /* pp->c_base.statement = (pp_fun) pp_cxx_statement; */
1949 pp->c_base.id_expression = (pp_fun) pp_cxx_id_expression;
1950 pp->c_base.primary_expression = (pp_fun) pp_cxx_primary_expression;
1951 pp->c_base.postfix_expression = (pp_fun) pp_cxx_postfix_expression;
1952 pp->c_base.unary_expression = (pp_fun) pp_cxx_unary_expression;
1953 pp->c_base.multiplicative_expression = (pp_fun) pp_cxx_multiplicative_expression;
1954 pp->c_base.conditional_expression = (pp_fun) pp_cxx_conditional_expression;
1955 pp->c_base.assignment_expression = (pp_fun) pp_cxx_assignment_expression;
1956 pp->c_base.expression = (pp_fun) pp_cxx_expression;
1957 pp->enclosing_scope = global_namespace;