From 8f0e4d72f2905596ecb212e8824a0a0e1489bab8 Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Fri, 30 Aug 2013 15:28:51 +0000 Subject: [PATCH] c-pretty-print.h (c_pretty_printer::declaration): Now a virtual member function. c-family/ * c-pretty-print.h (c_pretty_printer::declaration): Now a virtual member function. (c_pretty_printer::declaration_specifiers): Likewise. (c_pretty_printer::declarator): Likewise. (c_pretty_printer::abstract_declarator): Likewise. (c_pretty_printer::direct_abstract_declarator): Likewise. (c_pretty_printer::direct_declarator): Likewise. (c_pretty_printer::function_specifier): Likewise. (pp_declaration): Adjust. (pp_declaration_specifiers): Likewise. (pp_abstract_declarator): Likewise. (pp_direct_declarator): Likewise. (pp_function_specifier): Likewise. (pp_direct_abstract_declarator): Remove as unused. (pp_c_declaration): Remove. (pp_c_declaration_specifiers): Likewise. (pp_c_declarator): Likewise. (pp_c_direct_declarator): Likewise. (pp_c_function_specifier): Likewise. (pp_c_direct_abstract_declarator): Likewise. * c-pretty-print.c (c_pretty_printer::abstract_declarator): Rename from pp_c_abstract_declarator. Adjust. (c_pretty_printer::direct_abstract_declarator): Rename from pp_c_direct_abstract_declarator. Adjust. (c_pretty_printer::function_specifier): Rename from pp_c_function_specifier. Adjust. (c_pretty_printer::declaration_specifiers): Rename from pp_c_declaration_specifiers. Adjust. (c_pretty_printer::direct_declarator): Rename from pp_c_direct_declarator. Adjust. (c_pretty_printer::declarator): Rename from pp_c_declarator. Adjust. (c_pretty_printer::declaration): Rename from pp_c_declaration. Adjust. (c_pretty_printer::c_pretty_printer): Do not assign to declaration, declaration_specifiers, declarator, direct_declarator, direct_abstract_declarator, function_specifier. cp/ * cxx-pretty-print.h (cxx_pretty_printer::declaration): Declare as overrider. (cxx_pretty_printer::declaration_specifiers): Likewise. (cxx_pretty_printer::function_specifier): Likewise. (cxx_pretty_printer::declarator): Likewise. (cxx_pretty_printer::direct_declarator): Likewise. (cxx_pretty_printer::abstract_declarator): Likewise. (cxx_pretty_printer::direct_abstract_declarator): Likewise. (pp_cxx_declaration): Remove. * cxx-pretty-print.c (cxx_pretty_printer::function_specifier): Rename from pp_cxx_function_specifier. Adjust. (cxx_pretty_printer::declaration_specifiers): Rename from pp_cxx_decl_specifier_seq. Adjust. (cxx_pretty_printer::direct_declarator): Rename from pp_cxx_direct_declarator. Adjust. (cxx_pretty_printer::declarator): Rename from pp_cxx_declarator. Adjust. (cxx_pretty_printer::abstract_declarator): Rename from pp_cxx_abstract_declarator. Adjust. (cxx_pretty_printer::direct_abstract_declarator): Rename from pp_cxx_direct_abstract_declarator. Adjust. (cxx_pretty_printer::declaration): Rename from pp_cxx_declaration. Adjust. (cxx_pretty_printer::cxx_pretty_printer): Do not assign to declaration, declaration_specifiers, function_specifier, declarator, direct_declarator, abstract_declarator, direct_abstract_declarator. * error.c (dump_decl): Adjust. From-SVN: r202109 --- gcc/c-family/ChangeLog | 38 +++++++++ gcc/c-family/c-pretty-print.c | 87 +++++++++---------- gcc/c-family/c-pretty-print.h | 34 +++----- gcc/cp/ChangeLog | 31 +++++++ gcc/cp/cxx-pretty-print.c | 154 ++++++++++++++++------------------ gcc/cp/cxx-pretty-print.h | 8 +- gcc/cp/error.c | 6 +- 7 files changed, 204 insertions(+), 154 deletions(-) diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index c6562763d7a..c8bf2dffdc1 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,41 @@ +2013-08-30 Gabriel Dos Reis + + * c-pretty-print.h (c_pretty_printer::declaration): Now a virtual + member function. + (c_pretty_printer::declaration_specifiers): Likewise. + (c_pretty_printer::declarator): Likewise. + (c_pretty_printer::abstract_declarator): Likewise. + (c_pretty_printer::direct_abstract_declarator): Likewise. + (c_pretty_printer::direct_declarator): Likewise. + (c_pretty_printer::function_specifier): Likewise. + (pp_declaration): Adjust. + (pp_declaration_specifiers): Likewise. + (pp_abstract_declarator): Likewise. + (pp_direct_declarator): Likewise. + (pp_function_specifier): Likewise. + (pp_direct_abstract_declarator): Remove as unused. + (pp_c_declaration): Remove. + (pp_c_declaration_specifiers): Likewise. + (pp_c_declarator): Likewise. + (pp_c_direct_declarator): Likewise. + (pp_c_function_specifier): Likewise. + (pp_c_direct_abstract_declarator): Likewise. + * c-pretty-print.c (c_pretty_printer::abstract_declarator): Rename + from pp_c_abstract_declarator. Adjust. + (c_pretty_printer::direct_abstract_declarator): Rename from + pp_c_direct_abstract_declarator. Adjust. + (c_pretty_printer::function_specifier): Rename from + pp_c_function_specifier. Adjust. + (c_pretty_printer::declaration_specifiers): Rename from + pp_c_declaration_specifiers. Adjust. + (c_pretty_printer::direct_declarator): Rename from + pp_c_direct_declarator. Adjust. + (c_pretty_printer::declarator): Rename from pp_c_declarator. Adjust. + (c_pretty_printer::declaration): Rename from pp_c_declaration. Adjust. + (c_pretty_printer::c_pretty_printer): Do not assign to + declaration, declaration_specifiers, declarator, + direct_declarator, direct_abstract_declarator, function_specifier. + 2013-08-26 Gabriel Dos Reis * c-pretty-print.h (c_pretty_printer::unary_expression): Now a diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index 6d0c4066100..c50b068c627 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -431,7 +431,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t) function declarations, this routine prints not just the specifier-qualifier-list of such entities or types of such entities, but also the 'pointer' production part of their declarators. The - remaining part is done by pp_declarator or pp_c_abstract_declarator. */ + remaining part is done by pp_declarator or pp_abstract_declarator. */ void pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t) @@ -533,18 +533,18 @@ pp_c_parameter_type_list (c_pretty_printer *pp, tree t) pointer pointer(opt) direct-abstract-declarator */ -static void -pp_c_abstract_declarator (c_pretty_printer *pp, tree t) +void +c_pretty_printer::abstract_declarator (tree t) { if (TREE_CODE (t) == POINTER_TYPE) { if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE) - pp_c_right_paren (pp); + pp_c_right_paren (this); t = TREE_TYPE (t); } - pp_direct_abstract_declarator (pp, t); + direct_abstract_declarator (t); } /* direct-abstract-declarator: @@ -554,34 +554,34 @@ pp_c_abstract_declarator (c_pretty_printer *pp, tree t) direct-abstract-declarator(opt) ( parameter-type-list(opt) ) */ void -pp_c_direct_abstract_declarator (c_pretty_printer *pp, tree t) +c_pretty_printer::direct_abstract_declarator (tree t) { switch (TREE_CODE (t)) { case POINTER_TYPE: - pp_abstract_declarator (pp, t); + abstract_declarator (t); break; case FUNCTION_TYPE: - pp_c_parameter_type_list (pp, t); - pp_direct_abstract_declarator (pp, TREE_TYPE (t)); + pp_c_parameter_type_list (this, t); + direct_abstract_declarator (TREE_TYPE (t)); break; case ARRAY_TYPE: - pp_c_left_bracket (pp); + pp_c_left_bracket (this); if (TYPE_DOMAIN (t) && TYPE_MAX_VALUE (TYPE_DOMAIN (t))) { tree maxval = TYPE_MAX_VALUE (TYPE_DOMAIN (t)); tree type = TREE_TYPE (maxval); if (host_integerp (maxval, 0)) - pp_wide_integer (pp, tree_low_cst (maxval, 0) + 1); + pp_wide_integer (this, tree_low_cst (maxval, 0) + 1); else - pp_expression (pp, fold_build2 (PLUS_EXPR, type, maxval, + pp_expression (this, fold_build2 (PLUS_EXPR, type, maxval, build_int_cst (type, 1))); } - pp_c_right_bracket (pp); - pp_direct_abstract_declarator (pp, TREE_TYPE (t)); + pp_c_right_bracket (this); + direct_abstract_declarator (TREE_TYPE (t)); break; case IDENTIFIER_NODE: @@ -599,7 +599,7 @@ pp_c_direct_abstract_declarator (c_pretty_printer *pp, tree t) break; default: - pp_unsupported_tree (pp, t); + pp_unsupported_tree (this, t); break; } } @@ -639,10 +639,10 @@ pp_c_storage_class_specifier (c_pretty_printer *pp, tree t) inline */ void -pp_c_function_specifier (c_pretty_printer *pp, tree t) +c_pretty_printer::function_specifier (tree t) { if (TREE_CODE (t) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (t)) - pp_c_ws_string (pp, "inline"); + pp_c_ws_string (this, "inline"); } /* declaration-specifiers: @@ -652,11 +652,11 @@ pp_c_function_specifier (c_pretty_printer *pp, tree t) function-specifier declaration-specifiers(opt) */ void -pp_c_declaration_specifiers (c_pretty_printer *pp, tree t) +c_pretty_printer::declaration_specifiers (tree t) { - pp_storage_class_specifier (pp, t); - pp_function_specifier (pp, t); - pp_c_specifier_qualifier_list (pp, DECL_P (t) ? TREE_TYPE (t) : t); + pp_storage_class_specifier (this, t); + pp_function_specifier (this, t); + pp_c_specifier_qualifier_list (this, DECL_P (t) ? TREE_TYPE (t) : t); } /* direct-declarator @@ -670,7 +670,7 @@ pp_c_declaration_specifiers (c_pretty_printer *pp, tree t) direct-declarator ( identifier-list(opt) ) */ void -pp_c_direct_declarator (c_pretty_printer *pp, tree t) +c_pretty_printer::direct_declarator (tree t) { switch (TREE_CODE (t)) { @@ -679,29 +679,29 @@ pp_c_direct_declarator (c_pretty_printer *pp, tree t) case TYPE_DECL: case FIELD_DECL: case LABEL_DECL: - pp_c_space_for_pointer_operator (pp, TREE_TYPE (t)); - pp_c_tree_decl_identifier (pp, t); + pp_c_space_for_pointer_operator (this, TREE_TYPE (t)); + pp_c_tree_decl_identifier (this, t); break; case ARRAY_TYPE: case POINTER_TYPE: - pp_abstract_declarator (pp, TREE_TYPE (t)); + abstract_declarator (TREE_TYPE (t)); break; case FUNCTION_TYPE: - pp_parameter_list (pp, t); - pp_abstract_declarator (pp, TREE_TYPE (t)); + pp_parameter_list (this, t); + abstract_declarator (TREE_TYPE (t)); break; case FUNCTION_DECL: - pp_c_space_for_pointer_operator (pp, TREE_TYPE (TREE_TYPE (t))); - pp_c_tree_decl_identifier (pp, t); - if (pp->flags & pp_c_flag_abstract) - pp_abstract_declarator (pp, TREE_TYPE (t)); + pp_c_space_for_pointer_operator (this, TREE_TYPE (TREE_TYPE (t))); + pp_c_tree_decl_identifier (this, t); + if (flags & pp_c_flag_abstract) + abstract_declarator (TREE_TYPE (t)); else { - pp_parameter_list (pp, t); - pp_abstract_declarator (pp, TREE_TYPE (TREE_TYPE (t))); + pp_parameter_list (this, t); + abstract_declarator (TREE_TYPE (TREE_TYPE (t))); } break; @@ -714,7 +714,7 @@ pp_c_direct_declarator (c_pretty_printer *pp, tree t) break; default: - pp_unsupported_tree (pp, t); + pp_unsupported_tree (this, t); break; } } @@ -724,7 +724,7 @@ pp_c_direct_declarator (c_pretty_printer *pp, tree t) pointer(opt) direct-declarator */ void -pp_c_declarator (c_pretty_printer *pp, tree t) +c_pretty_printer::declarator (tree t) { switch (TREE_CODE (t)) { @@ -743,12 +743,12 @@ pp_c_declarator (c_pretty_printer *pp, tree t) case FUNCTION_TYPE: case FUNCTION_DECL: case TYPE_DECL: - pp_direct_declarator (pp, t); + pp_direct_declarator (this, t); break; default: - pp_unsupported_tree (pp, t); + pp_unsupported_tree (this, t); break; } } @@ -757,10 +757,10 @@ pp_c_declarator (c_pretty_printer *pp, tree t) declaration-specifiers init-declarator-list(opt) ; */ void -pp_c_declaration (c_pretty_printer *pp, tree t) +c_pretty_printer::declaration (tree t) { - pp_declaration_specifiers (pp, t); - pp_c_init_declarator (pp, t); + declaration_specifiers (t); + pp_c_init_declarator (this, t); } /* Pretty-print ATTRIBUTES using GNU C extension syntax. */ @@ -2325,18 +2325,11 @@ c_pretty_printer::c_pretty_printer () { offset_list = 0; flags = 0; - declaration = pp_c_declaration; - declaration_specifiers = pp_c_declaration_specifiers; - declarator = pp_c_declarator; - direct_declarator = pp_c_direct_declarator; type_specifier_seq = pp_c_specifier_qualifier_list; - abstract_declarator = pp_c_abstract_declarator; - direct_abstract_declarator = pp_c_direct_abstract_declarator; ptr_operator = pp_c_pointer; parameter_list = pp_c_parameter_type_list; type_id = pp_c_type_id; simple_type_specifier = pp_c_type_specifier; - function_specifier = pp_c_function_specifier; storage_class_specifier = pp_c_storage_class_specifier; initializer = pp_c_initializer; diff --git a/gcc/c-family/c-pretty-print.h b/gcc/c-family/c-pretty-print.h index 62492c3bede..4ab420daea5 100644 --- a/gcc/c-family/c-pretty-print.h +++ b/gcc/c-family/c-pretty-print.h @@ -66,6 +66,13 @@ struct c_pretty_printer : pretty_printer virtual void statement (tree); + virtual void declaration (tree); + virtual void declaration_specifiers (tree); + virtual void function_specifier (tree); + virtual void declarator (tree); + virtual void direct_declarator (tree); + virtual void abstract_declarator (tree); + virtual void direct_abstract_declarator (tree); /* Points to the first element of an array of offset-list. Not used yet. */ int *offset_list; @@ -74,18 +81,11 @@ struct c_pretty_printer : pretty_printer /* These must be overridden by each of the C and C++ front-end to reflect their understanding of syntactic productions when they differ. */ - c_pretty_print_fn declaration; - c_pretty_print_fn declaration_specifiers; - c_pretty_print_fn declarator; - c_pretty_print_fn abstract_declarator; - c_pretty_print_fn direct_abstract_declarator; c_pretty_print_fn type_specifier_seq; - c_pretty_print_fn direct_declarator; c_pretty_print_fn ptr_operator; c_pretty_print_fn parameter_list; c_pretty_print_fn type_id; c_pretty_print_fn simple_type_specifier; - c_pretty_print_fn function_specifier; c_pretty_print_fn storage_class_specifier; c_pretty_print_fn initializer; @@ -94,20 +94,18 @@ struct c_pretty_printer : pretty_printer #define pp_c_tree_identifier(PPI, ID) \ pp_c_identifier (PPI, IDENTIFIER_POINTER (ID)) -#define pp_declaration(PP, T) (PP)->declaration (PP, T) +#define pp_declaration(PP, T) (PP)->declaration (T) #define pp_declaration_specifiers(PP, D) \ - (PP)->declaration_specifiers (PP, D) -#define pp_abstract_declarator(PP, D) (PP)->abstract_declarator (PP, D) + (PP)->declaration_specifiers (D) +#define pp_abstract_declarator(PP, D) (PP)->abstract_declarator (D) #define pp_type_specifier_seq(PP, D) (PP)->type_specifier_seq (PP, D) -#define pp_declarator(PP, D) (PP)->declarator (PP, D) -#define pp_direct_declarator(PP, D) (PP)->direct_declarator (PP, D) -#define pp_direct_abstract_declarator(PP, D) \ - (PP)->direct_abstract_declarator (PP, D) +#define pp_declarator(PP, D) (PP)->declarator (D) +#define pp_direct_declarator(PP, D) (PP)->direct_declarator (D) #define pp_ptr_operator(PP, D) (PP)->ptr_operator (PP, D) #define pp_parameter_list(PP, T) (PP)->parameter_list (PP, T) #define pp_type_id(PP, D) (PP)->type_id (PP, D) #define pp_simple_type_specifier(PP, T) (PP)->simple_type_specifier (PP, T) -#define pp_function_specifier(PP, D) (PP)->function_specifier (PP, D) +#define pp_function_specifier(PP, D) (PP)->function_specifier (D) #define pp_storage_class_specifier(PP, D) \ (PP)->storage_class_specifier (PP, D); @@ -150,14 +148,8 @@ void pp_c_attributes_display (c_pretty_printer *, tree); void pp_c_cv_qualifiers (c_pretty_printer *pp, int qualifiers, bool func_type); void pp_c_type_qualifier_list (c_pretty_printer *, tree); void pp_c_parameter_type_list (c_pretty_printer *, tree); -void pp_c_declaration (c_pretty_printer *, tree); -void pp_c_declaration_specifiers (c_pretty_printer *, tree); -void pp_c_declarator (c_pretty_printer *, tree); -void pp_c_direct_declarator (c_pretty_printer *, tree); void pp_c_specifier_qualifier_list (c_pretty_printer *, tree); -void pp_c_function_specifier (c_pretty_printer *, tree); void pp_c_type_id (c_pretty_printer *, tree); -void pp_c_direct_abstract_declarator (c_pretty_printer *, tree); void pp_c_type_specifier (c_pretty_printer *, tree); void pp_c_storage_class_specifier (c_pretty_printer *, tree); /* Expressions. */ diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2af563e06dc..1e6d62104f8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,34 @@ +2013-08-30 Gabriel Dos Reis + + * cxx-pretty-print.h (cxx_pretty_printer::declaration): Declare as + overrider. + (cxx_pretty_printer::declaration_specifiers): Likewise. + (cxx_pretty_printer::function_specifier): Likewise. + (cxx_pretty_printer::declarator): Likewise. + (cxx_pretty_printer::direct_declarator): Likewise. + (cxx_pretty_printer::abstract_declarator): Likewise. + (cxx_pretty_printer::direct_abstract_declarator): Likewise. + (pp_cxx_declaration): Remove. + * cxx-pretty-print.c (cxx_pretty_printer::function_specifier): + Rename from pp_cxx_function_specifier. Adjust. + (cxx_pretty_printer::declaration_specifiers): Rename from + pp_cxx_decl_specifier_seq. Adjust. + (cxx_pretty_printer::direct_declarator): Rename from + pp_cxx_direct_declarator. Adjust. + (cxx_pretty_printer::declarator): Rename from pp_cxx_declarator. + Adjust. + (cxx_pretty_printer::abstract_declarator): Rename from + pp_cxx_abstract_declarator. Adjust. + (cxx_pretty_printer::direct_abstract_declarator): Rename from + pp_cxx_direct_abstract_declarator. Adjust. + (cxx_pretty_printer::declaration): Rename from + pp_cxx_declaration. Adjust. + (cxx_pretty_printer::cxx_pretty_printer): Do not assign to + declaration, declaration_specifiers, function_specifier, + declarator, direct_declarator, abstract_declarator, + direct_abstract_declarator. + * error.c (dump_decl): Adjust. + 2013-08-29 Jan Hubicka Correct previous patch to not mark terminate as LEAF. diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index 38745abf079..4fc9cbc0aa7 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -34,10 +34,7 @@ static void pp_cxx_template_argument_list (cxx_pretty_printer *, tree); static void pp_cxx_type_specifier_seq (cxx_pretty_printer *, tree); static void pp_cxx_ptr_operator (cxx_pretty_printer *, tree); static void pp_cxx_type_id (cxx_pretty_printer *, tree); -static void pp_cxx_direct_abstract_declarator (cxx_pretty_printer *, tree); -static void pp_cxx_declarator (cxx_pretty_printer *, tree); static void pp_cxx_parameter_declaration_clause (cxx_pretty_printer *, tree); -static void pp_cxx_abstract_declarator (cxx_pretty_printer *, tree); static void pp_cxx_template_parameter (cxx_pretty_printer *, tree); static void pp_cxx_cast_expression (cxx_pretty_printer *, tree); static void pp_cxx_typeid_expression (cxx_pretty_printer *, tree); @@ -1180,18 +1177,18 @@ cxx_pretty_printer::expression (tree t) virtual explicit */ -static void -pp_cxx_function_specifier (cxx_pretty_printer *pp, tree t) +void +cxx_pretty_printer::function_specifier (tree t) { switch (TREE_CODE (t)) { case FUNCTION_DECL: if (DECL_VIRTUAL_P (t)) - pp_cxx_ws_string (pp, "virtual"); + pp_cxx_ws_string (this, "virtual"); else if (DECL_CONSTRUCTOR_P (t) && DECL_NONCONVERTING_P (t)) - pp_cxx_ws_string (pp, "explicit"); + pp_cxx_ws_string (this, "explicit"); else - pp_c_function_specifier (pp, t); + c_pretty_printer::function_specifier (t); default: break; @@ -1208,8 +1205,8 @@ pp_cxx_function_specifier (cxx_pretty_printer *pp, tree t) friend typedef */ -static void -pp_cxx_decl_specifier_seq (cxx_pretty_printer *pp, tree t) +void +cxx_pretty_printer::declaration_specifiers (tree t) { switch (TREE_CODE (t)) { @@ -1217,25 +1214,25 @@ pp_cxx_decl_specifier_seq (cxx_pretty_printer *pp, tree t) case PARM_DECL: case CONST_DECL: case FIELD_DECL: - pp_cxx_storage_class_specifier (pp, t); - pp_cxx_decl_specifier_seq (pp, TREE_TYPE (t)); + pp_cxx_storage_class_specifier (this, t); + declaration_specifiers (TREE_TYPE (t)); break; case TYPE_DECL: - pp_cxx_ws_string (pp, "typedef"); - pp_cxx_decl_specifier_seq (pp, TREE_TYPE (t)); + pp_cxx_ws_string (this, "typedef"); + declaration_specifiers (TREE_TYPE (t)); break; case FUNCTION_DECL: /* Constructors don't have return types. And conversion functions do not have a type-specifier in their return types. */ if (DECL_CONSTRUCTOR_P (t) || DECL_CONV_FN_P (t)) - pp_cxx_function_specifier (pp, t); + function_specifier (t); else if (DECL_NONSTATIC_MEMBER_FUNCTION_P (t)) - pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (t))); + declaration_specifiers (TREE_TYPE (TREE_TYPE (t))); else default: - pp_c_declaration_specifiers (pp, t); + c_pretty_printer::declaration_specifiers (t); break; } } @@ -1326,7 +1323,7 @@ pp_cxx_type_specifier_seq (cxx_pretty_printer *pp, tree t) if (TYPE_PTRMEMFUNC_P (t)) { tree pfm = TYPE_PTRMEMFUNC_FN_TYPE (t); - pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (pfm))); + pp->declaration_specifiers (TREE_TYPE (TREE_TYPE (pfm))); pp_cxx_whitespace (pp); pp_cxx_ptr_operator (pp, t); break; @@ -1407,11 +1404,11 @@ pp_cxx_implicit_parameter_type (tree mf) static inline void pp_cxx_parameter_declaration (cxx_pretty_printer *pp, tree t) { - pp_cxx_decl_specifier_seq (pp, t); + pp->declaration_specifiers (t); if (TYPE_P (t)) - pp_cxx_abstract_declarator (pp, t); + pp_abstract_declarator (pp, t); else - pp_cxx_declarator (pp, t); + pp_declarator (pp, t); } /* parameter-declaration-clause: @@ -1517,8 +1514,8 @@ pp_cxx_exception_specification (cxx_pretty_printer *pp, tree t) direct-declaration [ constant-expression(opt) ] ( declarator ) */ -static void -pp_cxx_direct_declarator (cxx_pretty_printer *pp, tree t) +void +cxx_pretty_printer::direct_declarator (tree t) { switch (TREE_CODE (t)) { @@ -1528,31 +1525,31 @@ pp_cxx_direct_declarator (cxx_pretty_printer *pp, tree t) case FIELD_DECL: if (DECL_NAME (t)) { - pp_cxx_space_for_pointer_operator (pp, TREE_TYPE (t)); + pp_cxx_space_for_pointer_operator (this, TREE_TYPE (t)); if ((TREE_CODE (t) == PARM_DECL && FUNCTION_PARAMETER_PACK_P (t)) || template_parameter_pack_p (t)) /* A function parameter pack or non-type template parameter pack. */ - pp_cxx_ws_string (pp, "..."); + pp_cxx_ws_string (this, "..."); - pp_id_expression (pp, DECL_NAME (t)); + id_expression (DECL_NAME (t)); } - pp_cxx_abstract_declarator (pp, TREE_TYPE (t)); + abstract_declarator (TREE_TYPE (t)); break; case FUNCTION_DECL: - pp_cxx_space_for_pointer_operator (pp, TREE_TYPE (TREE_TYPE (t))); - pp_id_expression (pp, t); - pp_cxx_parameter_declaration_clause (pp, t); + pp_cxx_space_for_pointer_operator (this, TREE_TYPE (TREE_TYPE (t))); + expression (t); + pp_cxx_parameter_declaration_clause (this, t); if (DECL_NONSTATIC_MEMBER_FUNCTION_P (t)) { - pp->padding = pp_before; - pp_cxx_cv_qualifier_seq (pp, pp_cxx_implicit_parameter_type (t)); + padding = pp_before; + pp_cxx_cv_qualifier_seq (this, pp_cxx_implicit_parameter_type (t)); } - pp_cxx_exception_specification (pp, TREE_TYPE (t)); + pp_cxx_exception_specification (this, TREE_TYPE (t)); break; case TYPENAME_TYPE: @@ -1563,7 +1560,7 @@ pp_cxx_direct_declarator (cxx_pretty_printer *pp, tree t) break; default: - pp_c_direct_declarator (pp, t); + c_pretty_printer::direct_declarator (t); break; } } @@ -1572,10 +1569,10 @@ pp_cxx_direct_declarator (cxx_pretty_printer *pp, tree t) direct-declarator ptr-operator declarator */ -static void -pp_cxx_declarator (cxx_pretty_printer *pp, tree t) +void +cxx_pretty_printer::declarator (tree t) { - pp_cxx_direct_declarator (pp, t); + direct_declarator (t); } /* ctor-initializer: @@ -1624,8 +1621,8 @@ static void pp_cxx_function_definition (cxx_pretty_printer *pp, tree t) { tree saved_scope = pp->enclosing_scope; - pp_cxx_decl_specifier_seq (pp, t); - pp_cxx_declarator (pp, t); + pp->declaration_specifiers (t); + pp_declarator (pp, t); pp_needs_newline (pp) = true; pp->enclosing_scope = DECL_CONTEXT (t); if (DECL_SAVED_TREE (t)) @@ -1640,19 +1637,19 @@ pp_cxx_function_definition (cxx_pretty_printer *pp, tree t) ptr-operator abstract-declarator(opt) direct-abstract-declarator */ -static void -pp_cxx_abstract_declarator (cxx_pretty_printer *pp, tree t) +void +cxx_pretty_printer::abstract_declarator (tree t) { if (TYPE_PTRMEM_P (t)) - pp_cxx_right_paren (pp); + pp_cxx_right_paren (this); else if (POINTER_TYPE_P (t)) { if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE) - pp_cxx_right_paren (pp); + pp_cxx_right_paren (this); t = TREE_TYPE (t); } - pp_cxx_direct_abstract_declarator (pp, t); + direct_abstract_declarator (t); } /* direct-abstract-declarator: @@ -1661,30 +1658,30 @@ pp_cxx_abstract_declarator (cxx_pretty_printer *pp, tree t) direct-abstract-declarator(opt) [ constant-expression(opt) ] ( abstract-declarator ) */ -static void -pp_cxx_direct_abstract_declarator (cxx_pretty_printer *pp, tree t) +void +cxx_pretty_printer::direct_abstract_declarator (tree t) { switch (TREE_CODE (t)) { case REFERENCE_TYPE: - pp_cxx_abstract_declarator (pp, t); + abstract_declarator (t); break; case RECORD_TYPE: if (TYPE_PTRMEMFUNC_P (t)) - pp_cxx_direct_abstract_declarator (pp, TYPE_PTRMEMFUNC_FN_TYPE (t)); + direct_abstract_declarator (TYPE_PTRMEMFUNC_FN_TYPE (t)); break; case METHOD_TYPE: case FUNCTION_TYPE: - pp_cxx_parameter_declaration_clause (pp, t); - pp_cxx_direct_abstract_declarator (pp, TREE_TYPE (t)); + pp_cxx_parameter_declaration_clause (this, t); + direct_abstract_declarator (TREE_TYPE (t)); if (TREE_CODE (t) == METHOD_TYPE) { - pp->padding = pp_before; - pp_cxx_cv_qualifier_seq (pp, class_of_this_parm (t)); + padding = pp_before; + pp_cxx_cv_qualifier_seq (this, class_of_this_parm (t)); } - pp_cxx_exception_specification (pp, t); + pp_cxx_exception_specification (this, t); break; case TYPENAME_TYPE: @@ -1695,7 +1692,7 @@ pp_cxx_direct_abstract_declarator (cxx_pretty_printer *pp, tree t) break; default: - pp_c_direct_abstract_declarator (pp, t); + c_pretty_printer::direct_abstract_declarator (t); break; } } @@ -1797,9 +1794,9 @@ pp_cxx_exception_declaration (cxx_pretty_printer *pp, tree t) t = DECL_EXPR_DECL (t); pp_cxx_type_specifier_seq (pp, t); if (TYPE_P (t)) - pp_cxx_abstract_declarator (pp, t); + pp_abstract_declarator (pp, t); else - pp_cxx_declarator (pp, t); + pp_declarator (pp, t); } /* Statements. */ @@ -2008,7 +2005,7 @@ cxx_pretty_printer::statement (tree t) break; case STATIC_ASSERT: - pp_cxx_declaration (this, t); + declaration (t); break; default: @@ -2069,7 +2066,7 @@ pp_cxx_namespace_alias_definition (cxx_pretty_printer *pp, tree t) static void pp_cxx_simple_declaration (cxx_pretty_printer *pp, tree t) { - pp_cxx_decl_specifier_seq (pp, t); + pp->declaration_specifiers (t); pp_cxx_init_declarator (pp, t); pp_cxx_semicolon (pp); pp_needs_newline (pp) = true; @@ -2209,32 +2206,32 @@ pp_cxx_explicit_instantiation (cxx_pretty_printer *pp, tree t) using-directive static_assert-declaration */ void -pp_cxx_declaration (cxx_pretty_printer *pp, tree t) +cxx_pretty_printer::declaration (tree t) { if (TREE_CODE (t) == STATIC_ASSERT) { - pp_cxx_ws_string (pp, "static_assert"); - pp_cxx_left_paren (pp); - pp_expression (pp, STATIC_ASSERT_CONDITION (t)); - pp_cxx_separate_with (pp, ','); - pp_expression (pp, STATIC_ASSERT_MESSAGE (t)); - pp_cxx_right_paren (pp); + pp_cxx_ws_string (this, "static_assert"); + pp_cxx_left_paren (this); + expression (STATIC_ASSERT_CONDITION (t)); + pp_cxx_separate_with (this, ','); + expression (STATIC_ASSERT_MESSAGE (t)); + pp_cxx_right_paren (this); } else if (!DECL_LANG_SPECIFIC (t)) - pp_cxx_simple_declaration (pp, t); + pp_cxx_simple_declaration (this, t); else if (DECL_USE_TEMPLATE (t)) switch (DECL_USE_TEMPLATE (t)) { case 1: - pp_cxx_template_declaration (pp, t); + pp_cxx_template_declaration (this, t); break; case 2: - pp_cxx_explicit_specialization (pp, t); + pp_cxx_explicit_specialization (this, t); break; case 3: - pp_cxx_explicit_instantiation (pp, t); + pp_cxx_explicit_instantiation (this, t); break; default: @@ -2244,25 +2241,25 @@ pp_cxx_declaration (cxx_pretty_printer *pp, tree t) { case VAR_DECL: case TYPE_DECL: - pp_cxx_simple_declaration (pp, t); + pp_cxx_simple_declaration (this, t); break; case FUNCTION_DECL: if (DECL_SAVED_TREE (t)) - pp_cxx_function_definition (pp, t); + pp_cxx_function_definition (this, t); else - pp_cxx_simple_declaration (pp, t); + pp_cxx_simple_declaration (this, t); break; case NAMESPACE_DECL: if (DECL_NAMESPACE_ALIAS (t)) - pp_cxx_namespace_alias_definition (pp, t); + pp_cxx_namespace_alias_definition (this, t); else - pp_cxx_original_namespace_definition (pp, t); + pp_cxx_original_namespace_definition (this, t); break; default: - pp_unsupported_tree (pp, t); + pp_unsupported_tree (this, t); break; } } @@ -2431,15 +2428,8 @@ cxx_pretty_printer::cxx_pretty_printer () { pp_set_line_maximum_length (this, 0); - declaration = (pp_fun) pp_cxx_declaration; - declaration_specifiers = (pp_fun) pp_cxx_decl_specifier_seq; - function_specifier = (pp_fun) pp_cxx_function_specifier; type_specifier_seq = (pp_fun) pp_cxx_type_specifier_seq; - declarator = (pp_fun) pp_cxx_declarator; - direct_declarator = (pp_fun) pp_cxx_direct_declarator; parameter_list = (pp_fun) pp_cxx_parameter_declaration_clause; type_id = (pp_fun) pp_cxx_type_id; - abstract_declarator = (pp_fun) pp_cxx_abstract_declarator; - direct_abstract_declarator = (pp_fun) pp_cxx_direct_abstract_declarator; simple_type_specifier = (pp_fun) pp_cxx_simple_type_specifier; } diff --git a/gcc/cp/cxx-pretty-print.h b/gcc/cp/cxx-pretty-print.h index c3bb9c8bc54..c9856b39482 100644 --- a/gcc/cp/cxx-pretty-print.h +++ b/gcc/cp/cxx-pretty-print.h @@ -43,6 +43,13 @@ struct cxx_pretty_printer : c_pretty_printer void assignment_expression (tree); void expression (tree); void statement (tree); + void declaration (tree); + void declaration_specifiers (tree); + void function_specifier (tree); + void declarator (tree); + void direct_declarator (tree); + void abstract_declarator (tree); + void direct_abstract_declarator (tree); /* This is the enclosing scope of the entity being pretty-printed. */ tree enclosing_scope; @@ -77,7 +84,6 @@ void pp_cxx_end_template_argument_list (cxx_pretty_printer *); void pp_cxx_colon_colon (cxx_pretty_printer *); void pp_cxx_separate_with (cxx_pretty_printer *, int); -void pp_cxx_declaration (cxx_pretty_printer *, tree); void pp_cxx_canonical_template_parameter (cxx_pretty_printer *, tree); void pp_cxx_trait_expression (cxx_pretty_printer *, tree); void pp_cxx_va_arg_expression (cxx_pretty_printer *, tree); diff --git a/gcc/cp/error.c b/gcc/cp/error.c index af71000ec6c..cbb86a4874d 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1044,7 +1044,7 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) case NAMESPACE_DECL: if (flags & TFF_DECL_SPECIFIERS) - pp_cxx_declaration (pp, t); + pp->declaration (t); else { if (! (flags & TFF_UNQUALIFIED_NAME)) @@ -1196,7 +1196,7 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) break; case STATIC_ASSERT: - pp_cxx_declaration (pp, t); + pp->declaration (t); break; case BASELINK: @@ -1209,7 +1209,7 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) case TEMPLATE_TYPE_PARM: if (flags & TFF_DECL_SPECIFIERS) - pp_cxx_declaration (pp, t); + pp->declaration (t); else pp_type_id (pp, t); break;