Patchwork Clean up pretty printers [18/n]

login
register
mail settings
Submitter Gabriel Dos Reis
Date Aug. 26, 2013, 8:42 a.m.
Message ID <87y57o3kt5.fsf@euclid.axiomatics.org>
Download mbox | patch
Permalink /patch/269826/
State New
Headers show

Comments

Gabriel Dos Reis - Aug. 26, 2013, 8:42 a.m.
Same topic as patch 17/n.  For more expressing printers.
Tested on an x86_64-suse-linux.  Applied to mainline.

-- Gaby

2013-08-26  Gabriel Dos Reis  <gdre@integrable-solutions.net>

c-family/
	* c-pretty-print.h (c_pretty_printer::unary_expression): Now a
	virtual member function.
	(c_pretty_printer::multiplicative_expression): Likewise.
	(c_pretty_printer::conditional_expression): Likewise.
	(c_pretty_printer::assignment_expression): Likewise.
	(c_pretty_printer::expression): Likewise.
	(pp_unary_expression): Adjust.
	(pp_multiplicative_expression): Likewise.
	(pp_assignment_expression): Likewise.
	(pp_conditional_expression): Likewise.
	(pp_expression): Likewise.
	* c-pretty-print.c (c_pretty_printer::unary_expression): Rename
	from pp_c_unary_expression.  Adjust.
	(c_pretty_printer::multiplicative_expression): Rename from
	pp_c_multiplicative_expression.  Adjust.
	(c_pretty_printer::conditional_expression): Rename from
	pp_c_conditional_expression.  Adjust.
	(c_pretty_printer::assignment_expression): Rename from
	pp_c_assignment_expression.  Adjust.
	(c_pretty_printer::expression): Rename from pp_c_expression.  Adjust.
	(c_pretty_printer::c_pretty_printer): Do not assign to
	unary_expression, multiplicative_expression,
	conditional_expression, expression.

cp/
	* cxx-pretty-print.h (cxx_pretty_printer::unary_expression):
	Declare as overrider.
	(cxx_pretty_printer::multiplicative_expression): Likewise.
	(cxx_pretty_printer::conditional_expression): Likewise.
	(cxx_pretty_printer::assignment_expression): Likewise.
	(cxx_pretty_printer::expression): Likewise.
	* cxx-pretty-print.c (cxx_pretty_printer::unary_expression):
	Rename from pp_cxx_unary_expression.  Adjust.
	(cxx_pretty_printer::multiplicative_expression): Rename from
	pp_cxx_multiplicative_expression.  Adjust.
	(cxx_pretty_printer::conditional_expression): Rename from
	pp_cxx_conditional_expression.  Adjust.
	(cxx_pretty_printer::assignment_expression): Rename from
	pp_cxx_assignment_expression.  Adjust.
	(cxx_pretty_printer::expression): Rename from pp_cxx_expression.
	Adjust.
	(cxx_pretty_printer::cxx_pretty_printer): Dot not assign to
	unary_expression, multiplicative_expression,
	conditional_expression, assignment_expression, expression.
Gabriel Dos Reis - Aug. 26, 2013, 9:18 a.m.
Paolo Carlini <paolo.carlini@oracle.com> writes:

| Hi Gaby.
| 
| On 08/26/2013 10:42 AM, Gabriel Dos Reis wrote:
| > Same topic as patch 17/n.  For more expressing printers.
| > Tested on an x86_64-suse-linux.  Applied to mainline.
| Just got this:
| 
| /scratch/Gcc/svn-dirs/trunk/gcc/c/c-objc-common.c: In function ‘bool
| c_tree_printer(pretty_printer*, text_info*, const char*, int, bool,
| bool, bool)’:
| /scratch/Gcc/svn-dirs/trunk/gcc/c/c-objc-common.c:123:31: error:
| ‘pp_c_expression’ was not declared in this scope
| make[2]: *** [c/c-objc-common.o] Error 1
| 
| Yesterday things were fine.

What happened was I inadvertently committed only a fraction of the patch.
Now, all changes should be in.  Sorry for the breakage.  I guess it is
time to go to bed.

-- Gaby

Patch

Index: c-family/c-pretty-print.c
===================================================================
--- c-family/c-pretty-print.c	(revision 201985)
+++ c-family/c-pretty-print.c	(working copy)
@@ -50,7 +50,6 @@ 
 static void pp_c_initializer_list (c_pretty_printer *, tree);
 static void pp_c_brace_enclosed_initializer_list (c_pretty_printer *, tree);
 
-static void pp_c_multiplicative_expression (c_pretty_printer *, tree);
 static void pp_c_additive_expression (c_pretty_printer *, tree);
 static void pp_c_shift_expression (c_pretty_printer *, tree);
 static void pp_c_relational_expression (c_pretty_printer *, tree);
@@ -59,8 +58,6 @@ 
 static void pp_c_exclusive_or_expression (c_pretty_printer *, tree);
 static void pp_c_inclusive_or_expression (c_pretty_printer *, tree);
 static void pp_c_logical_and_expression (c_pretty_printer *, tree);
-static void pp_c_conditional_expression (c_pretty_printer *, tree);
-static void pp_c_assignment_expression (c_pretty_printer *, tree);
 
 /* declarations.  */
 
@@ -1255,7 +1252,7 @@ 
       if (TREE_OPERAND (e, 2))
 	{
 	  pp_separate_with (this, ',');
-	  pp_c_expression (this, TREE_OPERAND (e, 2));
+	  expression (TREE_OPERAND (e, 2));
 	}
       pp_c_right_paren (this);
       break;
@@ -1619,7 +1616,7 @@ 
       break;
 
     case MEM_REF:
-      pp_c_expression (this, e);
+      expression (e);
       break;
 
     case COMPLEX_CST:
@@ -1641,7 +1638,7 @@ 
     case VA_ARG_EXPR:
       pp_c_ws_string (this, "__builtin_va_arg");
       pp_c_left_paren (this);
-      pp_assignment_expression (this, TREE_OPERAND (e, 0));
+      assignment_expression (TREE_OPERAND (e, 0));
       pp_separate_with (this, ',');
       pp_type_id (this, TREE_TYPE (e));
       pp_c_right_paren (this);
@@ -1721,15 +1718,15 @@ 
       __imag__ unary-expression  */
 
 void
-pp_c_unary_expression (c_pretty_printer *pp, tree e)
+c_pretty_printer::unary_expression (tree e)
 {
   enum tree_code code = TREE_CODE (e);
   switch (code)
     {
     case PREINCREMENT_EXPR:
     case PREDECREMENT_EXPR:
-      pp_string (pp, code == PREINCREMENT_EXPR ? "++" : "--");
-      pp_c_unary_expression (pp, TREE_OPERAND (e, 0));
+      pp_string (this, code == PREINCREMENT_EXPR ? "++" : "--");
+      unary_expression (TREE_OPERAND (e, 0));
       break;
 
     case ADDR_EXPR:
@@ -1740,53 +1737,53 @@ 
     case CONJ_EXPR:
       /* String literal are used by address.  */
       if (code == ADDR_EXPR && TREE_CODE (TREE_OPERAND (e, 0)) != STRING_CST)
-	pp_ampersand (pp);
+	pp_ampersand (this);
       else if (code == INDIRECT_REF)
-	pp_c_star (pp);
+	pp_c_star (this);
       else if (code == NEGATE_EXPR)
-	pp_minus (pp);
+	pp_minus (this);
       else if (code == BIT_NOT_EXPR || code == CONJ_EXPR)
-	pp_complement (pp);
+	pp_complement (this);
       else if (code == TRUTH_NOT_EXPR)
-	pp_exclamation (pp);
-      pp_c_cast_expression (pp, TREE_OPERAND (e, 0));
+	pp_exclamation (this);
+      pp_c_cast_expression (this, TREE_OPERAND (e, 0));
       break;
 
     case MEM_REF:
       if (TREE_CODE (TREE_OPERAND (e, 0)) == ADDR_EXPR
 	  && integer_zerop (TREE_OPERAND (e, 1)))
-	pp_c_expression (pp, TREE_OPERAND (TREE_OPERAND (e, 0), 0));
+	expression (TREE_OPERAND (TREE_OPERAND (e, 0), 0));
       else
 	{
-	  pp_c_star (pp);
+	  pp_c_star (this);
 	  if (!integer_zerop (TREE_OPERAND (e, 1)))
 	    {
-	      pp_c_left_paren (pp);
+	      pp_c_left_paren (this);
 	      if (!integer_onep (TYPE_SIZE_UNIT
 				 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (e, 0))))))
-		pp_c_type_cast (pp, ptr_type_node);
+		pp_c_type_cast (this, ptr_type_node);
 	    }
-	  pp_c_cast_expression (pp, TREE_OPERAND (e, 0));
+	  pp_c_cast_expression (this, TREE_OPERAND (e, 0));
 	  if (!integer_zerop (TREE_OPERAND (e, 1)))
 	    {
-	      pp_plus (pp);
-	      pp_c_integer_constant (pp,
+	      pp_plus (this);
+	      pp_c_integer_constant (this,
 				     fold_convert (ssizetype,
 						   TREE_OPERAND (e, 1)));
-	      pp_c_right_paren (pp);
+	      pp_c_right_paren (this);
 	    }
 	}
       break;
 
     case REALPART_EXPR:
     case IMAGPART_EXPR:
-      pp_c_ws_string (pp, code == REALPART_EXPR ? "__real__" : "__imag__");
-      pp_c_whitespace (pp);
-      pp_unary_expression (pp, TREE_OPERAND (e, 0));
+      pp_c_ws_string (this, code == REALPART_EXPR ? "__real__" : "__imag__");
+      pp_c_whitespace (this);
+      unary_expression (TREE_OPERAND (e, 0));
       break;
 
     default:
-      pp_postfix_expression (pp, e);
+      postfix_expression (e);
       break;
     }
 }
@@ -1819,8 +1816,8 @@ 
       multiplicative-expression / cast-expression
       multiplicative-expression % cast-expression   */
 
-static void
-pp_c_multiplicative_expression (c_pretty_printer *pp, tree e)
+void
+c_pretty_printer::multiplicative_expression (tree e)
 {
   enum tree_code code = TREE_CODE (e);
   switch (code)
@@ -1828,20 +1825,20 @@ 
     case MULT_EXPR:
     case TRUNC_DIV_EXPR:
     case TRUNC_MOD_EXPR:
-      pp_multiplicative_expression (pp, TREE_OPERAND (e, 0));
-      pp_c_whitespace (pp);
+      multiplicative_expression (TREE_OPERAND (e, 0));
+      pp_c_whitespace (this);
       if (code == MULT_EXPR)
-	pp_c_star (pp);
+	pp_c_star (this);
       else if (code == TRUNC_DIV_EXPR)
-	pp_slash (pp);
+	pp_slash (this);
       else
-	pp_modulo (pp);
-      pp_c_whitespace (pp);
-      pp_c_cast_expression (pp, TREE_OPERAND (e, 1));
+	pp_modulo (this);
+      pp_c_whitespace (this);
+      pp_c_cast_expression (this, TREE_OPERAND (e, 1));
       break;
 
     default:
-      pp_c_cast_expression (pp, e);
+      pp_c_cast_expression (this, e);
       break;
     }
 }
@@ -2069,23 +2066,23 @@ 
       logical-OR-expression
       logical-OR-expression ? expression : conditional-expression  */
 
-static void
-pp_c_conditional_expression (c_pretty_printer *pp, tree e)
+void
+c_pretty_printer::conditional_expression (tree e)
 {
   if (TREE_CODE (e) == COND_EXPR)
     {
-      pp_c_logical_or_expression (pp, TREE_OPERAND (e, 0));
-      pp_c_whitespace (pp);
-      pp_question (pp);
-      pp_c_whitespace (pp);
-      pp_expression (pp, TREE_OPERAND (e, 1));
-      pp_c_whitespace (pp);
-      pp_colon (pp);
-      pp_c_whitespace (pp);
-      pp_c_conditional_expression (pp, TREE_OPERAND (e, 2));
+      pp_c_logical_or_expression (this, TREE_OPERAND (e, 0));
+      pp_c_whitespace (this);
+      pp_question (this);
+      pp_c_whitespace (this);
+      pp_expression (this, TREE_OPERAND (e, 1));
+      pp_c_whitespace (this);
+      pp_colon (this);
+      pp_c_whitespace (this);
+      conditional_expression (TREE_OPERAND (e, 2));
     }
   else
-    pp_c_logical_or_expression (pp, e);
+    pp_c_logical_or_expression (this, e);
 }
 
 
@@ -2096,20 +2093,20 @@ 
    assignment-expression: one of
       =    *=    /=    %=    +=    -=    >>=    <<=    &=    ^=    |=  */
 
-static void
-pp_c_assignment_expression (c_pretty_printer *pp, tree e)
+void
+c_pretty_printer::assignment_expression (tree e)
 {
   if (TREE_CODE (e) == MODIFY_EXPR
       || TREE_CODE (e) == INIT_EXPR)
     {
-      pp_c_unary_expression (pp, TREE_OPERAND (e, 0));
-      pp_c_whitespace (pp);
-      pp_equal (pp);
-      pp_space (pp);
-      pp_c_expression (pp, TREE_OPERAND (e, 1));
+      unary_expression (TREE_OPERAND (e, 0));
+      pp_c_whitespace (this);
+      pp_equal (this);
+      pp_space (this);
+      pp_expression (this, TREE_OPERAND (e, 1));
     }
   else
-    pp_c_conditional_expression (pp, e);
+    conditional_expression (e);
 }
 
 /* expression:
@@ -2120,27 +2117,27 @@ 
   chain, I take the liberty of dispatching nodes to the appropriate
   functions.  This makes some redundancy, but it worths it. That also
   prevents a possible infinite recursion between pp_primary_expression ()
-  and pp_c_expression ().  */
+  and pp_expression ().  */
 
 void
-pp_c_expression (c_pretty_printer *pp, tree e)
+c_pretty_printer::expression (tree e)
 {
   switch (TREE_CODE (e))
     {
     case INTEGER_CST:
-      pp_c_integer_constant (pp, e);
+      pp_c_integer_constant (this, e);
       break;
 
     case REAL_CST:
-      pp_c_floating_constant (pp, e);
+      pp_c_floating_constant (this, e);
       break;
 
     case FIXED_CST:
-      pp_c_fixed_constant (pp, e);
+      pp_c_fixed_constant (this, e);
       break;
 
     case STRING_CST:
-      pp_c_string_literal (pp, e);
+      pp_c_string_literal (this, e);
       break;
 
     case IDENTIFIER_NODE:
@@ -2152,15 +2149,15 @@ 
     case FIELD_DECL:
     case LABEL_DECL:
     case ERROR_MARK:
-      pp_primary_expression (pp, e);
+      primary_expression (e);
       break;
 
     case SSA_NAME:
       if (SSA_NAME_VAR (e)
 	  && !DECL_ARTIFICIAL (SSA_NAME_VAR (e)))
-	pp_c_expression (pp, SSA_NAME_VAR (e));
+	expression (SSA_NAME_VAR (e));
       else
-	pp->translate_string ("<unknown>");
+	translate_string ("<unknown>");
       break;
 
     case POSTINCREMENT_EXPR:
@@ -2185,7 +2182,7 @@ 
     case CONSTRUCTOR:
     case COMPOUND_LITERAL_EXPR:
     case VA_ARG_EXPR:
-      pp_postfix_expression (pp, e);
+      postfix_expression (e);
       break;
 
     case CONJ_EXPR:
@@ -2199,107 +2196,107 @@ 
     case PREDECREMENT_EXPR:
     case REALPART_EXPR:
     case IMAGPART_EXPR:
-      pp_c_unary_expression (pp, e);
+      unary_expression (e);
       break;
 
     case FLOAT_EXPR:
     case FIX_TRUNC_EXPR:
     CASE_CONVERT:
     case VIEW_CONVERT_EXPR:
-      pp_c_cast_expression (pp, e);
+      pp_c_cast_expression (this, e);
       break;
 
     case MULT_EXPR:
     case TRUNC_MOD_EXPR:
     case TRUNC_DIV_EXPR:
-      pp_multiplicative_expression (pp, e);
+      multiplicative_expression (e);
       break;
 
     case LSHIFT_EXPR:
     case RSHIFT_EXPR:
-      pp_c_shift_expression (pp, e);
+      pp_c_shift_expression (this, e);
       break;
 
     case LT_EXPR:
     case GT_EXPR:
     case LE_EXPR:
     case GE_EXPR:
-      pp_c_relational_expression (pp, e);
+      pp_c_relational_expression (this, e);
       break;
 
     case BIT_AND_EXPR:
-      pp_c_and_expression (pp, e);
+      pp_c_and_expression (this, e);
       break;
 
     case BIT_XOR_EXPR:
     case TRUTH_XOR_EXPR:
-      pp_c_exclusive_or_expression (pp, e);
+      pp_c_exclusive_or_expression (this, e);
       break;
 
     case BIT_IOR_EXPR:
-      pp_c_inclusive_or_expression (pp, e);
+      pp_c_inclusive_or_expression (this, e);
       break;
 
     case TRUTH_ANDIF_EXPR:
     case TRUTH_AND_EXPR:
-      pp_c_logical_and_expression (pp, e);
+      pp_c_logical_and_expression (this, e);
       break;
 
     case TRUTH_ORIF_EXPR:
     case TRUTH_OR_EXPR:
-      pp_c_logical_or_expression (pp, e);
+      pp_c_logical_or_expression (this, e);
       break;
 
     case EQ_EXPR:
     case NE_EXPR:
-      pp_c_equality_expression (pp, e);
+      pp_c_equality_expression (this, e);
       break;
 
     case COND_EXPR:
-      pp_conditional_expression (pp, e);
+      conditional_expression (e);
       break;
 
     case POINTER_PLUS_EXPR:
     case PLUS_EXPR:
     case MINUS_EXPR:
-      pp_c_additive_expression (pp, e);
+      pp_c_additive_expression (this, e);
       break;
 
     case MODIFY_EXPR:
     case INIT_EXPR:
-      pp_assignment_expression (pp, e);
+      assignment_expression (e);
       break;
 
     case COMPOUND_EXPR:
-      pp_c_left_paren (pp);
-      pp_expression (pp, TREE_OPERAND (e, 0));
-      pp_separate_with (pp, ',');
-      pp_assignment_expression (pp, TREE_OPERAND (e, 1));
-      pp_c_right_paren (pp);
+      pp_c_left_paren (this);
+      expression (TREE_OPERAND (e, 0));
+      pp_separate_with (this, ',');
+      assignment_expression (TREE_OPERAND (e, 1));
+      pp_c_right_paren (this);
       break;
 
     case NON_LVALUE_EXPR:
     case SAVE_EXPR:
-      pp_expression (pp, TREE_OPERAND (e, 0));
+      expression (TREE_OPERAND (e, 0));
       break;
 
     case TARGET_EXPR:
-      pp_postfix_expression (pp, TREE_OPERAND (e, 1));
+      postfix_expression (TREE_OPERAND (e, 1));
       break;
 
     case BIND_EXPR:
     case GOTO_EXPR:
       /* We don't yet have a way of dumping statements in a
          human-readable format.  */
-      pp_string (pp, "({...})");
+      pp_string (this, "({...})");
       break;
 
     case C_MAYBE_CONST_EXPR:
-      pp_c_expression (pp, C_MAYBE_CONST_EXPR_EXPR (e));
+      expression (C_MAYBE_CONST_EXPR_EXPR (e));
       break;
 
     default:
-      pp_unsupported_tree (pp, e);
+      pp_unsupported_tree (this, e);
       break;
     }
 }
@@ -2344,12 +2341,7 @@ 
 
   statement                 = pp_c_statement;
 
-  unary_expression          = pp_c_unary_expression;
   initializer               = pp_c_initializer;
-  multiplicative_expression = pp_c_multiplicative_expression;
-  conditional_expression    = pp_c_conditional_expression;
-  assignment_expression     = pp_c_assignment_expression;
-  expression                = pp_c_expression;
 }
 
 
Index: c-family/c-pretty-print.h
===================================================================
--- c-family/c-pretty-print.h	(revision 201985)
+++ c-family/c-pretty-print.h	(working copy)
@@ -58,6 +58,11 @@ 
   virtual void id_expression (tree);
   virtual void primary_expression (tree);
   virtual void postfix_expression (tree);
+  virtual void unary_expression (tree);
+  virtual void multiplicative_expression (tree);
+  virtual void conditional_expression (tree);
+  virtual void assignment_expression (tree);
+  virtual void expression (tree);
   /* Points to the first element of an array of offset-list.
      Not used yet.  */
   int *offset_list;
@@ -83,11 +88,6 @@ 
 
   c_pretty_print_fn statement;
 
-  c_pretty_print_fn unary_expression;
-  c_pretty_print_fn multiplicative_expression;
-  c_pretty_print_fn conditional_expression;
-  c_pretty_print_fn assignment_expression;
-  c_pretty_print_fn expression;
 };
 
 #define pp_c_tree_identifier(PPI, ID)              \
@@ -116,13 +116,13 @@ 
 #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 (PP, 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 (PP, E)
-#define pp_conditional_expression(PP, E) (PP)->conditional_expression (PP, E)
-#define pp_assignment_expression(PP, E) (PP)->assignment_expression (PP, E)
-#define pp_expression(PP, E)            (PP)->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 *);
@@ -162,12 +162,10 @@ 
 /* Statements.  */
 void pp_c_statement (c_pretty_printer *, tree);
 /* Expressions.  */
-void pp_c_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_constructor_elts (c_pretty_printer *, vec<constructor_elt, va_gc> *);
 void pp_c_call_argument_list (c_pretty_printer *, tree);
-void pp_c_unary_expression (c_pretty_printer *, tree);
 void pp_c_cast_expression (c_pretty_printer *, tree);
 void pp_c_init_declarator (c_pretty_printer *, tree);
 void pp_c_ws_string (c_pretty_printer *, const char *);
Index: cp/cxx-pretty-print.c
===================================================================
--- cp/cxx-pretty-print.c	(revision 201985)
+++ cp/cxx-pretty-print.c	(working copy)
@@ -30,8 +30,6 @@ 
 static void pp_cxx_unqualified_id (cxx_pretty_printer *, tree);
 static void pp_cxx_nested_name_specifier (cxx_pretty_printer *, tree);
 static void pp_cxx_qualified_id (cxx_pretty_printer *, tree);
-static void pp_cxx_assignment_expression (cxx_pretty_printer *, tree);
-static void pp_cxx_expression (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_ptr_operator (cxx_pretty_printer *, tree);
@@ -552,7 +550,7 @@ 
 		  skipfirst = false;
 		else
 		  {
-		    pp_cxx_expression (this, arg);
+		    expression (arg);
 		    if (more_aggr_init_expr_args_p (&iter))
 		      pp_cxx_separate_with (this, ',');
 		  }
@@ -567,7 +565,7 @@ 
 		  skipfirst = false;
 		else
 		  {
-		    pp_cxx_expression (this, arg);
+		    expression (arg);
 		    if (more_call_expr_args_p (&iter))
 		      pp_cxx_separate_with (this, ',');
 		  }
@@ -610,7 +608,7 @@ 
       pp_cxx_type_id (this, TREE_TYPE (t));
       pp_cxx_end_template_argument_list (this);
       pp_left_paren (this);
-      pp_cxx_expression (this, TREE_OPERAND (t, 0));
+      expression (TREE_OPERAND (t, 0));
       pp_right_paren (this);
       break;
 
@@ -699,7 +697,7 @@ 
 	  else if (init == void_zero_node)
 	    ;			/* OK, empty initializer list.  */
 	  else
-	    pp_cxx_expression (pp, init);
+	    pp_expression (pp, init);
 	  pp_right_paren (pp);
 	}
       break;
@@ -758,80 +756,80 @@ 
       __alignof__ unary-expression
       __alignof__ ( type-id )  */
 
-static void
-pp_cxx_unary_expression (cxx_pretty_printer *pp, tree t)
+void
+cxx_pretty_printer::unary_expression (tree t)
 {
   enum tree_code code = TREE_CODE (t);
   switch (code)
     {
     case NEW_EXPR:
     case VEC_NEW_EXPR:
-      pp_cxx_new_expression (pp, t);
+      pp_cxx_new_expression (this, t);
       break;
 
     case DELETE_EXPR:
     case VEC_DELETE_EXPR:
-      pp_cxx_delete_expression (pp, t);
+      pp_cxx_delete_expression (this, t);
       break;
 
     case SIZEOF_EXPR:
       if (PACK_EXPANSION_P (TREE_OPERAND (t, 0)))
 	{
-	  pp_cxx_ws_string (pp, "sizeof");
-	  pp_cxx_ws_string (pp, "...");
-	  pp_cxx_whitespace (pp);
-	  pp_cxx_left_paren (pp);
+	  pp_cxx_ws_string (this, "sizeof");
+	  pp_cxx_ws_string (this, "...");
+	  pp_cxx_whitespace (this);
+	  pp_cxx_left_paren (this);
 	  if (TYPE_P (TREE_OPERAND (t, 0)))
-	    pp_cxx_type_id (pp, TREE_OPERAND (t, 0));
+	    pp_cxx_type_id (this, TREE_OPERAND (t, 0));
 	  else
-	    pp_unary_expression (pp, TREE_OPERAND (t, 0));
-	  pp_cxx_right_paren (pp);
+	    unary_expression (TREE_OPERAND (t, 0));
+	  pp_cxx_right_paren (this);
 	  break;
 	}
       /* Fall through  */
 
     case ALIGNOF_EXPR:
-      pp_cxx_ws_string (pp, code == SIZEOF_EXPR ? "sizeof" : "__alignof__");
-      pp_cxx_whitespace (pp);
+      pp_cxx_ws_string (this, code == SIZEOF_EXPR ? "sizeof" : "__alignof__");
+      pp_cxx_whitespace (this);
       if (TREE_CODE (t) == SIZEOF_EXPR && SIZEOF_EXPR_TYPE_P (t))
 	{
-	  pp_cxx_left_paren (pp);
-	  pp_cxx_type_id (pp, TREE_TYPE (TREE_OPERAND (t, 0)));
-	  pp_cxx_right_paren (pp);
+	  pp_cxx_left_paren (this);
+	  pp_cxx_type_id (this, TREE_TYPE (TREE_OPERAND (t, 0)));
+	  pp_cxx_right_paren (this);
 	}
       else if (TYPE_P (TREE_OPERAND (t, 0)))
 	{
-	  pp_cxx_left_paren (pp);
-	  pp_cxx_type_id (pp, TREE_OPERAND (t, 0));
-	  pp_cxx_right_paren (pp);
+	  pp_cxx_left_paren (this);
+	  pp_cxx_type_id (this, TREE_OPERAND (t, 0));
+	  pp_cxx_right_paren (this);
 	}
       else
-	pp_unary_expression (pp, TREE_OPERAND (t, 0));
+	unary_expression (TREE_OPERAND (t, 0));
       break;
 
     case AT_ENCODE_EXPR:
-      pp_cxx_ws_string (pp, "@encode");
-      pp_cxx_whitespace (pp);
-      pp_cxx_left_paren (pp);
-      pp_cxx_type_id (pp, TREE_OPERAND (t, 0));
-      pp_cxx_right_paren (pp);
+      pp_cxx_ws_string (this, "@encode");
+      pp_cxx_whitespace (this);
+      pp_cxx_left_paren (this);
+      pp_cxx_type_id (this, TREE_OPERAND (t, 0));
+      pp_cxx_right_paren (this);
       break;      
 
     case NOEXCEPT_EXPR:
-      pp_cxx_ws_string (pp, "noexcept");
-      pp_cxx_whitespace (pp);
-      pp_cxx_left_paren (pp);
-      pp_cxx_expression (pp, TREE_OPERAND (t, 0));
-      pp_cxx_right_paren (pp);
+      pp_cxx_ws_string (this, "noexcept");
+      pp_cxx_whitespace (this);
+      pp_cxx_left_paren (this);
+      expression (TREE_OPERAND (t, 0));
+      pp_cxx_right_paren (this);
       break;
 
     case UNARY_PLUS_EXPR:
-      pp_plus (pp);
-      pp_cxx_cast_expression (pp, TREE_OPERAND (t, 0));
+      pp_plus (this);
+      pp_cxx_cast_expression (this, TREE_OPERAND (t, 0));
       break;
 
     default:
-      pp_c_unary_expression (pp, t);
+      c_pretty_printer::unary_expression (t);
       break;
     }
 }
