Commit 20059c8b by Gabriel Dos Reis Committed by Gabriel Dos Reis

c-objc-common.c (c_tree_printer): Tidy.

c/
	* c-objc-common.c (c_tree_printer): Tidy.
c-family/
	* c-pretty-print.h (c_pretty_printer::type_id): Now a virtual
	member function.
	(c_pretty_printer::storage_class_specifier): Likewise.
	(c_pretty_printer::initializer): Likewise.
	(pp_declaration): Remove.
	(pp_declaration_specifiers): Likewise.
	(pp_abstract_declarator): Likewise.
	(pp_declarator): Likewise.
	(pp_type_id): Likewise.
	(pp_statement): Likewise.
	(pp_constant): Likewise.
	(pp_id_expression): Likewise.
	(pp_primary_expression): Likewise.
	(pp_unary_expression): Likewise.
	(pp_multiplicative_expression): Likewise.
	(pp_conditional_expression): Likewise.
	(pp_assignment_expression): Likewise.
	(pp_expression): Likewise.
	(pp_c_type_id): Likewise.
	(pp_c_storage_class_specifier): Likewise.
	* c-pretty-print.c (pp_c_type_cast): Tidy.
	(pp_c_pointer): Likewise.
	(pp_c_type_specifier): Likewise.
	(pp_c_parameter_type_list): Likewise.
	(pp_c_function_definition): Likewise.
	(pp_c_init_declarator): Likewise.
	(pp_c_initializer_list): Likewise.
	(pp_c_constructor_elts): Likewise.
	(c_pretty_printer::direct_abstract_declarator): Likewise.
	(c_pretty_printer::declaration_specifiers): Likewise.
	(c_pretty_printer::primary_expression): Likewise.
	(c_pretty_printer::postfix_expression): Likewise.
	(c_pretty_printer::type_id): Rename from pp_c_type_id.
	(c_pretty_printer::storage_class_specifier): Rename from
	pp_c_storage_class_specifier.
	(c_pretty_printer::initializer): Rename from pp_c_initializer.
	(c_pretty_printer::c_pretty_printer): Do not assign to type_id,
	storage_class_specifier, initializer, offset_list, flags.

cp/
	* cxx-pretty-print.h (cxx_pretty_printer::type_id): Declare as
	overrider.
	* cxx-pretty-print.c (pp_cxx_storage_class_specifier): Remove.
	(pp_cxx_userdef_literal): Tidy.
	(pp_cxx_template_argument_list): Likewise.
	(pp_cxx_typeid_expression): Likewise.
	(pp_cxx_offsetof_expression_1): Likewise.
	(cxx_pretty_printer::postfix_expression): Likewise.
	(cxx_pretty_printer::unary_expression): Likewise.
	(cxx_pretty_printer::statement): Likewise.
	(cxx_pretty_printer::type_id): Rename from pp_cxx_type_id.
	(c_pretty_printer::cxx_pretty_printer): Do not assign to type_id.
	* error.c (dump_decl): Tidy.
	(dump_expr): Likewise.

