PATCH to c-pretty-print.c

Gabriel Dos Reis gdr@integrable-solutions.net
Mon Mar 15 10:35:00 GMT 2004


Hi,

  This came out while looking at the new C++ pretty-printer.
Bootstrapped and applied to mainline.

-- Gaby
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ChangeLog,v
retrieving revision 2.3167
diff -p -r2.3167 ChangeLog
*** ChangeLog	14 Mar 2004 22:29:26 -0000	2.3167
--- ChangeLog	15 Mar 2004 10:30:58 -0000
***************
*** 1,3 ****
--- 1,12 ----
+ 2004-03-15  Gabriel Dos Reis  <gdr@integrable-solutions.net>
+ 
+ 	* c-pretty-print.c (pp_c_semicolon): Fix formatting.
+ 	(pp_c_cv_qualifier): Document.
+ 	(pp_c_space_for_pointer_operator): Likewise.
+ 	(pp_c_integer_constant): Likewise.
+ 	(pp_c_identifier): Likewise.
+ 	(pp_c_init_declarator): Don't print function body.
+ 
  2004-03-14  Joseph S. Myers  <jsm@polyomino.org.uk>
  
  	* doc/contrib.texi, doc/extend.texi, doc/gcov.texi,
Index: c-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-pretty-print.c,v
retrieving revision 1.37
diff -p -r1.37 c-pretty-print.c
*** c-pretty-print.c	31 Jan 2004 17:47:43 -0000	1.37
--- c-pretty-print.c	15 Mar 2004 10:30:59 -0000
*************** pp_c_arrow (c_pretty_printer *pp)
*** 140,156 ****
  }
  
  void
! pp_c_semicolon(c_pretty_printer *pp)
  {
    pp_semicolon (pp);
    pp_base (pp)->padding = pp_none;
  }
  
  static void
  pp_c_cv_qualifier (c_pretty_printer *pp, const char *cv)
  {
    const char *p = pp_last_position_in_text (pp);
!   if (p != NULL && *p == '*')
      pp_c_whitespace (pp);
    pp_c_identifier (pp, cv);
  }
--- 140,161 ----
  }
  
  void
! pp_c_semicolon (c_pretty_printer *pp)
  {
    pp_semicolon (pp);
    pp_base (pp)->padding = pp_none;
  }
  
+ /* Print out the external representation of CV-QUALIFIER.  */
+ 
  static void
  pp_c_cv_qualifier (c_pretty_printer *pp, const char *cv)
  {
    const char *p = pp_last_position_in_text (pp);
!   /* The C programming language does not have references, but it is much
!      simpler to handle those here rather than going through the same
!      logic in the C++ pretty-printer.  */
!   if (p != NULL && (*p == '*' || *p == '&'))
      pp_c_whitespace (pp);
    pp_c_identifier (pp, cv);
  }
*************** pp_c_type_cast (c_pretty_printer *pp, tr
*** 165,170 ****
--- 170,178 ----
    pp_c_right_paren (pp);
  }
  
+ /* We're about to pretty-print a pointer type as indicated by T.
+    Output a whitespace, if needed, preparing for subsequent output.  */
+ 
  void
  pp_c_space_for_pointer_operator (c_pretty_printer *pp, tree t)
  {
*************** pp_c_string_literal (c_pretty_printer *p
*** 737,742 ****
--- 745,752 ----
    pp_doublequote (pp);
  }
  
+ /* Pretty-print an INTEGER literal.  */
+ 
  static void
  pp_c_integer_constant (c_pretty_printer *pp, tree i)
  {
*************** pp_c_constant (c_pretty_printer *pp, tre
*** 922,927 ****
--- 932,939 ----
      }
  }
  
+ /* Pretty-print an IDENTIFIER_NODE, precedeed by whitespace is necessary.  */
+ 
  void
  pp_c_identifier (c_pretty_printer *pp, const char *id)
  {
*************** void
*** 1012,1018 ****
  pp_c_init_declarator (c_pretty_printer *pp, tree t)
  {
    pp_declarator (pp, t);
!   if (DECL_INITIAL (t))
      {
        tree init = DECL_INITIAL (t);
        /* This C++ bit is handled here because it is easier to do so.
--- 1024,1032 ----
  pp_c_init_declarator (c_pretty_printer *pp, tree t)
  {
    pp_declarator (pp, t);
!   /* We don't want to output function definitions here.  There are handled
!      elsewhere (and the syntactic form is bogus anyway).  */
!   if (TREE_CODE (t) != FUNCTION_DECL && DECL_INITIAL (t))
      {
        tree init = DECL_INITIAL (t);
        /* This C++ bit is handled here because it is easier to do so.



More information about the Gcc-patches mailing list