@@ -899,8 +897,8 @@ 
       multiplicative-expression / pm-expression
       multiplicative-expression % pm-expression  */
 
-static void
-pp_cxx_multiplicative_expression (cxx_pretty_printer *pp, tree e)
+void
+cxx_pretty_printer::multiplicative_expression (tree e)
 {
   enum tree_code code = TREE_CODE (e);
   switch (code)
@@ -908,20 +906,20 @@ 
     case MULT_EXPR:
     case TRUNC_DIV_EXPR:
     case TRUNC_MOD_EXPR:
-      pp_cxx_multiplicative_expression (pp, TREE_OPERAND (e, 0));
-      pp_space (pp);
+      multiplicative_expression (TREE_OPERAND (e, 0));
+      pp_space (this);
       if (code == MULT_EXPR)
-	pp_star (pp);
+	pp_star (this);
       else if (code == TRUNC_DIV_EXPR)
-	pp_slash (pp);
+	pp_slash (this);
       else
-	pp_modulo (pp);
-      pp_space (pp);
-      pp_cxx_pm_expression (pp, TREE_OPERAND (e, 1));
+	pp_modulo (this);
+      pp_space (this);
+      pp_cxx_pm_expression (this, TREE_OPERAND (e, 1));
       break;
 
     default:
-      pp_cxx_pm_expression (pp, e);
+      pp_cxx_pm_expression (this, e);
       break;
     }
 }
@@ -930,21 +928,21 @@ 
       logical-or-expression
       logical-or-expression ?  expression  : assignment-expression  */
 
-static void
-pp_cxx_conditional_expression (cxx_pretty_printer *pp, tree e)
+void
+cxx_pretty_printer::conditional_expression (tree e)
 {
   if (TREE_CODE (e) == COND_EXPR)
     {
-      pp_c_logical_or_expression (pp, TREE_OPERAND (e, 0));
-      pp_space (pp);
-      pp_question (pp);
-      pp_space (pp);
-      pp_cxx_expression (pp, TREE_OPERAND (e, 1));
-      pp_space (pp);
-      pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 2));
+      pp_c_logical_or_expression (this, TREE_OPERAND (e, 0));
+      pp_space (this);
+      pp_question (this);
+      pp_space (this);
+      expression (TREE_OPERAND (e, 1));
+      pp_space (this);
+      assignment_expression (TREE_OPERAND (e, 2));
     }
   else
-    pp_c_logical_or_expression (pp, e);
+    pp_c_logical_or_expression (this, e);
 }
 
 /* Pretty-print a compound assignment operator token as indicated by T.  */
@@ -996,40 +994,40 @@ 
    assignment-operator: one of
       =    *=    /=    %=    +=    -=    >>=    <<=    &=    ^=    |=  */
 
-static void
-pp_cxx_assignment_expression (cxx_pretty_printer *pp, tree e)
+void
+cxx_pretty_printer::assignment_expression (tree e)
 {
   switch (TREE_CODE (e))
     {
     case MODIFY_EXPR:
     case INIT_EXPR:
-      pp_c_logical_or_expression (pp, TREE_OPERAND (e, 0));
-      pp_space (pp);
-      pp_equal (pp);
-      pp_space (pp);
-      pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 1));
+      pp_c_logical_or_expression (this, TREE_OPERAND (e, 0));
+      pp_space (this);
+      pp_equal (this);
+      pp_space (this);
+      assignment_expression (TREE_OPERAND (e, 1));
       break;
 
     case THROW_EXPR:
-      pp_cxx_ws_string (pp, "throw");
+      pp_cxx_ws_string (this, "throw");
       if (TREE_OPERAND (e, 0))
-	pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 0));
+	assignment_expression (TREE_OPERAND (e, 0));
       break;
 
     case MODOP_EXPR:
-      pp_c_logical_or_expression (pp, TREE_OPERAND (e, 0));
-      pp_cxx_assignment_operator (pp, TREE_OPERAND (e, 1));
-      pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 2));
+      pp_c_logical_or_expression (this, TREE_OPERAND (e, 0));
+      pp_cxx_assignment_operator (this, TREE_OPERAND (e, 1));
+      assignment_expression (TREE_OPERAND (e, 2));
       break;
 
     default:
-      pp_cxx_conditional_expression (pp, e);
+      conditional_expression (e);
       break;
     }
 }
 
-static void
-pp_cxx_expression (cxx_pretty_printer *pp, tree t)
+void
+cxx_pretty_printer::expression (tree t)
 {
   switch (TREE_CODE (t))
     {
@@ -1037,15 +1035,15 @@ 
     case INTEGER_CST:
     case REAL_CST:
     case COMPLEX_CST:
-      pp_constant (pp, t);
+      constant (t);
       break;
 
     case USERDEF_LITERAL:
-      pp_cxx_userdef_literal (pp, t);
+      pp_cxx_userdef_literal (this, t);
       break;
 
     case RESULT_DECL:
-      pp_cxx_unqualified_id (pp, t);
+      pp_cxx_unqualified_id (this, t);
       break;
 
 #if 0
@@ -1053,7 +1051,7 @@ 
 #endif
     case SCOPE_REF:
     case PTRMEM_CST:
-      pp_cxx_qualified_id (pp, t);
+      pp_cxx_qualified_id (this, t);
       break;
 
     case OVERLOAD:
@@ -1069,7 +1067,7 @@ 
     case TEMPLATE_PARM_INDEX:
     case TEMPLATE_TEMPLATE_PARM:
     case STMT_EXPR:
-      pp_primary_expression (pp, t);
+      primary_expression (t);
       break;
 
     case CALL_EXPR:
@@ -1085,65 +1083,65 @@ 
     case PSEUDO_DTOR_EXPR:
     case AGGR_INIT_EXPR:
     case ARROW_EXPR:
-      pp_postfix_expression (pp, t);
+      postfix_expression (t);
       break;
 
     case NEW_EXPR:
     case VEC_NEW_EXPR:
-      pp_cxx_new_expression (pp, t);
+      pp_cxx_new_expression (this, t);
       break;
 
     case DELETE_EXPR:
     case VEC_DELETE_EXPR:
-      pp_cxx_delete_expression (pp, t);
+      pp_cxx_delete_expression (this, t);
       break;
 
     case SIZEOF_EXPR:
     case ALIGNOF_EXPR:
     case NOEXCEPT_EXPR:
-      pp_cxx_unary_expression (pp, t);
+      unary_expression (t);
       break;
 
     case CAST_EXPR:
     case IMPLICIT_CONV_EXPR:
-      pp_cxx_cast_expression (pp, t);
+      pp_cxx_cast_expression (this, t);
       break;
 
     case OFFSET_REF:
     case MEMBER_REF:
     case DOTSTAR_EXPR:
-      pp_cxx_pm_expression (pp, t);
+      pp_cxx_pm_expression (this, t);
       break;
 
     case MULT_EXPR:
     case TRUNC_DIV_EXPR:
     case TRUNC_MOD_EXPR:
-      pp_cxx_multiplicative_expression (pp, t);
+      multiplicative_expression (t);
       break;
 
     case COND_EXPR:
-      pp_cxx_conditional_expression (pp, t);
+      conditional_expression (t);
       break;
 
     case MODIFY_EXPR:
     case INIT_EXPR:
     case THROW_EXPR:
     case MODOP_EXPR:
-      pp_cxx_assignment_expression (pp, t);
+      assignment_expression (t);
       break;
 
     case NON_DEPENDENT_EXPR:
     case MUST_NOT_THROW_EXPR:
-      pp_cxx_expression (pp, TREE_OPERAND (t, 0));
+      expression (TREE_OPERAND (t, 0));
       break;
 
     case EXPR_PACK_EXPANSION:
-      pp_cxx_expression (pp, PACK_EXPANSION_PATTERN (t));
-      pp_cxx_ws_string (pp, "...");
+      expression (PACK_EXPANSION_PATTERN (t));
+      pp_cxx_ws_string (this, "...");
       break;
 
     case TEMPLATE_ID_EXPR:
-      pp_cxx_template_id (pp, t);
+      pp_cxx_template_id (this, t);
       break;
 
     case NONTYPE_ARGUMENT_PACK:
@@ -1153,24 +1151,24 @@ 
 	for (i = 0; i < len; ++i)
 	  {
 	    if (i > 0)
-	      pp_cxx_separate_with (pp, ',');
-	    pp_cxx_expression (pp, TREE_VEC_ELT (args, i));
+	      pp_cxx_separate_with (this, ',');
+	    expression (TREE_VEC_ELT (args, i));
 	  }
       }
       break;
       
     case LAMBDA_EXPR:
-      pp_cxx_ws_string (pp, "<lambda>");
+      pp_cxx_ws_string (this, "<lambda>");
       break;
 
     case PAREN_EXPR:
-      pp_cxx_left_paren (pp);
-      pp_cxx_expression (pp, TREE_OPERAND (t, 0));
-      pp_cxx_right_paren (pp);
+      pp_cxx_left_paren (this);
+      expression (TREE_OPERAND (t, 0));
+      pp_cxx_right_paren (this);
       break;
 
     default:
-      pp_c_expression (pp, t);
+      c_pretty_printer::expression (t);
       break;
     }
 }
@@ -1321,7 +1319,7 @@ 
     case DECLTYPE_TYPE:
       pp_cxx_ws_string (pp, "decltype");
       pp_cxx_left_paren (pp);
-      pp_cxx_expression (pp, DECLTYPE_TYPE_EXPR (t));
+      pp_expression (pp, DECLTYPE_TYPE_EXPR (t));
       pp_cxx_right_paren (pp);
       break;
 
@@ -1450,7 +1448,7 @@ 
 	  pp_cxx_whitespace (pp);
 	  pp_equal (pp);
 	  pp_cxx_whitespace (pp);
-	  pp_cxx_assignment_expression (pp, TREE_PURPOSE (types));
+	  pp_assignment_expression (pp, TREE_PURPOSE (types));
 	}
     }
   pp_cxx_right_paren (pp);
@@ -1479,7 +1477,7 @@ 
       if (DEFERRED_NOEXCEPT_SPEC_P (ex_spec))
 	pp_cxx_ws_string (pp, "<uninstantiated>");
       else
-	pp_cxx_expression (pp, TREE_PURPOSE (ex_spec));
+	pp_expression (pp, TREE_PURPOSE (ex_spec));
       pp_cxx_right_paren (pp);
       return;
     }
@@ -1788,7 +1786,7 @@ 
 			       && TYPE_P (DECL_TEMPLATE_RESULT (arg))))
 	    pp_cxx_type_id (pp, arg);
 	  else
-	    pp_cxx_expression (pp, arg);
+	    pp_expression (pp, arg);
 	}
     }
 }
@@ -1877,7 +1875,7 @@ 
       pp_cxx_ws_string (pp, "if");
       pp_cxx_whitespace (pp);
       pp_cxx_left_paren (pp);
-      pp_cxx_expression (pp, IF_COND (t));
+      pp_expression (pp, IF_COND (t));
       pp_cxx_right_paren (pp);
       pp_newline_and_indent (pp, 2);
       pp_cxx_statement (pp, THEN_CLAUSE (t));
@@ -1900,7 +1898,7 @@ 
       pp_cxx_ws_string (pp, "switch");
       pp_space (pp);
       pp_cxx_left_paren (pp);
-      pp_cxx_expression (pp, SWITCH_STMT_COND (t));
+      pp_expression (pp, SWITCH_STMT_COND (t));
       pp_cxx_right_paren (pp);
       pp_indentation (pp) += 3;
       pp_needs_newline (pp) = true;
@@ -1917,7 +1915,7 @@ 
       pp_cxx_ws_string (pp, "while");
       pp_space (pp);
       pp_cxx_left_paren (pp);
-      pp_cxx_expression (pp, WHILE_COND (t));
+      pp_expression (pp, WHILE_COND (t));
       pp_cxx_right_paren (pp);
       pp_newline_and_indent (pp, 3);
       pp_cxx_statement (pp, WHILE_BODY (t));
@@ -1933,7 +1931,7 @@ 
       pp_cxx_ws_string (pp, "while");
       pp_space (pp);
       pp_cxx_left_paren (pp);
-      pp_cxx_expression (pp, DO_COND (t));
+      pp_expression (pp, DO_COND (t));
       pp_cxx_right_paren (pp);
       pp_cxx_semicolon (pp);
       pp_needs_newline (pp) = true;
@@ -1950,12 +1948,12 @@ 
       pp_needs_newline (pp) = false;
       pp_cxx_whitespace (pp);
       if (FOR_COND (t))
-	pp_cxx_expression (pp, FOR_COND (t));
+	pp_expression (pp, FOR_COND (t));
       pp_cxx_semicolon (pp);
       pp_needs_newline (pp) = false;
       pp_cxx_whitespace (pp);
       if (FOR_EXPR (t))
-	pp_cxx_expression (pp, FOR_EXPR (t));
+	pp_expression (pp, FOR_EXPR (t));
       pp_cxx_right_paren (pp);
       pp_newline_and_indent (pp, 3);
       pp_cxx_statement (pp, FOR_BODY (t));
@@ -1994,7 +1992,7 @@ 
       /* expression-statement:
 	    expression(opt) ;  */
     case EXPR_STMT:
-      pp_cxx_expression (pp, EXPR_STMT_EXPR (t));
+      pp_expression (pp, EXPR_STMT_EXPR (t));
       pp_cxx_semicolon (pp);
       pp_needs_newline (pp) = true;
       break;
@@ -2218,9 +2216,9 @@ 
     {
       pp_cxx_ws_string (pp, "static_assert");
       pp_cxx_left_paren (pp);
-      pp_cxx_expression (pp, STATIC_ASSERT_CONDITION (t));
+      pp_expression (pp, STATIC_ASSERT_CONDITION (t));
       pp_cxx_separate_with (pp, ',');
-      pp_cxx_expression (pp, STATIC_ASSERT_MESSAGE (t));
+      pp_expression (pp, STATIC_ASSERT_MESSAGE (t));
       pp_cxx_right_paren (pp);
     }
   else if (!DECL_LANG_SPECIFIC (t))
@@ -2279,7 +2277,7 @@ 
   if (TYPE_P (t))
     pp_cxx_type_id (pp, t);
   else
-    pp_cxx_expression (pp, t);
+    pp_expression (pp, t);
   pp_cxx_right_paren (pp);
 }
 
@@ -2288,7 +2286,7 @@ 
 {
   pp_cxx_ws_string (pp, "va_arg");
   pp_cxx_left_paren (pp);
-  pp_cxx_assignment_expression (pp, TREE_OPERAND (t, 0));
+  pp_assignment_expression (pp, TREE_OPERAND (t, 0));
   pp_cxx_separate_with (pp, ',');
   pp_cxx_type_id (pp, TREE_TYPE (t));
   pp_cxx_right_paren (pp);
@@ -2313,13 +2311,13 @@ 
 	return false;
       if (TREE_CODE (TREE_OPERAND (t, 0)) != ARROW_EXPR)
 	pp_cxx_dot (pp);
-      pp_cxx_expression (pp, TREE_OPERAND (t, 1));
+      pp_expression (pp, TREE_OPERAND (t, 1));
       return true;
     case ARRAY_REF:
       if (!pp_cxx_offsetof_expression_1 (pp, TREE_OPERAND (t, 0)))
 	return false;
       pp_left_bracket (pp);
-      pp_cxx_expression (pp, TREE_OPERAND (t, 1));
+      pp_expression (pp, TREE_OPERAND (t, 1));
       pp_right_bracket (pp);
       return true;
     default:
@@ -2333,7 +2331,7 @@ 
   pp_cxx_ws_string (pp, "offsetof");
   pp_cxx_left_paren (pp);
   if (!pp_cxx_offsetof_expression_1 (pp, TREE_OPERAND (t, 0)))
-    pp_cxx_expression (pp, TREE_OPERAND (t, 0));
+    pp_expression (pp, TREE_OPERAND (t, 0));
   pp_cxx_right_paren (pp);
 }
 
@@ -2447,10 +2445,4 @@ 
   simple_type_specifier = (pp_fun) pp_cxx_simple_type_specifier;
 
   /* pp->statement = (pp_fun) pp_cxx_statement;  */
-
-  unary_expression = (pp_fun) pp_cxx_unary_expression;
-  multiplicative_expression = (pp_fun) pp_cxx_multiplicative_expression;
-  conditional_expression = (pp_fun) pp_cxx_conditional_expression;
-  assignment_expression = (pp_fun) pp_cxx_assignment_expression;
-  expression = (pp_fun) pp_cxx_expression;
 }
Index: cp/cxx-pretty-print.h
===================================================================
--- cp/cxx-pretty-print.h	(revision 201985)
+++ cp/cxx-pretty-print.h	(working copy)
@@ -37,6 +37,11 @@ 
   void id_expression (tree);
   void primary_expression (tree);
   void postfix_expression (tree);
+  void unary_expression (tree);
+  void multiplicative_expression (tree);
+  void conditional_expression (tree);
+  void assignment_expression (tree);
+  void expression (tree);
   /* This is the enclosing scope of the entity being pretty-printed.  */
   tree enclosing_scope;
 };