From-SVN: r202203
parent fa3bf4ce
2013-09-03 Gabriel Dos Reis <gdr@integrable-solutions.net>
* c-pretty-print.h (c_pretty_printer::type_id): Now a virtual
member function.
(c_pretty_printer::storage_class_specifier): Likewise.
(c_pretty_printer::initializer): Likewise.
(pp_declaration): Remove.
(pp_declaration_specifiers): Likewise.
(pp_abstract_declarator): Likewise.
(pp_declarator): Likewise.
(pp_type_id): Likewise.
(pp_statement): Likewise.
(pp_constant): Likewise.
(pp_id_expression): Likewise.
(pp_primary_expression): Likewise.
(pp_unary_expression): Likewise.
(pp_multiplicative_expression): Likewise.
(pp_conditional_expression): Likewise.
(pp_assignment_expression): Likewise.
(pp_expression): Likewise.
(pp_c_type_id): Likewise.
(pp_c_storage_class_specifier): Likewise.
* c-pretty-print.c (pp_c_type_cast): Tidy.
(pp_c_pointer): Likewise.
(pp_c_type_specifier): Likewise.
(pp_c_parameter_type_list): Likewise.
(pp_c_function_definition): Likewise.
(pp_c_init_declarator): Likewise.
(pp_c_initializer_list): Likewise.
(pp_c_constructor_elts): Likewise.
(c_pretty_printer::direct_abstract_declarator): Likewise.
(c_pretty_printer::declaration_specifiers): Likewise.
(c_pretty_printer::primary_expression): Likewise.
(c_pretty_printer::postfix_expression): Likewise.
(c_pretty_printer::type_id): Rename from pp_c_type_id.
(c_pretty_printer::storage_class_specifier): Rename from
pp_c_storage_class_specifier.
(c_pretty_printer::initializer): Rename from pp_c_initializer.
(c_pretty_printer::c_pretty_printer): Do not assign to type_id,
storage_class_specifier, initializer, offset_list, flags.
2013-08-30 Marek Polacek <polacek@redhat.com> 2013-08-30 Marek Polacek <polacek@redhat.com>
* c-ubsan.c: New file. * c-ubsan.c: New file.
......
...@@ -208,7 +208,7 @@ static void ...@@ -208,7 +208,7 @@ static void
pp_c_type_cast (c_pretty_printer *pp, tree t) pp_c_type_cast (c_pretty_printer *pp, tree t)
{ {
pp_c_left_paren (pp); pp_c_left_paren (pp);
pp_type_id (pp, t); pp->type_id (t);
pp_c_right_paren (pp); pp_c_right_paren (pp);
} }
...@@ -296,7 +296,7 @@ pp_c_pointer (c_pretty_printer *pp, tree t) ...@@ -296,7 +296,7 @@ pp_c_pointer (c_pretty_printer *pp, tree t)
/* ??? This node is now in GENERIC and so shouldn't be here. But /* ??? This node is now in GENERIC and so shouldn't be here. But
we'll fix that later. */ we'll fix that later. */
case DECL_EXPR: case DECL_EXPR:
pp_declaration (pp, DECL_EXPR_DECL (t)); pp->declaration (DECL_EXPR_DECL (t));
pp_needs_newline (pp) = true; pp_needs_newline (pp) = true;
break; break;
...@@ -393,7 +393,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t) ...@@ -393,7 +393,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
case TYPE_DECL: case TYPE_DECL:
if (DECL_NAME (t)) if (DECL_NAME (t))
pp_id_expression (pp, t); pp->id_expression (t);
else else
pp->translate_string ("<typedef-error>"); pp->translate_string ("<typedef-error>");
break; break;
...@@ -411,7 +411,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t) ...@@ -411,7 +411,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
pp->translate_string ("<tag-error>"); pp->translate_string ("<tag-error>");
if (TYPE_NAME (t)) if (TYPE_NAME (t))
pp_id_expression (pp, TYPE_NAME (t)); pp->id_expression (TYPE_NAME (t));
else else
pp->translate_string ("<anonymous>"); pp->translate_string ("<anonymous>");
break; break;
...@@ -431,7 +431,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t) ...@@ -431,7 +431,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
function declarations, this routine prints not just the function declarations, this routine prints not just the
specifier-qualifier-list of such entities or types of such entities, specifier-qualifier-list of such entities or types of such entities,
but also the 'pointer' production part of their declarators. The but also the 'pointer' production part of their declarators. The
remaining part is done by pp_declarator or pp_abstract_declarator. */ remaining part is done by declarator() or abstract_declarator(). */
void void
pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t) pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t)
...@@ -518,12 +518,12 @@ pp_c_parameter_type_list (c_pretty_printer *pp, tree t) ...@@ -518,12 +518,12 @@ pp_c_parameter_type_list (c_pretty_printer *pp, tree t)
if (!first) if (!first)
pp_separate_with (pp, ','); pp_separate_with (pp, ',');
first = false; first = false;
pp_declaration_specifiers pp->declaration_specifiers
(pp, want_parm_decl ? parms : TREE_VALUE (parms)); (want_parm_decl ? parms : TREE_VALUE (parms));
if (want_parm_decl) if (want_parm_decl)
pp_declarator (pp, parms); pp->declarator (parms);
else else
pp_abstract_declarator (pp, TREE_VALUE (parms)); pp->abstract_declarator (TREE_VALUE (parms));
} }
} }
pp_c_right_paren (pp); pp_c_right_paren (pp);
...@@ -577,8 +577,8 @@ c_pretty_printer::direct_abstract_declarator (tree t) ...@@ -577,8 +577,8 @@ c_pretty_printer::direct_abstract_declarator (tree t)
if (host_integerp (maxval, 0)) if (host_integerp (maxval, 0))
pp_wide_integer (this, tree_low_cst (maxval, 0) + 1); pp_wide_integer (this, tree_low_cst (maxval, 0) + 1);
else else
pp_expression (this, fold_build2 (PLUS_EXPR, type, maxval, expression (fold_build2 (PLUS_EXPR, type, maxval,
build_int_cst (type, 1))); build_int_cst (type, 1)));
} }
pp_c_right_bracket (this); pp_c_right_bracket (this);
direct_abstract_declarator (TREE_TYPE (t)); direct_abstract_declarator (TREE_TYPE (t));
...@@ -608,10 +608,10 @@ c_pretty_printer::direct_abstract_declarator (tree t) ...@@ -608,10 +608,10 @@ c_pretty_printer::direct_abstract_declarator (tree t)
specifier-qualifier-list abstract-declarator(opt) */ specifier-qualifier-list abstract-declarator(opt) */
void void
pp_c_type_id (c_pretty_printer *pp, tree t) c_pretty_printer::type_id (tree t)
{ {
pp_c_specifier_qualifier_list (pp, t); pp_c_specifier_qualifier_list (this, t);
pp_abstract_declarator (pp, t); abstract_declarator (t);
} }
/* storage-class-specifier: /* storage-class-specifier:
...@@ -622,16 +622,16 @@ pp_c_type_id (c_pretty_printer *pp, tree t) ...@@ -622,16 +622,16 @@ pp_c_type_id (c_pretty_printer *pp, tree t)
register */ register */
void void
pp_c_storage_class_specifier (c_pretty_printer *pp, tree t) c_pretty_printer::storage_class_specifier (tree t)
{ {
if (TREE_CODE (t) == TYPE_DECL) if (TREE_CODE (t) == TYPE_DECL)
pp_c_ws_string (pp, "typedef"); pp_c_ws_string (this, "typedef");
else if (DECL_P (t)) else if (DECL_P (t))
{ {
if (DECL_REGISTER (t)) if (DECL_REGISTER (t))
pp_c_ws_string (pp, "register"); pp_c_ws_string (this, "register");
else if (TREE_STATIC (t) && TREE_CODE (t) == VAR_DECL) else if (TREE_STATIC (t) && TREE_CODE (t) == VAR_DECL)
pp_c_ws_string (pp, "static"); pp_c_ws_string (this, "static");
} }
} }
...@@ -654,8 +654,8 @@ c_pretty_printer::function_specifier (tree t) ...@@ -654,8 +654,8 @@ c_pretty_printer::function_specifier (tree t)
void void
c_pretty_printer::declaration_specifiers (tree t) c_pretty_printer::declaration_specifiers (tree t)
{ {
pp_storage_class_specifier (this, t); storage_class_specifier (t);
pp_function_specifier (this, t); function_specifier (t);
pp_c_specifier_qualifier_list (this, DECL_P (t) ? TREE_TYPE (t) : t); pp_c_specifier_qualifier_list (this, DECL_P (t) ? TREE_TYPE (t) : t);
} }
...@@ -743,7 +743,7 @@ c_pretty_printer::declarator (tree t) ...@@ -743,7 +743,7 @@ c_pretty_printer::declarator (tree t)
case FUNCTION_TYPE: case FUNCTION_TYPE:
case FUNCTION_DECL: case FUNCTION_DECL:
case TYPE_DECL: case TYPE_DECL:
pp_direct_declarator (this, t); direct_declarator (t);
break; break;
...@@ -834,8 +834,8 @@ pp_c_attributes_display (c_pretty_printer *pp, tree a) ...@@ -834,8 +834,8 @@ pp_c_attributes_display (c_pretty_printer *pp, tree a)
void void
pp_c_function_definition (c_pretty_printer *pp, tree t) pp_c_function_definition (c_pretty_printer *pp, tree t)
{ {
pp_declaration_specifiers (pp, t); pp->declaration_specifiers (t);
pp_declarator (pp, t); pp->declarator (t);
pp_needs_newline (pp) = true; pp_needs_newline (pp) = true;
pp->statement (DECL_SAVED_TREE (t)); pp->statement (DECL_SAVED_TREE (t));
pp_newline_and_flush (pp); pp_newline_and_flush (pp);
...@@ -997,7 +997,7 @@ pp_c_enumeration_constant (c_pretty_printer *pp, tree e) ...@@ -997,7 +997,7 @@ pp_c_enumeration_constant (c_pretty_printer *pp, tree e)
; ;
if (value != NULL_TREE) if (value != NULL_TREE)
pp_id_expression (pp, TREE_PURPOSE (value)); pp->id_expression (TREE_PURPOSE (value));
else else
{ {
/* Value must have been cast. */ /* Value must have been cast. */
...@@ -1097,7 +1097,7 @@ pp_c_complex_expr (c_pretty_printer *pp, tree e) ...@@ -1097,7 +1097,7 @@ pp_c_complex_expr (c_pretty_printer *pp, tree e)
== TREE_OPERAND (TREE_OPERAND (imagexpr, 0), 0)) == TREE_OPERAND (TREE_OPERAND (imagexpr, 0), 0))
{ {
pp_c_type_cast (pp, type); pp_c_type_cast (pp, type);
pp_expression (pp, TREE_OPERAND (TREE_OPERAND (realexpr, 0), 0)); pp->expression (TREE_OPERAND (TREE_OPERAND (realexpr, 0), 0));
return; return;
} }
...@@ -1108,7 +1108,7 @@ pp_c_complex_expr (c_pretty_printer *pp, tree e) ...@@ -1108,7 +1108,7 @@ pp_c_complex_expr (c_pretty_printer *pp, tree e)
pp_c_type_cast (pp, type); pp_c_type_cast (pp, type);
if (TREE_CODE (realexpr) == NOP_EXPR) if (TREE_CODE (realexpr) == NOP_EXPR)
realexpr = TREE_OPERAND (realexpr, 0); realexpr = TREE_OPERAND (realexpr, 0);
pp_expression (pp, realexpr); pp->expression (realexpr);
return; return;
} }
...@@ -1248,7 +1248,7 @@ c_pretty_printer::primary_expression (tree e) ...@@ -1248,7 +1248,7 @@ c_pretty_printer::primary_expression (tree e)
primary_expression (TREE_OPERAND (e, 0)); primary_expression (TREE_OPERAND (e, 0));
pp_separate_with (this, ','); pp_separate_with (this, ',');
pp_ampersand (this); pp_ampersand (this);
pp_initializer (this, TREE_OPERAND (e, 1)); initializer (TREE_OPERAND (e, 1));
if (TREE_OPERAND (e, 2)) if (TREE_OPERAND (e, 2))
{ {
pp_separate_with (this, ','); pp_separate_with (this, ',');
...@@ -1260,7 +1260,7 @@ c_pretty_printer::primary_expression (tree e) ...@@ -1260,7 +1260,7 @@ c_pretty_printer::primary_expression (tree e)
default: default:
/* FIXME: Make sure we won't get into an infinite loop. */ /* FIXME: Make sure we won't get into an infinite loop. */
pp_c_left_paren (this); pp_c_left_paren (this);
pp_expression (this, e); expression (e);
pp_c_right_paren (this); pp_c_right_paren (this);
break; break;
} }
...@@ -1272,13 +1272,13 @@ c_pretty_printer::primary_expression (tree e) ...@@ -1272,13 +1272,13 @@ c_pretty_printer::primary_expression (tree e)
{ initializer-list } { initializer-list }
{ initializer-list , } */ { initializer-list , } */
static void void
pp_c_initializer (c_pretty_printer *pp, tree e) c_pretty_printer::initializer (tree e)
{ {
if (TREE_CODE (e) == CONSTRUCTOR) if (TREE_CODE (e) == CONSTRUCTOR)
pp_c_brace_enclosed_initializer_list (pp, e); pp_c_brace_enclosed_initializer_list (this, e);
else else
pp_expression (pp, e); expression (e);
} }
/* init-declarator: /* init-declarator:
...@@ -1288,7 +1288,7 @@ pp_c_initializer (c_pretty_printer *pp, tree e) ...@@ -1288,7 +1288,7 @@ pp_c_initializer (c_pretty_printer *pp, tree e)
void void
pp_c_init_declarator (c_pretty_printer *pp, tree t) pp_c_init_declarator (c_pretty_printer *pp, tree t)
{ {
pp_declarator (pp, t); pp->declarator (t);
/* We don't want to output function definitions here. There are handled /* We don't want to output function definitions here. There are handled
elsewhere (and the syntactic form is bogus anyway). */ elsewhere (and the syntactic form is bogus anyway). */
if (TREE_CODE (t) != FUNCTION_DECL && DECL_INITIAL (t)) if (TREE_CODE (t) != FUNCTION_DECL && DECL_INITIAL (t))
...@@ -1301,7 +1301,7 @@ pp_c_init_declarator (c_pretty_printer *pp, tree t) ...@@ -1301,7 +1301,7 @@ pp_c_init_declarator (c_pretty_printer *pp, tree t)
if (TREE_CODE (init) == TREE_LIST) if (TREE_CODE (init) == TREE_LIST)
{ {
pp_c_left_paren (pp); pp_c_left_paren (pp);
pp_expression (pp, TREE_VALUE (init)); pp->expression (TREE_VALUE (init));
pp_right_paren (pp); pp_right_paren (pp);
} }
else else
...@@ -1309,7 +1309,7 @@ pp_c_init_declarator (c_pretty_printer *pp, tree t) ...@@ -1309,7 +1309,7 @@ pp_c_init_declarator (c_pretty_printer *pp, tree t)
pp_space (pp); pp_space (pp);
pp_equal (pp); pp_equal (pp);
pp_space (pp); pp_space (pp);
pp_c_initializer (pp, init); pp->initializer (init);
} }
} }
} }
...@@ -1353,19 +1353,19 @@ pp_c_initializer_list (c_pretty_printer *pp, tree e) ...@@ -1353,19 +1353,19 @@ pp_c_initializer_list (c_pretty_printer *pp, tree e)
if (code == RECORD_TYPE || code == UNION_TYPE) if (code == RECORD_TYPE || code == UNION_TYPE)
{ {
pp_c_dot (pp); pp_c_dot (pp);
pp_primary_expression (pp, TREE_PURPOSE (init)); pp->primary_expression (TREE_PURPOSE (init));
} }
else else
{ {
pp_c_left_bracket (pp); pp_c_left_bracket (pp);
if (TREE_PURPOSE (init)) if (TREE_PURPOSE (init))
pp_constant (pp, TREE_PURPOSE (init)); pp->constant (TREE_PURPOSE (init));
pp_c_right_bracket (pp); pp_c_right_bracket (pp);
} }
pp_c_whitespace (pp); pp_c_whitespace (pp);
pp_equal (pp); pp_equal (pp);
pp_c_whitespace (pp); pp_c_whitespace (pp);
pp_initializer (pp, TREE_VALUE (init)); pp->initializer (TREE_VALUE (init));
if (TREE_CHAIN (init)) if (TREE_CHAIN (init))
pp_separate_with (pp, ','); pp_separate_with (pp, ',');
} }
...@@ -1380,7 +1380,7 @@ pp_c_initializer_list (c_pretty_printer *pp, tree e) ...@@ -1380,7 +1380,7 @@ pp_c_initializer_list (c_pretty_printer *pp, tree e)
{ {
if (i > 0) if (i > 0)
pp_separate_with (pp, ','); pp_separate_with (pp, ',');
pp_expression (pp, VECTOR_CST_ELT (e, i)); pp->expression (VECTOR_CST_ELT (e, i));
} }
} }
else else
...@@ -1391,9 +1391,9 @@ pp_c_initializer_list (c_pretty_printer *pp, tree e) ...@@ -1391,9 +1391,9 @@ pp_c_initializer_list (c_pretty_printer *pp, tree e)
if (TREE_CODE (e) == COMPLEX_CST || TREE_CODE (e) == COMPLEX_EXPR) if (TREE_CODE (e) == COMPLEX_CST || TREE_CODE (e) == COMPLEX_EXPR)
{ {
const bool cst = TREE_CODE (e) == COMPLEX_CST; const bool cst = TREE_CODE (e) == COMPLEX_CST;
pp_expression (pp, cst ? TREE_REALPART (e) : TREE_OPERAND (e, 0)); pp->expression (cst ? TREE_REALPART (e) : TREE_OPERAND (e, 0));
pp_separate_with (pp, ','); pp_separate_with (pp, ',');
pp_expression (pp, cst ? TREE_IMAGPART (e) : TREE_OPERAND (e, 1)); pp->expression (cst ? TREE_IMAGPART (e) : TREE_OPERAND (e, 1));
} }
else else
break; break;
...@@ -1474,18 +1474,18 @@ c_pretty_printer::postfix_expression (tree e) ...@@ -1474,18 +1474,18 @@ c_pretty_printer::postfix_expression (tree e)
case ARRAY_REF: case ARRAY_REF:
postfix_expression (TREE_OPERAND (e, 0)); postfix_expression (TREE_OPERAND (e, 0));
pp_c_left_bracket (this); pp_c_left_bracket (this);
pp_expression (this, TREE_OPERAND (e, 1)); expression (TREE_OPERAND (e, 1));
pp_c_right_bracket (this); pp_c_right_bracket (this);
break; break;
case ARRAY_NOTATION_REF: case ARRAY_NOTATION_REF:
postfix_expression (ARRAY_NOTATION_ARRAY (e)); postfix_expression (ARRAY_NOTATION_ARRAY (e));
pp_c_left_bracket (this); pp_c_left_bracket (this);
pp_expression (this, ARRAY_NOTATION_START (e)); expression (ARRAY_NOTATION_START (e));
pp_colon (this); pp_colon (this);
pp_expression (this, ARRAY_NOTATION_LENGTH (e)); expression (ARRAY_NOTATION_LENGTH (e));
pp_colon (this); pp_colon (this);
pp_expression (this, ARRAY_NOTATION_STRIDE (e)); expression (ARRAY_NOTATION_STRIDE (e));
pp_c_right_bracket (this); pp_c_right_bracket (this);
break; break;
...@@ -1497,7 +1497,7 @@ c_pretty_printer::postfix_expression (tree e) ...@@ -1497,7 +1497,7 @@ c_pretty_printer::postfix_expression (tree e)
pp_c_left_paren (this); pp_c_left_paren (this);
FOR_EACH_CALL_EXPR_ARG (arg, iter, e) FOR_EACH_CALL_EXPR_ARG (arg, iter, e)
{ {
pp_expression (this, arg); expression (arg);
if (more_call_expr_args_p (&iter)) if (more_call_expr_args_p (&iter))
pp_separate_with (this, ','); pp_separate_with (this, ',');
} }
...@@ -1555,16 +1555,16 @@ c_pretty_printer::postfix_expression (tree e) ...@@ -1555,16 +1555,16 @@ c_pretty_printer::postfix_expression (tree e)
two_args_fun: two_args_fun:
pp_c_left_paren (this); pp_c_left_paren (this);
pp_expression (this, TREE_OPERAND (e, 0)); expression (TREE_OPERAND (e, 0));
pp_separate_with (this, ','); pp_separate_with (this, ',');
pp_expression (this, TREE_OPERAND (e, 1)); expression (TREE_OPERAND (e, 1));
pp_c_right_paren (this); pp_c_right_paren (this);
break; break;
case ABS_EXPR: case ABS_EXPR:
pp_c_ws_string (this, "__builtin_abs"); pp_c_ws_string (this, "__builtin_abs");
pp_c_left_paren (this); pp_c_left_paren (this);
pp_expression (this, TREE_OPERAND (e, 0)); expression (TREE_OPERAND (e, 0));
pp_c_right_paren (this); pp_c_right_paren (this);
break; break;
...@@ -1581,7 +1581,7 @@ c_pretty_printer::postfix_expression (tree e) ...@@ -1581,7 +1581,7 @@ c_pretty_printer::postfix_expression (tree e)
postfix_expression (object); postfix_expression (object);
pp_c_dot (this); pp_c_dot (this);
} }
pp_expression (this, TREE_OPERAND (e, 1)); expression (TREE_OPERAND (e, 1));
} }
break; break;
...@@ -1599,11 +1599,11 @@ c_pretty_printer::postfix_expression (tree e) ...@@ -1599,11 +1599,11 @@ c_pretty_printer::postfix_expression (tree e)
{ {
pp_c_left_paren (this); pp_c_left_paren (this);
pp_c_left_paren (this); pp_c_left_paren (this);
pp_type_id (this, type); type_id (type);
pp_c_star (this); pp_c_star (this);
pp_c_right_paren (this); pp_c_right_paren (this);
pp_c_ampersand (this); pp_c_ampersand (this);
pp_expression (this, TREE_OPERAND (e, 0)); expression (TREE_OPERAND (e, 0));
pp_c_right_paren (this); pp_c_right_paren (this);
pp_c_left_bracket (this); pp_c_left_bracket (this);
pp_wide_integer (this, bitpos / size); pp_wide_integer (this, bitpos / size);
...@@ -1632,7 +1632,7 @@ c_pretty_printer::postfix_expression (tree e) ...@@ -1632,7 +1632,7 @@ c_pretty_printer::postfix_expression (tree e)
e = DECL_INITIAL (COMPOUND_LITERAL_EXPR_DECL (e)); e = DECL_INITIAL (COMPOUND_LITERAL_EXPR_DECL (e));
/* Fall through. */ /* Fall through. */
case CONSTRUCTOR: case CONSTRUCTOR:
pp_initializer (this, e); initializer (e);
break; break;
case VA_ARG_EXPR: case VA_ARG_EXPR:
...@@ -1640,7 +1640,7 @@ c_pretty_printer::postfix_expression (tree e) ...@@ -1640,7 +1640,7 @@ c_pretty_printer::postfix_expression (tree e)
pp_c_left_paren (this); pp_c_left_paren (this);
assignment_expression (TREE_OPERAND (e, 0)); assignment_expression (TREE_OPERAND (e, 0));
pp_separate_with (this, ','); pp_separate_with (this, ',');
pp_type_id (this, TREE_TYPE (e)); type_id (TREE_TYPE (e));
pp_c_right_paren (this); pp_c_right_paren (this);
break; break;
...@@ -1665,7 +1665,7 @@ pp_c_expression_list (c_pretty_printer *pp, tree e) ...@@ -1665,7 +1665,7 @@ pp_c_expression_list (c_pretty_printer *pp, tree e)
{ {
for (; e != NULL_TREE; e = TREE_CHAIN (e)) for (; e != NULL_TREE; e = TREE_CHAIN (e))
{ {
pp_expression (pp, TREE_VALUE (e)); pp->expression (TREE_VALUE (e));
if (TREE_CHAIN (e)) if (TREE_CHAIN (e))
pp_separate_with (pp, ','); pp_separate_with (pp, ',');
} }
...@@ -1681,7 +1681,7 @@ pp_c_constructor_elts (c_pretty_printer *pp, vec<constructor_elt, va_gc> *v) ...@@ -1681,7 +1681,7 @@ pp_c_constructor_elts (c_pretty_printer *pp, vec<constructor_elt, va_gc> *v)
FOR_EACH_CONSTRUCTOR_VALUE (v, ix, value) FOR_EACH_CONSTRUCTOR_VALUE (v, ix, value)
{ {
pp_expression (pp, value); pp->expression (value);
if (ix != vec_safe_length (v) - 1) if (ix != vec_safe_length (v) - 1)
pp_separate_with (pp, ','); pp_separate_with (pp, ',');
} }
...@@ -1806,7 +1806,7 @@ pp_c_cast_expression (c_pretty_printer *pp, tree e) ...@@ -1806,7 +1806,7 @@ pp_c_cast_expression (c_pretty_printer *pp, tree e)
break; break;
default: default:
pp_unary_expression (pp, e); pp->unary_expression (e);
} }
} }
...@@ -1864,11 +1864,11 @@ pp_c_additive_expression (c_pretty_printer *pp, tree e) ...@@ -1864,11 +1864,11 @@ pp_c_additive_expression (c_pretty_printer *pp, tree e)
else else
pp_minus (pp); pp_minus (pp);
pp_c_whitespace (pp); pp_c_whitespace (pp);
pp_multiplicative_expression (pp, TREE_OPERAND (e, 1)); pp->multiplicative_expression (TREE_OPERAND (e, 1));
break; break;
default: default:
pp_multiplicative_expression (pp, e); pp->multiplicative_expression (e);
break; break;
} }
} }
...@@ -2075,7 +2075,7 @@ c_pretty_printer::conditional_expression (tree e) ...@@ -2075,7 +2075,7 @@ c_pretty_printer::conditional_expression (tree e)
pp_c_whitespace (this); pp_c_whitespace (this);
pp_question (this); pp_question (this);
pp_c_whitespace (this); pp_c_whitespace (this);
pp_expression (this, TREE_OPERAND (e, 1)); expression (TREE_OPERAND (e, 1));
pp_c_whitespace (this); pp_c_whitespace (this);
pp_colon (this); pp_colon (this);
pp_c_whitespace (this); pp_c_whitespace (this);
...@@ -2103,7 +2103,7 @@ c_pretty_printer::assignment_expression (tree e) ...@@ -2103,7 +2103,7 @@ c_pretty_printer::assignment_expression (tree e)
pp_c_whitespace (this); pp_c_whitespace (this);
pp_equal (this); pp_equal (this);
pp_space (this); pp_space (this);
pp_expression (this, TREE_OPERAND (e, 1)); expression (TREE_OPERAND (e, 1));
} }
else else
conditional_expression (e); conditional_expression (e);
...@@ -2116,8 +2116,8 @@ c_pretty_printer::assignment_expression (tree e) ...@@ -2116,8 +2116,8 @@ c_pretty_printer::assignment_expression (tree e)
Implementation note: instead of going through the usual recursion Implementation note: instead of going through the usual recursion
chain, I take the liberty of dispatching nodes to the appropriate chain, I take the liberty of dispatching nodes to the appropriate
functions. This makes some redundancy, but it worths it. That also functions. This makes some redundancy, but it worths it. That also
prevents a possible infinite recursion between pp_primary_expression () prevents a possible infinite recursion between primary_expression ()
and pp_expression (). */ and expression (). */
void void
c_pretty_printer::expression (tree e) c_pretty_printer::expression (tree e)
...@@ -2321,18 +2321,14 @@ c_pretty_printer::statement (tree stmt) ...@@ -2321,18 +2321,14 @@ c_pretty_printer::statement (tree stmt)
/* Initialize the PRETTY-PRINTER for handling C codes. */ /* Initialize the PRETTY-PRINTER for handling C codes. */
c_pretty_printer::c_pretty_printer () c_pretty_printer::c_pretty_printer ()
: pretty_printer () : pretty_printer (),
offset_list (),
flags ()
{ {
offset_list = 0;
flags = 0;
type_specifier_seq = pp_c_specifier_qualifier_list; type_specifier_seq = pp_c_specifier_qualifier_list;
ptr_operator = pp_c_pointer; ptr_operator = pp_c_pointer;
parameter_list = pp_c_parameter_type_list; parameter_list = pp_c_parameter_type_list;
type_id = pp_c_type_id;
simple_type_specifier = pp_c_type_specifier; simple_type_specifier = pp_c_type_specifier;
storage_class_specifier = pp_c_storage_class_specifier;
initializer = pp_c_initializer;
} }
......
...@@ -64,15 +64,19 @@ struct c_pretty_printer : pretty_printer ...@@ -64,15 +64,19 @@ struct c_pretty_printer : pretty_printer
virtual void assignment_expression (tree); virtual void assignment_expression (tree);
virtual void expression (tree); virtual void expression (tree);
virtual void type_id (tree);
virtual void statement (tree); virtual void statement (tree);
virtual void declaration (tree); virtual void declaration (tree);
virtual void declaration_specifiers (tree); virtual void declaration_specifiers (tree);
virtual void function_specifier (tree); virtual void function_specifier (tree);
virtual void storage_class_specifier (tree);
virtual void declarator (tree); virtual void declarator (tree);
virtual void direct_declarator (tree); virtual void direct_declarator (tree);
virtual void abstract_declarator (tree); virtual void abstract_declarator (tree);
virtual void direct_abstract_declarator (tree); virtual void direct_abstract_declarator (tree);
virtual void initializer (tree);
/* Points to the first element of an array of offset-list. /* Points to the first element of an array of offset-list.
Not used yet. */ Not used yet. */
int *offset_list; int *offset_list;
...@@ -84,45 +88,16 @@ struct c_pretty_printer : pretty_printer ...@@ -84,45 +88,16 @@ struct c_pretty_printer : pretty_printer
c_pretty_print_fn type_specifier_seq; c_pretty_print_fn type_specifier_seq;
c_pretty_print_fn ptr_operator; c_pretty_print_fn ptr_operator;
c_pretty_print_fn parameter_list; c_pretty_print_fn parameter_list;
c_pretty_print_fn type_id;
c_pretty_print_fn simple_type_specifier; c_pretty_print_fn simple_type_specifier;
c_pretty_print_fn storage_class_specifier;
c_pretty_print_fn initializer;
}; };
#define pp_c_tree_identifier(PPI, ID) \ #define pp_c_tree_identifier(PPI, ID) \
pp_c_identifier (PPI, IDENTIFIER_POINTER (ID)) pp_c_identifier (PPI, IDENTIFIER_POINTER (ID))
#define pp_declaration(PP, T) (PP)->declaration (T)
#define pp_declaration_specifiers(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_type_specifier_seq(PP, D) (PP)->type_specifier_seq (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_ptr_operator(PP, D) (PP)->ptr_operator (PP, D)
#define pp_parameter_list(PP, T) (PP)->parameter_list (PP, T) #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_simple_type_specifier(PP, T) (PP)->simple_type_specifier (PP, T)
#define pp_function_specifier(PP, D) (PP)->function_specifier (D)
#define pp_storage_class_specifier(PP, D) \
(PP)->storage_class_specifier (PP, D);
#define pp_statement(PP, S) (PP)->statement (PP, S)
#define pp_constant(PP, E) (PP)->constant (E)
#define pp_id_expression(PP, E) (PP)->id_expression (E)
#define pp_primary_expression(PP, E) (PP)->primary_expression (E)
#define pp_postfix_expression(PP, E) (PP)->postfix_expression (E)
#define pp_unary_expression(PP, E) (PP)->unary_expression (E)
#define pp_initializer(PP, E) (PP)->initializer (PP, E)
#define pp_multiplicative_expression(PP, E) \
(PP)->multiplicative_expression (E)
#define pp_conditional_expression(PP, E) (PP)->conditional_expression (E)
#define pp_assignment_expression(PP, E) (PP)->assignment_expression (E)
#define pp_expression(PP, E) (PP)->expression (E)
void pp_c_whitespace (c_pretty_printer *); void pp_c_whitespace (c_pretty_printer *);
void pp_c_left_paren (c_pretty_printer *); void pp_c_left_paren (c_pretty_printer *);
...@@ -149,9 +124,7 @@ void pp_c_cv_qualifiers (c_pretty_printer *pp, int qualifiers, bool func_type); ...@@ -149,9 +124,7 @@ 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_type_qualifier_list (c_pretty_printer *, tree);
void pp_c_parameter_type_list (c_pretty_printer *, tree); void pp_c_parameter_type_list (c_pretty_printer *, tree);
void pp_c_specifier_qualifier_list (c_pretty_printer *, tree); void pp_c_specifier_qualifier_list (c_pretty_printer *, tree);
void pp_c_type_id (c_pretty_printer *, tree);
void pp_c_type_specifier (c_pretty_printer *, tree); void pp_c_type_specifier (c_pretty_printer *, tree);
void pp_c_storage_class_specifier (c_pretty_printer *, tree);
/* Expressions. */ /* Expressions. */
void pp_c_logical_or_expression (c_pretty_printer *, tree); void pp_c_logical_or_expression (c_pretty_printer *, tree);
void pp_c_expression_list (c_pretty_printer *, tree); void pp_c_expression_list (c_pretty_printer *, tree);
......
2013-09-03 Gabriel Dos Reis <gdr@integrable-solutions.net>
* c-objc-common.c (c_tree_printer): Tidy.
2013-08-30 Marek Polacek <polacek@redhat.com> 2013-08-30 Marek Polacek <polacek@redhat.com>
* c-typeck.c (build_binary_op): Add division by zero and shift * c-typeck.c (build_binary_op): Add division by zero and shift
......
...@@ -120,7 +120,7 @@ c_tree_printer (pretty_printer *pp, text_info *text, const char *spec, ...@@ -120,7 +120,7 @@ c_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
t = DECL_DEBUG_EXPR (t); t = DECL_DEBUG_EXPR (t);
if (!DECL_P (t)) if (!DECL_P (t))
{ {
pp_expression (cpp, t); cpp->expression (t);
return true; return true;
} }
} }
...@@ -143,12 +143,12 @@ c_tree_printer (pretty_printer *pp, text_info *text, const char *spec, ...@@ -143,12 +143,12 @@ c_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
if (DECL_NAME (name)) if (DECL_NAME (name))
pp_identifier (cpp, lang_hooks.decl_printable_name (name, 2)); pp_identifier (cpp, lang_hooks.decl_printable_name (name, 2));
else else
pp_type_id (cpp, t); cpp->type_id (t);
return true; return true;
} }
else else
{ {
pp_type_id (cpp, t); cpp->type_id (t);
return true; return true;
} }
break; break;
...@@ -157,7 +157,7 @@ c_tree_printer (pretty_printer *pp, text_info *text, const char *spec, ...@@ -157,7 +157,7 @@ c_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
if (TREE_CODE (t) == IDENTIFIER_NODE) if (TREE_CODE (t) == IDENTIFIER_NODE)
pp_identifier (cpp, IDENTIFIER_POINTER (t)); pp_identifier (cpp, IDENTIFIER_POINTER (t));
else else
pp_expression (cpp, t); cpp->expression (t);
return true; return true;
case 'V': case 'V':
......
2013-09-03 Gabriel Dos Reis <gdr@integrable-solutions.net>
* cxx-pretty-print.h (cxx_pretty_printer::type_id): Declare as
overrider.
* cxx-pretty-print.c (pp_cxx_storage_class_specifier): Remove.
(pp_cxx_userdef_literal): Tidy.
(pp_cxx_template_argument_list): Likewise.
(pp_cxx_typeid_expression): Likewise.
(pp_cxx_offsetof_expression_1): Likewise.
(cxx_pretty_printer::postfix_expression): Likewise.
(cxx_pretty_printer::unary_expression): Likewise.
(cxx_pretty_printer::statement): Likewise.
(cxx_pretty_printer::type_id): Rename from pp_cxx_type_id.
(c_pretty_printer::cxx_pretty_printer): Do not assign to type_id.
* error.c (dump_decl): Tidy.
(dump_expr): Likewise.
2013-09-02 Paolo Carlini <paolo.carlini@oracle.com> 2013-09-02 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/21682, implement DR 565 PR c++/21682, implement DR 565
......
...@@ -33,7 +33,6 @@ static void pp_cxx_qualified_id (cxx_pretty_printer *, tree); ...@@ -33,7 +33,6 @@ static void pp_cxx_qualified_id (cxx_pretty_printer *, tree);
static void pp_cxx_template_argument_list (cxx_pretty_printer *, tree); 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_type_specifier_seq (cxx_pretty_printer *, tree);
static void pp_cxx_ptr_operator (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_parameter_declaration_clause (cxx_pretty_printer *, tree); static void pp_cxx_parameter_declaration_clause (cxx_pretty_printer *, tree);
static void pp_cxx_template_parameter (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_cast_expression (cxx_pretty_printer *, tree);
...@@ -51,8 +50,6 @@ pp_cxx_nonconsecutive_character (cxx_pretty_printer *pp, int c) ...@@ -51,8 +50,6 @@ pp_cxx_nonconsecutive_character (cxx_pretty_printer *pp, int c)
pp->padding = pp_none; pp->padding = pp_none;
} }
#define pp_cxx_storage_class_specifier(PP, T) \
pp_c_storage_class_specifier (PP, T)
#define pp_cxx_expression_list(PP, T) \ #define pp_cxx_expression_list(PP, T) \
pp_c_expression_list (PP, T) pp_c_expression_list (PP, T)
#define pp_cxx_space_for_pointer_operator(PP, T) \ #define pp_cxx_space_for_pointer_operator(PP, T) \
...@@ -362,8 +359,8 @@ cxx_pretty_printer::id_expression (tree t) ...@@ -362,8 +359,8 @@ cxx_pretty_printer::id_expression (tree t)
void void
pp_cxx_userdef_literal (cxx_pretty_printer *pp, tree t) pp_cxx_userdef_literal (cxx_pretty_printer *pp, tree t)
{ {
pp_constant (pp, USERDEF_LITERAL_VALUE (t)); pp->constant (USERDEF_LITERAL_VALUE (t));
pp_id_expression (pp, USERDEF_LITERAL_SUFFIX_ID (t)); pp->id_expression (USERDEF_LITERAL_SUFFIX_ID (t));
} }
...@@ -601,7 +598,7 @@ cxx_pretty_printer::postfix_expression (tree t) ...@@ -601,7 +598,7 @@ cxx_pretty_printer::postfix_expression (tree t)
else else
pp_cxx_ws_string (this, "const_cast"); pp_cxx_ws_string (this, "const_cast");
pp_cxx_begin_template_argument_list (this); pp_cxx_begin_template_argument_list (this);
pp_cxx_type_id (this, TREE_TYPE (t)); type_id (TREE_TYPE (t));
pp_cxx_end_template_argument_list (this); pp_cxx_end_template_argument_list (this);
pp_left_paren (this); pp_left_paren (this);
expression (TREE_OPERAND (t, 0)); expression (TREE_OPERAND (t, 0));
...@@ -609,7 +606,7 @@ cxx_pretty_printer::postfix_expression (tree t) ...@@ -609,7 +606,7 @@ cxx_pretty_printer::postfix_expression (tree t)
break; break;
case EMPTY_CLASS_EXPR: case EMPTY_CLASS_EXPR:
pp_cxx_type_id (this, TREE_TYPE (t)); type_id (TREE_TYPE (t));
pp_left_paren (this); pp_left_paren (this);
pp_right_paren (this); pp_right_paren (this);
break; break;
...@@ -684,7 +681,7 @@ pp_cxx_new_expression (cxx_pretty_printer *pp, tree t) ...@@ -684,7 +681,7 @@ pp_cxx_new_expression (cxx_pretty_printer *pp, tree t)
MINUS_EXPR, integer_type_node, MINUS_EXPR, integer_type_node,
TREE_OPERAND (type, 1), TREE_OPERAND (type, 1),
integer_one_node))); integer_one_node)));
pp_cxx_type_id (pp, type); pp->type_id (type);
if (init) if (init)
{ {
pp_left_paren (pp); pp_left_paren (pp);
...@@ -693,7 +690,7 @@ pp_cxx_new_expression (cxx_pretty_printer *pp, tree t) ...@@ -693,7 +690,7 @@ pp_cxx_new_expression (cxx_pretty_printer *pp, tree t)
else if (init == void_zero_node) else if (init == void_zero_node)
; /* OK, empty initializer list. */ ; /* OK, empty initializer list. */
else else
pp_expression (pp, init); pp->expression (init);
pp_right_paren (pp); pp_right_paren (pp);
} }
break; break;
...@@ -776,7 +773,7 @@ cxx_pretty_printer::unary_expression (tree t) ...@@ -776,7 +773,7 @@ cxx_pretty_printer::unary_expression (tree t)
pp_cxx_whitespace (this); pp_cxx_whitespace (this);
pp_cxx_left_paren (this); pp_cxx_left_paren (this);
if (TYPE_P (TREE_OPERAND (t, 0))) if (TYPE_P (TREE_OPERAND (t, 0)))
pp_cxx_type_id (this, TREE_OPERAND (t, 0)); type_id (TREE_OPERAND (t, 0));
else else
unary_expression (TREE_OPERAND (t, 0)); unary_expression (TREE_OPERAND (t, 0));
pp_cxx_right_paren (this); pp_cxx_right_paren (this);
...@@ -790,13 +787,13 @@ cxx_pretty_printer::unary_expression (tree t) ...@@ -790,13 +787,13 @@ cxx_pretty_printer::unary_expression (tree t)
if (TREE_CODE (t) == SIZEOF_EXPR && SIZEOF_EXPR_TYPE_P (t)) if (TREE_CODE (t) == SIZEOF_EXPR && SIZEOF_EXPR_TYPE_P (t))
{ {
pp_cxx_left_paren (this); pp_cxx_left_paren (this);
pp_cxx_type_id (this, TREE_TYPE (TREE_OPERAND (t, 0))); type_id (TREE_TYPE (TREE_OPERAND (t, 0)));
pp_cxx_right_paren (this); pp_cxx_right_paren (this);
} }
else if (TYPE_P (TREE_OPERAND (t, 0))) else if (TYPE_P (TREE_OPERAND (t, 0)))
{ {
pp_cxx_left_paren (this); pp_cxx_left_paren (this);
pp_cxx_type_id (this, TREE_OPERAND (t, 0)); type_id (TREE_OPERAND (t, 0));
pp_cxx_right_paren (this); pp_cxx_right_paren (this);
} }
else else
...@@ -807,7 +804,7 @@ cxx_pretty_printer::unary_expression (tree t) ...@@ -807,7 +804,7 @@ cxx_pretty_printer::unary_expression (tree t)
pp_cxx_ws_string (this, "@encode"); pp_cxx_ws_string (this, "@encode");
pp_cxx_whitespace (this); pp_cxx_whitespace (this);
pp_cxx_left_paren (this); pp_cxx_left_paren (this);
pp_cxx_type_id (this, TREE_OPERAND (t, 0)); type_id (TREE_OPERAND (t, 0));
pp_cxx_right_paren (this); pp_cxx_right_paren (this);
break; break;
...@@ -841,7 +838,7 @@ pp_cxx_cast_expression (cxx_pretty_printer *pp, tree t) ...@@ -841,7 +838,7 @@ pp_cxx_cast_expression (cxx_pretty_printer *pp, tree t)
{ {
case CAST_EXPR: case CAST_EXPR:
case IMPLICIT_CONV_EXPR: case IMPLICIT_CONV_EXPR:
pp_cxx_type_id (pp, TREE_TYPE (t)); pp->type_id (TREE_TYPE (t));
pp_cxx_call_argument_list (pp, TREE_OPERAND (t, 0)); pp_cxx_call_argument_list (pp, TREE_OPERAND (t, 0));
break; break;
...@@ -1214,7 +1211,7 @@ cxx_pretty_printer::declaration_specifiers (tree t) ...@@ -1214,7 +1211,7 @@ cxx_pretty_printer::declaration_specifiers (tree t)
case PARM_DECL: case PARM_DECL:
case CONST_DECL: case CONST_DECL:
case FIELD_DECL: case FIELD_DECL:
pp_cxx_storage_class_specifier (this, t); storage_class_specifier (t);
declaration_specifiers (TREE_TYPE (t)); declaration_specifiers (TREE_TYPE (t));
break; break;
...@@ -1315,7 +1312,7 @@ pp_cxx_type_specifier_seq (cxx_pretty_printer *pp, tree t) ...@@ -1315,7 +1312,7 @@ pp_cxx_type_specifier_seq (cxx_pretty_printer *pp, tree t)
case DECLTYPE_TYPE: case DECLTYPE_TYPE:
pp_cxx_ws_string (pp, "decltype"); pp_cxx_ws_string (pp, "decltype");
pp_cxx_left_paren (pp); pp_cxx_left_paren (pp);
pp_expression (pp, DECLTYPE_TYPE_EXPR (t)); pp->expression (DECLTYPE_TYPE_EXPR (t));
pp_cxx_right_paren (pp); pp_cxx_right_paren (pp);
break; break;
...@@ -1406,9 +1403,9 @@ pp_cxx_parameter_declaration (cxx_pretty_printer *pp, tree t) ...@@ -1406,9 +1403,9 @@ pp_cxx_parameter_declaration (cxx_pretty_printer *pp, tree t)
{ {
pp->declaration_specifiers (t); pp->declaration_specifiers (t);
if (TYPE_P (t)) if (TYPE_P (t))
pp_abstract_declarator (pp, t); pp->abstract_declarator (t);
else else
pp_declarator (pp, t); pp->declarator (t);
} }
/* parameter-declaration-clause: /* parameter-declaration-clause:
...@@ -1444,7 +1441,7 @@ pp_cxx_parameter_declaration_clause (cxx_pretty_printer *pp, tree t) ...@@ -1444,7 +1441,7 @@ pp_cxx_parameter_declaration_clause (cxx_pretty_printer *pp, tree t)
pp_cxx_whitespace (pp); pp_cxx_whitespace (pp);
pp_equal (pp); pp_equal (pp);
pp_cxx_whitespace (pp); pp_cxx_whitespace (pp);
pp_assignment_expression (pp, TREE_PURPOSE (types)); pp->assignment_expression (TREE_PURPOSE (types));
} }
} }
pp_cxx_right_paren (pp); pp_cxx_right_paren (pp);
...@@ -1473,7 +1470,7 @@ pp_cxx_exception_specification (cxx_pretty_printer *pp, tree t) ...@@ -1473,7 +1470,7 @@ pp_cxx_exception_specification (cxx_pretty_printer *pp, tree t)
if (DEFERRED_NOEXCEPT_SPEC_P (ex_spec)) if (DEFERRED_NOEXCEPT_SPEC_P (ex_spec))
pp_cxx_ws_string (pp, "<uninstantiated>"); pp_cxx_ws_string (pp, "<uninstantiated>");
else else
pp_expression (pp, TREE_PURPOSE (ex_spec)); pp->expression (TREE_PURPOSE (ex_spec));
pp_cxx_right_paren (pp); pp_cxx_right_paren (pp);
return; return;
} }
...@@ -1501,7 +1498,7 @@ pp_cxx_exception_specification (cxx_pretty_printer *pp, tree t) ...@@ -1501,7 +1498,7 @@ pp_cxx_exception_specification (cxx_pretty_printer *pp, tree t)
else else
need_comma = true; need_comma = true;
pp_cxx_type_id (pp, type); pp->type_id (type);
} }
} }
pp_cxx_right_paren (pp); pp_cxx_right_paren (pp);
...@@ -1602,9 +1599,9 @@ pp_cxx_ctor_initializer (cxx_pretty_printer *pp, tree t) ...@@ -1602,9 +1599,9 @@ pp_cxx_ctor_initializer (cxx_pretty_printer *pp, tree t)
bool is_pack = PACK_EXPANSION_P (purpose); bool is_pack = PACK_EXPANSION_P (purpose);
if (is_pack) if (is_pack)
pp_primary_expression (pp, PACK_EXPANSION_PATTERN (purpose)); pp->primary_expression (PACK_EXPANSION_PATTERN (purpose));
else else
pp_primary_expression (pp, purpose); pp->primary_expression (purpose);
pp_cxx_call_argument_list (pp, TREE_VALUE (t)); pp_cxx_call_argument_list (pp, TREE_VALUE (t));
if (is_pack) if (is_pack)
pp_cxx_ws_string (pp, "..."); pp_cxx_ws_string (pp, "...");
...@@ -1622,7 +1619,7 @@ pp_cxx_function_definition (cxx_pretty_printer *pp, tree t) ...@@ -1622,7 +1619,7 @@ pp_cxx_function_definition (cxx_pretty_printer *pp, tree t)
{ {
tree saved_scope = pp->enclosing_scope; tree saved_scope = pp->enclosing_scope;
pp->declaration_specifiers (t); pp->declaration_specifiers (t);
pp_declarator (pp, t); pp->declarator (t);
pp_needs_newline (pp) = true; pp_needs_newline (pp) = true;
pp->enclosing_scope = DECL_CONTEXT (t); pp->enclosing_scope = DECL_CONTEXT (t);
if (DECL_SAVED_TREE (t)) if (DECL_SAVED_TREE (t))
...@@ -1700,11 +1697,11 @@ cxx_pretty_printer::direct_abstract_declarator (tree t) ...@@ -1700,11 +1697,11 @@ cxx_pretty_printer::direct_abstract_declarator (tree t)
/* type-id: /* type-id:
type-specifier-seq abstract-declarator(opt) */ type-specifier-seq abstract-declarator(opt) */
static void void
pp_cxx_type_id (cxx_pretty_printer *pp, tree t) cxx_pretty_printer::type_id (tree t)
{ {
pp_flags saved_flags = pp->flags; pp_flags saved_flags = flags;
pp->flags |= pp_c_flag_abstract; flags |= pp_c_flag_abstract;
switch (TREE_CODE (t)) switch (TREE_CODE (t))
{ {
...@@ -1723,20 +1720,20 @@ pp_cxx_type_id (cxx_pretty_printer *pp, tree t) ...@@ -1723,20 +1720,20 @@ pp_cxx_type_id (cxx_pretty_printer *pp, tree t)
case UNDERLYING_TYPE: case UNDERLYING_TYPE:
case DECLTYPE_TYPE: case DECLTYPE_TYPE:
case TEMPLATE_ID_EXPR: case TEMPLATE_ID_EXPR:
pp_cxx_type_specifier_seq (pp, t); pp_cxx_type_specifier_seq (this, t);
break; break;
case TYPE_PACK_EXPANSION: case TYPE_PACK_EXPANSION:
pp_cxx_type_id (pp, PACK_EXPANSION_PATTERN (t)); type_id (PACK_EXPANSION_PATTERN (t));
pp_cxx_ws_string (pp, "..."); pp_cxx_ws_string (this, "...");
break; break;
default: default:
pp_c_type_id (pp, t); c_pretty_printer::type_id (t);
break; break;
} }
pp->flags = saved_flags; flags = saved_flags;
} }
/* template-argument-list: /* template-argument-list:
...@@ -1780,9 +1777,9 @@ pp_cxx_template_argument_list (cxx_pretty_printer *pp, tree t) ...@@ -1780,9 +1777,9 @@ pp_cxx_template_argument_list (cxx_pretty_printer *pp, tree t)
if (TYPE_P (arg) || (TREE_CODE (arg) == TEMPLATE_DECL if (TYPE_P (arg) || (TREE_CODE (arg) == TEMPLATE_DECL
&& TYPE_P (DECL_TEMPLATE_RESULT (arg)))) && TYPE_P (DECL_TEMPLATE_RESULT (arg))))
pp_cxx_type_id (pp, arg); pp->type_id (arg);
else else
pp_expression (pp, arg); pp->expression (arg);
} }
} }
} }
...@@ -1794,9 +1791,9 @@ pp_cxx_exception_declaration (cxx_pretty_printer *pp, tree t) ...@@ -1794,9 +1791,9 @@ pp_cxx_exception_declaration (cxx_pretty_printer *pp, tree t)
t = DECL_EXPR_DECL (t); t = DECL_EXPR_DECL (t);
pp_cxx_type_specifier_seq (pp, t); pp_cxx_type_specifier_seq (pp, t);
if (TYPE_P (t)) if (TYPE_P (t))
pp_abstract_declarator (pp, t); pp->abstract_declarator (t);
else else
pp_declarator (pp, t); pp->declarator (t);
} }
/* Statements. */ /* Statements. */
...@@ -1871,7 +1868,7 @@ cxx_pretty_printer::statement (tree t) ...@@ -1871,7 +1868,7 @@ cxx_pretty_printer::statement (tree t)
pp_cxx_ws_string (this, "if"); pp_cxx_ws_string (this, "if");
pp_cxx_whitespace (this); pp_cxx_whitespace (this);
pp_cxx_left_paren (this); pp_cxx_left_paren (this);
pp_expression (this, IF_COND (t)); expression (IF_COND (t));
pp_cxx_right_paren (this); pp_cxx_right_paren (this);
pp_newline_and_indent (this, 2); pp_newline_and_indent (this, 2);
statement (THEN_CLAUSE (t)); statement (THEN_CLAUSE (t));
...@@ -1894,7 +1891,7 @@ cxx_pretty_printer::statement (tree t) ...@@ -1894,7 +1891,7 @@ cxx_pretty_printer::statement (tree t)
pp_cxx_ws_string (this, "switch"); pp_cxx_ws_string (this, "switch");
pp_space (this); pp_space (this);
pp_cxx_left_paren (this); pp_cxx_left_paren (this);
pp_expression (this, SWITCH_STMT_COND (t)); expression (SWITCH_STMT_COND (t));
pp_cxx_right_paren (this); pp_cxx_right_paren (this);
pp_indentation (this) += 3; pp_indentation (this) += 3;
pp_needs_newline (this) = true; pp_needs_newline (this) = true;
...@@ -1911,7 +1908,7 @@ cxx_pretty_printer::statement (tree t) ...@@ -1911,7 +1908,7 @@ cxx_pretty_printer::statement (tree t)
pp_cxx_ws_string (this, "while"); pp_cxx_ws_string (this, "while");
pp_space (this); pp_space (this);
pp_cxx_left_paren (this); pp_cxx_left_paren (this);
pp_expression (this, WHILE_COND (t)); expression (WHILE_COND (t));
pp_cxx_right_paren (this); pp_cxx_right_paren (this);
pp_newline_and_indent (this, 3); pp_newline_and_indent (this, 3);
statement (WHILE_BODY (t)); statement (WHILE_BODY (t));
...@@ -1927,7 +1924,7 @@ cxx_pretty_printer::statement (tree t) ...@@ -1927,7 +1924,7 @@ cxx_pretty_printer::statement (tree t)
pp_cxx_ws_string (this, "while"); pp_cxx_ws_string (this, "while");
pp_space (this); pp_space (this);
pp_cxx_left_paren (this); pp_cxx_left_paren (this);
pp_expression (this, DO_COND (t)); expression (DO_COND (t));
pp_cxx_right_paren (this); pp_cxx_right_paren (this);
pp_cxx_semicolon (this); pp_cxx_semicolon (this);
pp_needs_newline (this) = true; pp_needs_newline (this) = true;
...@@ -1944,12 +1941,12 @@ cxx_pretty_printer::statement (tree t) ...@@ -1944,12 +1941,12 @@ cxx_pretty_printer::statement (tree t)
pp_needs_newline (this) = false; pp_needs_newline (this) = false;
pp_cxx_whitespace (this); pp_cxx_whitespace (this);
if (FOR_COND (t)) if (FOR_COND (t))
pp_expression (this, FOR_COND (t)); expression (FOR_COND (t));
pp_cxx_semicolon (this); pp_cxx_semicolon (this);
pp_needs_newline (this) = false; pp_needs_newline (this) = false;
pp_cxx_whitespace (this); pp_cxx_whitespace (this);
if (FOR_EXPR (t)) if (FOR_EXPR (t))
pp_expression (this, FOR_EXPR (t)); expression (FOR_EXPR (t));
pp_cxx_right_paren (this); pp_cxx_right_paren (this);
pp_newline_and_indent (this, 3); pp_newline_and_indent (this, 3);
statement (FOR_BODY (t)); statement (FOR_BODY (t));
...@@ -1988,7 +1985,7 @@ cxx_pretty_printer::statement (tree t) ...@@ -1988,7 +1985,7 @@ cxx_pretty_printer::statement (tree t)
/* expression-statement: /* expression-statement:
expression(opt) ; */ expression(opt) ; */
case EXPR_STMT: case EXPR_STMT:
pp_expression (this, EXPR_STMT_EXPR (t)); expression (EXPR_STMT_EXPR (t));
pp_cxx_semicolon (this); pp_cxx_semicolon (this);
pp_needs_newline (this) = true; pp_needs_newline (this) = true;
break; break;
...@@ -2271,9 +2268,9 @@ pp_cxx_typeid_expression (cxx_pretty_printer *pp, tree t) ...@@ -2271,9 +2268,9 @@ pp_cxx_typeid_expression (cxx_pretty_printer *pp, tree t)
pp_cxx_ws_string (pp, "typeid"); pp_cxx_ws_string (pp, "typeid");
pp_cxx_left_paren (pp); pp_cxx_left_paren (pp);
if (TYPE_P (t)) if (TYPE_P (t))
pp_cxx_type_id (pp, t); pp->type_id (t);
else else
pp_expression (pp, t); pp->expression (t);
pp_cxx_right_paren (pp); pp_cxx_right_paren (pp);
} }
...@@ -2282,9 +2279,9 @@ pp_cxx_va_arg_expression (cxx_pretty_printer *pp, tree t) ...@@ -2282,9 +2279,9 @@ pp_cxx_va_arg_expression (cxx_pretty_printer *pp, tree t)
{ {
pp_cxx_ws_string (pp, "va_arg"); pp_cxx_ws_string (pp, "va_arg");
pp_cxx_left_paren (pp); pp_cxx_left_paren (pp);
pp_assignment_expression (pp, TREE_OPERAND (t, 0)); pp->assignment_expression (TREE_OPERAND (t, 0));
pp_cxx_separate_with (pp, ','); pp_cxx_separate_with (pp, ',');
pp_cxx_type_id (pp, TREE_TYPE (t)); pp->type_id (TREE_TYPE (t));
pp_cxx_right_paren (pp); pp_cxx_right_paren (pp);
} }
...@@ -2297,7 +2294,7 @@ pp_cxx_offsetof_expression_1 (cxx_pretty_printer *pp, tree t) ...@@ -2297,7 +2294,7 @@ pp_cxx_offsetof_expression_1 (cxx_pretty_printer *pp, tree t)
if (TREE_CODE (TREE_OPERAND (t, 0)) == STATIC_CAST_EXPR if (TREE_CODE (TREE_OPERAND (t, 0)) == STATIC_CAST_EXPR
&& POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 0)))) && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 0))))
{ {
pp_cxx_type_id (pp, TREE_TYPE (TREE_TYPE (TREE_OPERAND (t, 0)))); pp->type_id (TREE_TYPE (TREE_TYPE (TREE_OPERAND (t, 0))));
pp_cxx_separate_with (pp, ','); pp_cxx_separate_with (pp, ',');
return true; return true;
} }
...@@ -2307,13 +2304,13 @@ pp_cxx_offsetof_expression_1 (cxx_pretty_printer *pp, tree t) ...@@ -2307,13 +2304,13 @@ pp_cxx_offsetof_expression_1 (cxx_pretty_printer *pp, tree t)
return false; return false;
if (TREE_CODE (TREE_OPERAND (t, 0)) != ARROW_EXPR) if (TREE_CODE (TREE_OPERAND (t, 0)) != ARROW_EXPR)
pp_cxx_dot (pp); pp_cxx_dot (pp);
pp_expression (pp, TREE_OPERAND (t, 1)); pp->expression (TREE_OPERAND (t, 1));
return true; return true;
case ARRAY_REF: case ARRAY_REF:
if (!pp_cxx_offsetof_expression_1 (pp, TREE_OPERAND (t, 0))) if (!pp_cxx_offsetof_expression_1 (pp, TREE_OPERAND (t, 0)))
return false; return false;
pp_left_bracket (pp); pp_left_bracket (pp);
pp_expression (pp, TREE_OPERAND (t, 1)); pp->expression (TREE_OPERAND (t, 1));
pp_right_bracket (pp); pp_right_bracket (pp);
return true; return true;
default: default:
...@@ -2327,7 +2324,7 @@ pp_cxx_offsetof_expression (cxx_pretty_printer *pp, tree t) ...@@ -2327,7 +2324,7 @@ pp_cxx_offsetof_expression (cxx_pretty_printer *pp, tree t)
pp_cxx_ws_string (pp, "offsetof"); pp_cxx_ws_string (pp, "offsetof");
pp_cxx_left_paren (pp); pp_cxx_left_paren (pp);
if (!pp_cxx_offsetof_expression_1 (pp, TREE_OPERAND (t, 0))) if (!pp_cxx_offsetof_expression_1 (pp, TREE_OPERAND (t, 0)))
pp_expression (pp, TREE_OPERAND (t, 0)); pp->expression (TREE_OPERAND (t, 0));
pp_cxx_right_paren (pp); pp_cxx_right_paren (pp);
} }
...@@ -2407,12 +2404,12 @@ pp_cxx_trait_expression (cxx_pretty_printer *pp, tree t) ...@@ -2407,12 +2404,12 @@ pp_cxx_trait_expression (cxx_pretty_printer *pp, tree t)
} }
pp_cxx_left_paren (pp); pp_cxx_left_paren (pp);
pp_cxx_type_id (pp, TRAIT_EXPR_TYPE1 (t)); pp->type_id (TRAIT_EXPR_TYPE1 (t));
if (kind == CPTK_IS_BASE_OF || kind == CPTK_IS_CONVERTIBLE_TO) if (kind == CPTK_IS_BASE_OF || kind == CPTK_IS_CONVERTIBLE_TO)
{ {
pp_cxx_separate_with (pp, ','); pp_cxx_separate_with (pp, ',');
pp_cxx_type_id (pp, TRAIT_EXPR_TYPE2 (t)); pp->type_id (TRAIT_EXPR_TYPE2 (t));
} }
pp_cxx_right_paren (pp); pp_cxx_right_paren (pp);
...@@ -2430,6 +2427,5 @@ cxx_pretty_printer::cxx_pretty_printer () ...@@ -2430,6 +2427,5 @@ cxx_pretty_printer::cxx_pretty_printer ()
type_specifier_seq = (pp_fun) pp_cxx_type_specifier_seq; type_specifier_seq = (pp_fun) pp_cxx_type_specifier_seq;
parameter_list = (pp_fun) pp_cxx_parameter_declaration_clause; parameter_list = (pp_fun) pp_cxx_parameter_declaration_clause;
type_id = (pp_fun) pp_cxx_type_id;
simple_type_specifier = (pp_fun) pp_cxx_simple_type_specifier; simple_type_specifier = (pp_fun) pp_cxx_simple_type_specifier;
} }
...@@ -42,6 +42,7 @@ struct cxx_pretty_printer : c_pretty_printer ...@@ -42,6 +42,7 @@ struct cxx_pretty_printer : c_pretty_printer
void conditional_expression (tree); void conditional_expression (tree);
void assignment_expression (tree); void assignment_expression (tree);
void expression (tree); void expression (tree);
void type_id (tree);
void statement (tree); void statement (tree);
void declaration (tree); void declaration (tree);
void declaration_specifiers (tree); void declaration_specifiers (tree);
......
...@@ -1212,7 +1212,7 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) ...@@ -1212,7 +1212,7 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags)
if (flags & TFF_DECL_SPECIFIERS) if (flags & TFF_DECL_SPECIFIERS)
pp->declaration (t); pp->declaration (t);
else else
pp_type_id (pp, t); pp->type_id (t);
break; break;
case UNBOUND_CLASS_TEMPLATE: case UNBOUND_CLASS_TEMPLATE:
...@@ -1908,7 +1908,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) ...@@ -1908,7 +1908,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
case REAL_CST: case REAL_CST:
case STRING_CST: case STRING_CST:
case COMPLEX_CST: case COMPLEX_CST:
pp_constant (pp, t); pp->constant (t);
break; break;
case USERDEF_LITERAL: case USERDEF_LITERAL:
...@@ -2538,7 +2538,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) ...@@ -2538,7 +2538,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
case TYPENAME_TYPE: case TYPENAME_TYPE:
/* We get here when we want to print a dependent type as an /* We get here when we want to print a dependent type as an
id-expression, without any disambiguator decoration. */ id-expression, without any disambiguator decoration. */
pp_id_expression (pp, t); pp->id_expression (t);
break; break;
case TEMPLATE_TYPE_PARM: case TEMPLATE_TYPE_PARM:
...@@ -2588,7 +2588,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) ...@@ -2588,7 +2588,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
case BIT_FIELD_REF: case BIT_FIELD_REF:
case FIX_TRUNC_EXPR: case FIX_TRUNC_EXPR:
case FLOAT_EXPR: case FLOAT_EXPR:
pp_expression (pp, t); pp->expression (t);
break; break;
case TRUTH_AND_EXPR: case TRUTH_AND_EXPR:
...@@ -2596,7 +2596,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) ...@@ -2596,7 +2596,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
case TRUTH_XOR_EXPR: case TRUTH_XOR_EXPR:
if (flags & TFF_EXPR_IN_PARENS) if (flags & TFF_EXPR_IN_PARENS)
pp_cxx_left_paren (pp); pp_cxx_left_paren (pp);
pp_expression (pp, t); pp->expression (t);
if (flags & TFF_EXPR_IN_PARENS) if (flags & TFF_EXPR_IN_PARENS)
pp_cxx_right_paren (pp); pp_cxx_right_paren (pp);
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment