This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[mainline] C++ PATCH: set up initial bits for pretty-printing


This is putting initial bits for better pretty-printing support in the
C++ (and C) front ends.  This will (hopefully) enable us to have an
idea of what is going on for the tree-level transformations we are
doing.  This also will be a rewrite of some components in cp/error.c

Bootstrapped and tested on an i686-pc-linux-gnu.

-- Gaby
2003-08-05  Gabriel Dos Reis  <gdr@integrable-solutions.net>

	* pretty-print.h (pp_set_line_maximum_length): Make macro.
	(pp_set_prefix): Likewise.
	(pp_destroy_prefix): Likewise.
	(pp_remaining_character_count_for_line): Likewise.
	(pp_clear_output_area): Likewise.
	(pp_formatted_text): Likewise.
	(pp_last_position_in_text): Likewise.
	(pp_emit_prefix): Likewise.
	(pp_append_text): Likewise.
	(pp_flush): Likewise.
	(pp_format_text): Likewise.
	(pp_format_verbatim): Likewise.
	(pp_tree_identifier): Tidy.
	* pretty-print.c (pp_base_format_text): Rename from pp_format_text.
	(pp_base_format_verbatim): Rename from pp_format_verbatim.
	(pp_base_flush): Rename from pp_flush.
	(pp_base_set_line_maximum_length): Rename from
	pp_set_line_maximum_length.
	(pp_base_clear_output_area): Rename from pp_clear_output_area.
	(pp_base_set_prefix): Rename from pp_set_prefix.
	(pp_base_destroy_prefix): Rename from pp_destroy_prefix.
	(pp_base_emit_prefix): Rename from pp_emit_prefix.
	(pp_base_append_text): Rename from pp_append_text.
	(pp_base_formatted_text): Rename from pp_formatted_text.
	(pp_base_last_position_in_text): Rename from pp_last_position_in_text.
	(pp_base_remaining_character_count_for_line): Rename from
	pp_remaining_character_count_for_line.
	* diagnostic.h (diagnostic_format_decoder): Tidy.
	(diagnostic_flush_buffer): Likewise.
	* c-pretty-print.h: (pp_c_string_literal): Declare.
	(pp_c_real_literal): Likewise.
	(pp_c_integer_literal): Likewise.
	* c-pretty-print.c (pp_c_char): Use pp_string in lieu of
	pp_identifier. 
 	(pp_c_character_literal): Tidy.
 	(pp_c_string_literal): Make public.
 	(pp_c_bool_literal): Likewise.
 	(pp_c_integer_literal): Likewise.
 	(pp_c_real_literal): Likewise.

cp/
	* cxx-pretty-print.h: New file.
	* cxx-pretty-print.c: Likewise.
	* error.c (scratch_pretty_printer): Change type.
	(init_error): Tidy.
	(dump_aggr_type): Likewise.
	(dump_global_iord): Likewise.
	(dump_expr): Likewise.
	(dump_char): Remove.
	* cp-lang.c (LANG_HOOKS_INITIALIZE_DIAGNOSTITCS): Define.
	(cxx_initialize_diagnostics): New function.
	* Make-lang.in (CXX_OBJS): Add cp/cxx-pretty-print.o
	(CXX_PRETTY_PRINT_H): New variable.
	(cp/cxx-pretty-print.o): New rule.
	(cp/cp-lang.o): Update dependence.
	(cp/error.o): Likewise.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1135
diff -p -r1.1135 Makefile.in
*** Makefile.in	1 Aug 2003 14:04:00 -0000	1.1135
--- Makefile.in	5 Aug 2003 19:18:02 -0000
*************** PREDICT_H = predict.h predict.def
*** 658,663 ****
--- 658,664 ----
  CPPLIB_H = cpplib.h line-map.h
  PRETTY_PRINT_H = pretty-print.h input.h $(OBSTACK_H)
  DIAGNOSTIC_H = diagnostic.h diagnostic.def $(PRETTY_PRINT_H)
+ C_PRETTY_PRINT_H = $(PRETTY_PRINT_H) $(C_COMMON_H) $(TREE_H)
  
  # sed inserts variable overrides after the following line.
  ####target overrides
*************** c-common.o : c-common.c $(CONFIG_H) $(SY
*** 1326,1332 ****
  	$(GGC_H) $(EXPR_H) $(TM_P_H) builtin-types.def builtin-attrs.def \
  	$(DIAGNOSTIC_H) gt-c-common.h langhooks.h varray.h $(RTL_H) \
  	$(TARGET_H) $(C_TREE_H)
! c-pretty-print.o : c-pretty-print.c c-pretty-print.h pretty-print.h \
  	$(C_COMMON_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) real.h
  
  c-opts.o : c-opts.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
--- 1327,1333 ----
  	$(GGC_H) $(EXPR_H) $(TM_P_H) builtin-types.def builtin-attrs.def \
  	$(DIAGNOSTIC_H) gt-c-common.h langhooks.h varray.h $(RTL_H) \
  	$(TARGET_H) $(C_TREE_H)
! c-pretty-print.o : c-pretty-print.c $(C_PRETTY_PRINT_H) \
  	$(C_COMMON_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) real.h
  
  c-opts.o : c-opts.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
Index: c-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-pretty-print.c,v
retrieving revision 1.20
diff -p -r1.20 c-pretty-print.c
*** c-pretty-print.c	3 Aug 2003 20:02:56 -0000	1.20
--- c-pretty-print.c	5 Aug 2003 19:18:03 -0000
*************** static void pp_c_char (c_pretty_printer,
*** 39,47 ****
  static void pp_c_character_literal (c_pretty_printer, tree);
  static void pp_c_bool_literal (c_pretty_printer, tree);
  static bool pp_c_enumerator (c_pretty_printer, tree);
- static void pp_c_integer_literal (c_pretty_printer, tree);
- static void pp_c_real_literal (c_pretty_printer, tree);
- static void pp_c_string_literal (c_pretty_printer, tree);
  
  static void pp_c_primary_expression (c_pretty_printer, tree);
  
--- 39,44 ----
*************** pp_c_char (c_pretty_printer ppi, int c)
*** 306,339 ****
    switch (c)
      {
      case TARGET_NEWLINE:
!       pp_identifier (ppi, "\\n");
        break;
      case TARGET_TAB:
!       pp_identifier (ppi, "\\t");
        break;
      case TARGET_VT:
!       pp_identifier (ppi, "\\v");
        break;
      case TARGET_BS:
!       pp_identifier (ppi, "\\b");
        break;
      case TARGET_CR:
!       pp_identifier (ppi, "\\r");
        break;
      case TARGET_FF:
!       pp_identifier (ppi, "\\f");
        break;
      case TARGET_BELL:
!       pp_identifier (ppi, "\\a");
        break;
      case '\\':
!       pp_identifier (ppi, "\\\\");
        break;
      case '\'':
!       pp_identifier (ppi, "\\'");
        break;
      case '\"':
!       pp_identifier (ppi, "\\\"");
        break;
      default:
        if (ISPRINT (c))
--- 303,336 ----
    switch (c)
      {
      case TARGET_NEWLINE:
!       pp_string (ppi, "\\n");
        break;
      case TARGET_TAB:
!       pp_string (ppi, "\\t");
        break;
      case TARGET_VT:
!       pp_string (ppi, "\\v");
        break;
      case TARGET_BS:
!       pp_string (ppi, "\\b");
        break;
      case TARGET_CR:
!       pp_string (ppi, "\\r");
        break;
      case TARGET_FF:
!       pp_string (ppi, "\\f");
        break;
      case TARGET_BELL:
!       pp_string (ppi, "\\a");
        break;
      case '\\':
!       pp_string (ppi, "\\\\");
        break;
      case '\'':
!       pp_string (ppi, "\\'");
        break;
      case '\"':
!       pp_string (ppi, "\\\"");
        break;
      default:
        if (ISPRINT (c))
*************** pp_c_char (c_pretty_printer ppi, int c)
*** 345,351 ****
  }
  
  /* Print out a STRING literal.  */
! static inline void
  pp_c_string_literal (c_pretty_printer ppi, tree s)
  {
    const char *p = TREE_STRING_POINTER (s);
--- 342,348 ----
  }
  
  /* Print out a STRING literal.  */
! void
  pp_c_string_literal (c_pretty_printer ppi, tree s)
  {
    const char *p = TREE_STRING_POINTER (s);
*************** pp_c_string_literal (c_pretty_printer pp
*** 361,373 ****
  static inline void
  pp_c_character_literal (c_pretty_printer ppi, tree c)
  {
    pp_quote (ppi);
!   pp_c_char (ppi, tree_low_cst (c, 0));
    pp_quote (ppi);
  }
  
  /* Print out a BOOLEAN literal.  */
! static inline void
  pp_c_bool_literal (c_pretty_printer ppi, tree b)
  {
    if (b == boolean_false_node || integer_zerop (b))
--- 358,374 ----
  static inline void
  pp_c_character_literal (c_pretty_printer ppi, tree c)
  {
+   tree type = TREE_TYPE (c);
    pp_quote (ppi);
!   if (host_integerp (c, TREE_UNSIGNED (type)))
!     pp_c_char (ppi, tree_low_cst (c, TREE_UNSIGNED (type)));
!   else
!     pp_scalar (ppi, "\\x%x", (unsigned) TREE_INT_CST_LOW (c));
    pp_quote (ppi);
  }
  
  /* Print out a BOOLEAN literal.  */
! void
  pp_c_bool_literal (c_pretty_printer ppi, tree b)
  {
    if (b == boolean_false_node || integer_zerop (b))
*************** pp_c_enumerator (c_pretty_printer ppi, t
*** 423,429 ****
  }
  
  /* Print out an INTEGER constant value.  */
! static void
  pp_c_integer_literal (c_pretty_printer ppi, tree i)
  {
    tree type = TREE_TYPE (i);
--- 424,430 ----
  }
  
  /* Print out an INTEGER constant value.  */
! void
  pp_c_integer_literal (c_pretty_printer ppi, tree i)
  {
    tree type = TREE_TYPE (i);
*************** pp_c_integer_literal (c_pretty_printer p
*** 449,468 ****
  	      sprintf (pp_buffer (ppi)->digit_buffer,
  		       HOST_WIDE_INT_PRINT_DOUBLE_HEX,
  		       TREE_INT_CST_HIGH (i), TREE_INT_CST_LOW (i));
! 	      pp_identifier (ppi, pp_buffer (ppi)->digit_buffer);
! 
  	    }
  	}
      }
  }
  
  /* Print out a REAL value.  */
! static inline void
  pp_c_real_literal (c_pretty_printer ppi, tree r)
  {
    real_to_decimal (pp_buffer (ppi)->digit_buffer, &TREE_REAL_CST (r),
  		   sizeof (pp_buffer (ppi)->digit_buffer), 0, 1);
!   pp_identifier (ppi, pp_buffer(ppi)->digit_buffer);
  }
  
  
--- 450,468 ----
  	      sprintf (pp_buffer (ppi)->digit_buffer,
  		       HOST_WIDE_INT_PRINT_DOUBLE_HEX,
  		       TREE_INT_CST_HIGH (i), TREE_INT_CST_LOW (i));
! 	      pp_string (ppi, pp_buffer (ppi)->digit_buffer);
  	    }
  	}
      }
  }
  
  /* Print out a REAL value.  */
! void
  pp_c_real_literal (c_pretty_printer ppi, tree r)
  {
    real_to_decimal (pp_buffer (ppi)->digit_buffer, &TREE_REAL_CST (r),
  		   sizeof (pp_buffer (ppi)->digit_buffer), 0, 1);
!   pp_string (ppi, pp_buffer(ppi)->digit_buffer);
  }
  
  
Index: c-pretty-print.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-pretty-print.h,v
retrieving revision 1.9
diff -p -r1.9 c-pretty-print.h
*** c-pretty-print.h	25 Jul 2003 09:52:24 -0000	1.9
--- c-pretty-print.h	5 Aug 2003 19:18:03 -0000
*************** void pp_c_cast_expression (c_pretty_prin
*** 160,164 ****
--- 160,167 ----
  void pp_c_postfix_expression (c_pretty_printer, tree);
  void pp_c_initializer (c_pretty_printer, tree);
  void pp_c_literal (c_pretty_printer, tree);
+ void pp_c_string_literal (c_pretty_printer, tree);
+ void pp_c_real_literal (c_pretty_printer, tree);
+ void pp_c_integer_literal (c_pretty_printer, tree);
  
  #endif /* GCC_C_PRETTY_PRINTER */
Index: diagnostic.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/diagnostic.h,v
retrieving revision 1.64
diff -p -r1.64 diagnostic.h
*** diagnostic.h	25 Jul 2003 09:52:24 -0000	1.64
--- diagnostic.h	5 Aug 2003 19:18:03 -0000
*************** struct diagnostic_context
*** 110,116 ****
  #define diagnostic_auxiliary_data(DC) (DC)->x_data
  
  /* Same as pp_format_decoder.  Works on 'diagnostic_context *'.  */
! #define diagnostic_format_decoder(DC) pp_format_decoder ((DC)->printer)
  
  /* Same as output_prefixing_rule.  Works on 'diagnostic_context *'.  */
  #define diagnostic_prefixing_rule(DC) ((DC)->printer->prefixing_rule)
--- 110,116 ----
  #define diagnostic_auxiliary_data(DC) (DC)->x_data
  
  /* Same as pp_format_decoder.  Works on 'diagnostic_context *'.  */
! #define diagnostic_format_decoder(DC) ((DC)->printer->format_decoder)
  
  /* Same as output_prefixing_rule.  Works on 'diagnostic_context *'.  */
  #define diagnostic_prefixing_rule(DC) ((DC)->printer->prefixing_rule)
*************** struct diagnostic_context
*** 119,125 ****
     Zero means don't wrap lines.  */
  #define diagnostic_line_cutoff(DC) ((DC)->printer->ideal_maximum_length)
  
! #define diagnostic_flush_buffer(DC) pp_flush ((DC)->printer)
  
  /* True if the last function in which a diagnostic was reported is
     different from the current one.  */
--- 119,125 ----
     Zero means don't wrap lines.  */
  #define diagnostic_line_cutoff(DC) ((DC)->printer->ideal_maximum_length)
  
! #define diagnostic_flush_buffer(DC) pp_base_flush ((DC)->printer)
  
  /* True if the last function in which a diagnostic was reported is
     different from the current one.  */
Index: pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/pretty-print.c,v
retrieving revision 2.2
diff -p -r2.2 pretty-print.c
*** pretty-print.c	3 Aug 2003 20:02:56 -0000	2.2
--- pretty-print.c	5 Aug 2003 19:18:03 -0000
*************** pp_append_r (pretty_printer *pp, const c
*** 181,187 ****
     %*.s: a substring the length of which is specified by an integer.
     %H: location_t.  */
  void
! pp_format_text (pretty_printer *pp, text_info *text)
  {
    for (; *text->format_spec; ++text->format_spec)
      {
--- 181,187 ----
     %*.s: a substring the length of which is specified by an integer.
     %H: location_t.  */
  void
! pp_base_format_text (pretty_printer *pp, text_info *text)
  {
    for (; *text->format_spec; ++text->format_spec)
      {
*************** pp_format_text (pretty_printer *pp, text
*** 320,326 ****
  /* Helper subroutine of output_verbatim and verbatim. Do the appropriate
     settings needed by BUFFER for a verbatim formatting.  */
  void
! pp_format_verbatim (pretty_printer *pp, text_info *text)
  {
    diagnostic_prefixing_rule_t rule = pp_prefixing_rule (pp);
    int line_cutoff = pp_line_cutoff (pp);
--- 320,326 ----
  /* Helper subroutine of output_verbatim and verbatim. Do the appropriate
     settings needed by BUFFER for a verbatim formatting.  */
  void
! pp_base_format_verbatim (pretty_printer *pp, text_info *text)
  {
    diagnostic_prefixing_rule_t rule = pp_prefixing_rule (pp);
    int line_cutoff = pp_line_cutoff (pp);
*************** pp_format_verbatim (pretty_printer *pp, 
*** 337,343 ****
  
  /* Flush the content of BUFFER onto the attached stream.  */
  void
! pp_flush (pretty_printer *pp)
  {
    pp_write_text_to_stream (pp);
    pp_clear_state (pp);
--- 337,343 ----
  
  /* Flush the content of BUFFER onto the attached stream.  */
  void
! pp_base_flush (pretty_printer *pp)
  {
    pp_write_text_to_stream (pp);
    pp_clear_state (pp);
*************** pp_flush (pretty_printer *pp)
*** 349,355 ****
     output in line-wrapping mode.  A LENGTH value 0 suppresses
     line-wrapping.  */
  void
! pp_set_line_maximum_length (pretty_printer *pp, int length)
  {
    pp_line_cutoff (pp) = length;
    pp_set_real_maximum_length (pp);
--- 349,355 ----
     output in line-wrapping mode.  A LENGTH value 0 suppresses
     line-wrapping.  */
  void
! pp_base_set_line_maximum_length (pretty_printer *pp, int length)
  {
    pp_line_cutoff (pp) = length;
    pp_set_real_maximum_length (pp);
*************** pp_set_line_maximum_length (pretty_print
*** 357,363 ****
  
  /* Clear PRETTY-PRINTER output area text info.  */
  void
! pp_clear_output_area (pretty_printer *pp)
  {
    obstack_free (&pp->buffer->obstack, obstack_base (&pp->buffer->obstack));
    pp->buffer->line_length = 0;
--- 357,363 ----
  
  /* Clear PRETTY-PRINTER output area text info.  */
  void
! pp_base_clear_output_area (pretty_printer *pp)
  {
    obstack_free (&pp->buffer->obstack, obstack_base (&pp->buffer->obstack));
    pp->buffer->line_length = 0;
*************** pp_clear_output_area (pretty_printer *pp
*** 365,371 ****
  
  /* Set PREFIX for PRETTY-PRINTER.  */
  void
! pp_set_prefix (pretty_printer *pp, const char *prefix)
  {
    pp->prefix = prefix;
    pp_set_real_maximum_length (pp);
--- 365,371 ----
  
  /* Set PREFIX for PRETTY-PRINTER.  */
  void
! pp_base_set_prefix (pretty_printer *pp, const char *prefix)
  {
    pp->prefix = prefix;
    pp_set_real_maximum_length (pp);
*************** pp_set_prefix (pretty_printer *pp, const
*** 375,381 ****
  
  /* Free PRETTY-PRINTER's prefix, a previously malloc()'d string.  */
  void
! pp_destroy_prefix (pretty_printer *pp)
  {
    if (pp->prefix != NULL)
      {
--- 375,381 ----
  
  /* Free PRETTY-PRINTER's prefix, a previously malloc()'d string.  */
  void
! pp_base_destroy_prefix (pretty_printer *pp)
  {
    if (pp->prefix != NULL)
      {
*************** pp_destroy_prefix (pretty_printer *pp)
*** 386,392 ****
  
  /* Write out PRETTY-PRINTER's prefix.  */
  void
! pp_emit_prefix (pretty_printer *pp)
  {
    if (pp->prefix != NULL)
      {
--- 386,392 ----
  
  /* Write out PRETTY-PRINTER's prefix.  */
  void
! pp_base_emit_prefix (pretty_printer *pp)
  {
    if (pp->prefix != NULL)
      {
*************** pp_construct (pretty_printer *pp, const 
*** 436,442 ****
     whitespace if appropriate.  The caller must ensure that it is
     safe to do so.  */
  void
! pp_append_text (pretty_printer *pp, const char *start, const char *end)
  {
    /* Emit prefix and skip whitespace if we're starting a new line.  */
    if (pp->buffer->line_length == 0)
--- 436,442 ----
     whitespace if appropriate.  The caller must ensure that it is
     safe to do so.  */
  void
! pp_base_append_text (pretty_printer *pp, const char *start, const char *end)
  {
    /* Emit prefix and skip whitespace if we're starting a new line.  */
    if (pp->buffer->line_length == 0)
*************** pp_append_text (pretty_printer *pp, cons
*** 452,458 ****
  /* Finishes constructing a NULL-terminated character string representing
     the PRETTY-PRINTED text.  */
  const char *
! pp_formatted_text (pretty_printer *pp)
  {
    obstack_1grow (&pp->buffer->obstack, '\0');
    return pp_formatted_text_data (pp);
--- 452,458 ----
  /* Finishes constructing a NULL-terminated character string representing
     the PRETTY-PRINTED text.  */
  const char *
! pp_base_formatted_text (pretty_printer *pp)
  {
    obstack_1grow (&pp->buffer->obstack, '\0');
    return pp_formatted_text_data (pp);
*************** pp_formatted_text (pretty_printer *pp)
*** 461,467 ****
  /*  Return a pointer to the last character emitted in PRETTY-PRINTER's
      output area.  A NULL pointer means no character available.  */
  const char *
! pp_last_position_in_text (const pretty_printer *pp)
  {
    const char *p = NULL;
    struct obstack *text = &pp->buffer->obstack;
--- 461,467 ----
  /*  Return a pointer to the last character emitted in PRETTY-PRINTER's
      output area.  A NULL pointer means no character available.  */
  const char *
! pp_base_last_position_in_text (const pretty_printer *pp)
  {
    const char *p = NULL;
    struct obstack *text = &pp->buffer->obstack;
*************** pp_last_position_in_text (const pretty_p
*** 474,480 ****
  /* Return the amount of characters PRETTY-PRINTER can accept to
     make a full line.  Meaningfull only in line-wrapping mode.  */
  int
! pp_remaining_character_count_for_line (pretty_printer *pp)
  {
    return pp->maximum_length - pp->buffer->line_length;
  }
--- 474,480 ----
  /* Return the amount of characters PRETTY-PRINTER can accept to
     make a full line.  Meaningfull only in line-wrapping mode.  */
  int
! pp_base_remaining_character_count_for_line (pretty_printer *pp)
  {
    return pp->maximum_length - pp->buffer->line_length;
  }
Index: pretty-print.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/pretty-print.h,v
retrieving revision 1.7
diff -p -r1.7 pretty-print.h
*** pretty-print.h	3 Aug 2003 20:02:56 -0000	1.7
--- pretty-print.h	5 Aug 2003 19:18:04 -0000
*************** struct pretty_print_info
*** 145,153 ****
--- 145,173 ----
    bool need_newline;
  };
  
+ #define pp_set_line_maximum_length(PP, L) \
+    pp_base_set_line_maximum_length (pp_base (PP), L)
+ #define pp_set_prefix(PP, P)    pp_base_set_prefix (pp_base (PP), P)
+ #define pp_destroy_prefix(PP)   pp_base_destroy_prefix (pp_base (PP))
+ #define pp_remaining_character_count_for_line(PP) \
+   pp_base_remaining_character_count_for_line (pp_base (PP))
+ #define pp_clear_output_area(PP) \
+   pp_base_clear_output_area (pp_base (PP))
+ #define pp_formatted_text(PP)   pp_base_formatted_text (pp_base (PP))
+ #define pp_last_position_in_text(PP) \
+   pp_base_last_position_in_text (pp_base (PP))
+ #define pp_emit_prefix(PP)      pp_base_emit_prefix (pp_base (PP))
+ #define pp_append_text(PP, B, E) \
+   pp_base_append_text (pp_base (PP), B, E)
+ #define pp_flush(PP)            pp_base_flush (pp_base (PP))
+ #define pp_format_text(PP, TI)  pp_base_format_text (pp_base (PP), TI)
+ #define pp_format_verbatim(PP, TI) \
+   pp_base_format_verbatim (pp_base (PP), TI)
+ 
  #define pp_character(PP, C)     pp_base_character (pp_base (PP), C)
  #define pp_string(PP, S)        pp_base_string (pp_base (PP), S)
  #define pp_newline(PP)          pp_base_newline (pp_base (PP))
+ 
  #define pp_space(PP)            pp_character (PP, ' ')
  #define pp_left_paren(PP)       pp_character (PP, '(')
  #define pp_right_paren(PP)      pp_character (PP, ')')
*************** struct pretty_print_info
*** 202,208 ****
  
  #define pp_identifier(PP, ID)  pp_string (PP, ID)
  #define pp_tree_identifier(PP, T)                      \
!   pp_append_text(pp_base (PP), IDENTIFIER_POINTER (T), \
                   IDENTIFIER_POINTER (T) + IDENTIFIER_LENGTH (T))
  
  #define pp_unsupported_tree(PP, T)                         \
--- 222,228 ----
  
  #define pp_identifier(PP, ID)  pp_string (PP, ID)
  #define pp_tree_identifier(PP, T)                      \
!   pp_append_text(PP, IDENTIFIER_POINTER (T), \
                   IDENTIFIER_POINTER (T) + IDENTIFIER_LENGTH (T))
  
  #define pp_unsupported_tree(PP, T)                         \
*************** struct pretty_print_info
*** 216,235 ****
  #define pp_base(PP) (PP)
  
  extern void pp_construct (pretty_printer *, const char *, int);
! extern void pp_set_line_maximum_length (pretty_printer *, int);
! extern void pp_set_prefix (pretty_printer *, const char *);
! extern void pp_destroy_prefix (pretty_printer *);
! extern int pp_remaining_character_count_for_line (pretty_printer *);
! extern void pp_clear_output_area (pretty_printer *);
! extern const char *pp_formatted_text (pretty_printer *);
! extern const char *pp_last_position_in_text (const pretty_printer *);
! extern void pp_emit_prefix (pretty_printer *);
! extern void pp_append_text (pretty_printer *, const char *, const char *);
  extern void pp_printf (pretty_printer *, const char *, ...) ATTRIBUTE_PRINTF_2;
  extern void pp_verbatim (pretty_printer *, const char *, ...);
! extern void pp_flush (pretty_printer *);
! extern void pp_format_text (pretty_printer *, text_info *);
! extern void pp_format_verbatim (pretty_printer *, text_info *);
  
  extern void pp_base_newline (pretty_printer *);
  extern void pp_base_character (pretty_printer *, int);
--- 236,255 ----
  #define pp_base(PP) (PP)
  
  extern void pp_construct (pretty_printer *, const char *, int);
! extern void pp_base_set_line_maximum_length (pretty_printer *, int);
! extern void pp_base_set_prefix (pretty_printer *, const char *);
! extern void pp_base_destroy_prefix (pretty_printer *);
! extern int pp_base_remaining_character_count_for_line (pretty_printer *);
! extern void pp_base_clear_output_area (pretty_printer *);
! extern const char *pp_base_formatted_text (pretty_printer *);
! extern const char *pp_base_last_position_in_text (const pretty_printer *);
! extern void pp_base_emit_prefix (pretty_printer *);
! extern void pp_base_append_text (pretty_printer *, const char *, const char *);
  extern void pp_printf (pretty_printer *, const char *, ...) ATTRIBUTE_PRINTF_2;
  extern void pp_verbatim (pretty_printer *, const char *, ...);
! extern void pp_base_flush (pretty_printer *);
! extern void pp_base_format_text (pretty_printer *, text_info *);
! extern void pp_base_format_verbatim (pretty_printer *, text_info *);
  
  extern void pp_base_newline (pretty_printer *);
  extern void pp_base_character (pretty_printer *, int);
Index: cp/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/Make-lang.in,v
retrieving revision 1.159
diff -p -r1.159 Make-lang.in
*** cp/Make-lang.in	29 Jul 2003 01:14:22 -0000	1.159
--- cp/Make-lang.in	5 Aug 2003 19:18:16 -0000
*************** CXX_C_OBJS = attribs.o c-common.o c-form
*** 86,93 ****
  CXX_OBJS = cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o \
   cp/class.o cp/decl2.o cp/error.o cp/lex.o cp/parser.o cp/ptree.o cp/rtti.o \
   cp/typeck.o cp/cvt.o cp/except.o cp/friend.o cp/init.o cp/method.o \
!  cp/search.o cp/semantics.o cp/tree.o cp/repo.o cp/dump.o \
!  cp/optimize.o cp/mangle.o cp/cp-lang.o cp/name-lookup.o
  
  # Use strict warnings for this front end.
  cp-warn = $(STRICT_WARN) $(WERROR)
--- 86,93 ----
  CXX_OBJS = cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o \
   cp/class.o cp/decl2.o cp/error.o cp/lex.o cp/parser.o cp/ptree.o cp/rtti.o \
   cp/typeck.o cp/cvt.o cp/except.o cp/friend.o cp/init.o cp/method.o \
!  cp/search.o cp/semantics.o cp/tree.o cp/repo.o cp/dump.o cp/optimize.o \
!  cp/mangle.o cp/cp-lang.o cp/name-lookup.o cp/cxx-pretty-print.o
  
  # Use strict warnings for this front end.
  cp-warn = $(STRICT_WARN) $(WERROR)
*************** CXX_TREE_H = $(TREE_H) cp/name-lookup.h 
*** 231,240 ****
  	$(GGC_H) \
  	$(srcdir)/../include/hashtab.h $(srcdir)/../include/splay-tree.h
  
  cp/lex.o: cp/lex.c $(CXX_TREE_H) $(TM_H) flags.h cp/lex.h \
    c-pragma.h toplev.h output.h input.h cp/operators.def $(TM_P_H)
  cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H) $(TM_H) toplev.h langhooks.h \
!   $(LANGHOOKS_DEF_H) c-common.h
  cp/decl.o: cp/decl.c $(CXX_TREE_H) $(TM_H) flags.h cp/lex.h cp/decl.h stack.h \
    output.h $(EXPR_H) except.h toplev.h $(HASHTAB_H) $(RTL_H) \
    cp/operators.def $(TM_P_H) tree-inline.h diagnostic.h c-pragma.h \
--- 231,242 ----
  	$(GGC_H) \
  	$(srcdir)/../include/hashtab.h $(srcdir)/../include/splay-tree.h
  
+ CXX_PRETTY_PRINT_H = cp/cxx-pretty-print.h $(C_PRETTY_PRINT_H)
+ 
  cp/lex.o: cp/lex.c $(CXX_TREE_H) $(TM_H) flags.h cp/lex.h \
    c-pragma.h toplev.h output.h input.h cp/operators.def $(TM_P_H)
  cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H) $(TM_H) toplev.h langhooks.h \
!   $(LANGHOOKS_DEF_H) c-common.h $(CXX_PRETTY_PRINT_H) $(DIAGNOSTIC_H)
  cp/decl.o: cp/decl.c $(CXX_TREE_H) $(TM_H) flags.h cp/lex.h cp/decl.h stack.h \
    output.h $(EXPR_H) except.h toplev.h $(HASHTAB_H) $(RTL_H) \
    cp/operators.def $(TM_P_H) tree-inline.h diagnostic.h c-pragma.h \
*************** cp/expr.o: cp/expr.c $(CXX_TREE_H) $(TM_
*** 266,272 ****
  cp/pt.o: cp/pt.c $(CXX_TREE_H) $(TM_H) cp/decl.h cp/lex.h \
    toplev.h $(RTL_H) except.h tree-inline.h gt-cp-pt.h
  cp/error.o: cp/error.c $(CXX_TREE_H) $(TM_H) toplev.h $(DIAGNOSTIC_H) \
!   flags.h real.h $(LANGHOOKS_DEF_H)
  cp/repo.o: cp/repo.c $(CXX_TREE_H) $(TM_H) toplev.h diagnostic.h \
    gt-cp-repo.h
  cp/semantics.o: cp/semantics.c $(CXX_TREE_H) $(TM_H) cp/lex.h except.h toplev.h \
--- 268,274 ----
  cp/pt.o: cp/pt.c $(CXX_TREE_H) $(TM_H) cp/decl.h cp/lex.h \
    toplev.h $(RTL_H) except.h tree-inline.h gt-cp-pt.h
  cp/error.o: cp/error.c $(CXX_TREE_H) $(TM_H) toplev.h $(DIAGNOSTIC_H) \
!   flags.h real.h $(LANGHOOKS_DEF_H) $(CXX_PRETTY_PRINT_H)
  cp/repo.o: cp/repo.c $(CXX_TREE_H) $(TM_H) toplev.h diagnostic.h \
    gt-cp-repo.h
  cp/semantics.o: cp/semantics.c $(CXX_TREE_H) $(TM_H) cp/lex.h except.h toplev.h \
*************** cp/parser.o: cp/parser.c $(CXX_TREE_H) $
*** 281,283 ****
--- 283,288 ----
  
  cp/name-lookup.o: cp/name-lookup.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
  	$(TM_H) $(CXX_TREE_H) timevar.h gt-cp-name-lookup.h
+ 
+ cp/cxx-pretty-print.o: cp/cxx-pretty-print.c $(CXX_PRETTY_PRINT_H) \
+   $(CONFIG_H) $(SYSTEM_H) $(TM_H) coretypes.h $(CXX_TREE_H)
Index: cp/cp-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-lang.c,v
retrieving revision 1.59
diff -p -r1.59 cp-lang.c
*** cp/cp-lang.c	4 Aug 2003 20:44:18 -0000	1.59
--- cp/cp-lang.c	5 Aug 2003 19:18:16 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 29,34 ****
--- 29,36 ----
  #include "toplev.h"
  #include "langhooks.h"
  #include "langhooks-def.h"
+ #include "diagnostic.h"
+ #include "cxx-pretty-print.h"
  
  enum c_language_kind c_language = clk_cxx;
  
*************** static bool cxx_warn_unused_global_decl 
*** 38,43 ****
--- 40,46 ----
  static tree cp_expr_size (tree);
  static size_t cp_tree_size (enum tree_code);
  static bool cp_var_mod_type_p (tree);
+ static void cxx_initialize_diagnostics (diagnostic_context *);
  
  #undef LANG_HOOKS_NAME
  #define LANG_HOOKS_NAME "GNU C++"
*************** static bool cp_var_mod_type_p (tree);
*** 51,56 ****
--- 54,61 ----
  #define LANG_HOOKS_CLEAR_BINDING_STACK pop_everything
  #undef LANG_HOOKS_INIT_OPTIONS
  #define LANG_HOOKS_INIT_OPTIONS c_common_init_options
+ #undef LANG_HOOKS_INITIALIZE_DIAGNOSTITCS
+ #define LANG_HOOKS_INITIALIZE_DIAGNOSTITCS cxx_initialize_diagnostics
  #undef LANG_HOOKS_HANDLE_OPTION
  #define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
  #undef LANG_HOOKS_HANDLE_FILENAME
*************** void
*** 372,375 ****
--- 377,395 ----
  c_reset_state (void)
  {
    sorry ("inter-module optimisations not implemented yet");
+ }
+ 
+ /* Construct a C++-aware pretty-printer for CONTEXT.  It is assumed
+    that CONTEXT->printer is an already constructed basic pretty_printer.  */
+ static void
+ cxx_initialize_diagnostics (diagnostic_context *context)
+ {
+   pretty_printer *base = context->printer;
+   cxx_pretty_printer *pp = xmalloc (sizeof (cxx_pretty_printer));
+   memcpy (pp_base (pp), base, sizeof (pretty_printer));
+   pp_cxx_pretty_printer_init (pp);
+   context->printer = (pretty_printer *) pp;
+ 
+   /* It is safe to free this object because it was previously malloc()'d.  */
+   free (base);
  }
Index: cp/cxx-pretty-print.c
===================================================================
RCS file: cp/cxx-pretty-print.c
diff -N cp/cxx-pretty-print.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- cp/cxx-pretty-print.c	5 Aug 2003 19:18:16 -0000
***************
*** 0 ****
--- 1,157 ----
+ /* Implementation of subroutines for the GNU C++ pretty-printer.
+    Copyright (C) 2003 Free Software Foundation, Inc.
+    Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
+ 
+ This file is part of GCC.
+ 
+ GCC is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+ 
+ GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING.  If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.  */
+ 
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+ #include "tm.h"
+ #include "real.h"
+ #include "cxx-pretty-print.h"
+ #include "cp-tree.h"
+ 
+ /* Declarations.  */
+ 
+ void
+ pp_cxx_declaration (cxx_pretty_printer *pp, tree t)
+ {
+   pp_unsupported_tree (pp, t);
+ }
+ 
+ static void
+ pp_cxx_declaration_specifiers (cxx_pretty_printer *pp, tree t)
+ {
+   pp_unsupported_tree (pp, t);
+ }
+ 
+ static void
+ pp_cxx_type_specifier (cxx_pretty_printer *pp, tree t)
+ {
+   pp_unsupported_tree (pp, t);
+ }
+ 
+ static void
+ pp_cxx_declarator (cxx_pretty_printer *pp, tree t)
+ {
+   pp_unsupported_tree (pp, t);
+ }
+ 
+ static void
+ pp_cxx_direct_declarator (cxx_pretty_printer *pp, tree t)
+ {
+   pp_unsupported_tree (pp, t);
+ }
+ 
+ static void
+ pp_cxx_parameter_declaration (cxx_pretty_printer *pp, tree t)
+ {
+   pp_unsupported_tree (pp, t);
+ }
+ 
+ static void
+ pp_cxx_type_id (cxx_pretty_printer *pp, tree t)
+ {
+   pp_unsupported_tree (pp, t);
+ }
+ 
+ /* Statements.  */
+ 
+ void
+ pp_cxx_statement (cxx_pretty_printer *pp, tree t)
+ {
+   pp_unsupported_tree (pp, t);
+ }
+ 
+ /* Expressions. */
+ 
+ static void
+ pp_cxx_primary_expression (cxx_pretty_printer *pp, tree t)
+ {
+   pp_unsupported_tree (pp, t);
+ }
+ 
+ static void
+ pp_cxx_postfix_expression (cxx_pretty_printer *pp, tree t)
+ {
+   pp_unsupported_tree (pp, t);
+ }
+ 
+ static void
+ pp_cxx_unary_expression (cxx_pretty_printer *pp, tree t)
+ {
+   pp_unsupported_tree (pp, t);
+ }
+ 
+ static void
+ pp_cxx_initializer (cxx_pretty_printer *pp, tree t)
+ {
+   pp_unsupported_tree (pp, t);
+ }
+ 
+ static void
+ pp_cxx_multiplicatice_expression (cxx_pretty_printer *pp, tree t)
+ {
+   pp_unsupported_tree (pp, t);
+ }
+ 
+ static void
+ pp_cxx_conditional_expression (cxx_pretty_printer *pp, tree t)
+ {
+   pp_unsupported_tree (pp, t);
+ }
+ 
+ static void
+ pp_cxx_assignment_expression (cxx_pretty_printer *pp, tree t)
+ {
+   pp_unsupported_tree (pp, t);
+ }
+ 
+ void
+ pp_cxx_expression (cxx_pretty_printer *pp, tree t)
+ {
+   pp_unsupported_tree (pp, t);
+ }
+ 
+ 
+ 
+ typedef c_pretty_print_fn pp_fun;
+ 
+ void
+ pp_cxx_pretty_printer_init (cxx_pretty_printer *pp)
+ {
+   pp_c_pretty_printer_init (pp_c_base (pp));
+ 
+   pp->c_base.declaration = (pp_fun) pp_cxx_declaration;
+   pp->c_base.declaration_specifiers = (pp_fun) pp_cxx_declaration_specifiers;
+   pp->c_base.type_specifier = (pp_fun) pp_cxx_type_specifier;
+   pp->c_base.declarator = (pp_fun) pp_cxx_declarator;
+   pp->c_base.direct_declarator = (pp_fun) pp_cxx_direct_declarator;
+   pp->c_base.parameter_declaration = (pp_fun) pp_cxx_parameter_declaration;
+   pp->c_base.type_id = (pp_fun) pp_cxx_type_id;
+   pp->c_base.statement = (pp_fun) pp_cxx_statement;
+   pp->c_base.primary_expression = (pp_fun) pp_cxx_primary_expression;
+   pp->c_base.postfix_expression = (pp_fun) pp_cxx_postfix_expression;
+   pp->c_base.unary_expression = (pp_fun) pp_cxx_unary_expression;
+   pp->c_base.initializer = (pp_fun) pp_cxx_initializer;
+   pp->c_base.multiplicative_expression = (pp_fun) pp_cxx_multiplicatice_expression;
+   pp->c_base.conditional_expression = (pp_fun) pp_cxx_conditional_expression;
+   pp->c_base.assignment_expression = (pp_fun) pp_cxx_assignment_expression;
+   pp->enclosing_scope = NULL;
+ }
Index: cp/cxx-pretty-print.h
===================================================================
RCS file: cp/cxx-pretty-print.h
diff -N cp/cxx-pretty-print.h
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- cp/cxx-pretty-print.h	5 Aug 2003 19:18:16 -0000
***************
*** 0 ****
--- 1,44 ----
+ /* Interface for the GNU C++ pretty-printer.
+    Copyright (C) 2003 Free Software Foundation, Inc.
+    Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
+ 
+ This file is part of GCC.
+ 
+ GCC is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+ 
+ GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING.  If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.  */
+ 
+ #ifndef GCC_CXX_PRETTY_PRINT_H
+ #define GCC_CXX_PRETTY_PRINT_H
+ 
+ #include "c-pretty-print.h"
+ 
+ #undef pp_c_base
+ #define pp_c_base(PP) (&(PP)->c_base)
+ 
+ typedef struct
+ {
+   struct c_pretty_print_info c_base;
+   /* This is the enclosing scope of the entity being pretty-printed.  */
+   tree enclosing_scope;
+ } cxx_pretty_printer;
+ 
+ void pp_cxx_pretty_printer_init (cxx_pretty_printer *);
+ 
+ void pp_cxx_declaration (cxx_pretty_printer *, tree);
+ void pp_cxx_statement (cxx_pretty_printer *, tree);
+ void pp_cxx_expression (cxx_pretty_printer *, tree);
+ 
+ 
+ #endif /* GCC_CXX_PRETTY_PRINT_H */
Index: cp/error.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/error.c,v
retrieving revision 1.227
diff -p -r1.227 error.c
*** cp/error.c	28 Jul 2003 11:06:28 -0000	1.227
--- cp/error.c	5 Aug 2003 19:18:17 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 30,36 ****
  #include "flags.h"
  #include "diagnostic.h"
  #include "langhooks-def.h"
! #include "pretty-print.h"
  
  enum pad { none, before, after };
  
--- 30,36 ----
  #include "flags.h"
  #include "diagnostic.h"
  #include "langhooks-def.h"
! #include "cxx-pretty-print.h"
  
  enum pad { none, before, after };
  
*************** enum pad { none, before, after };
*** 43,49 ****
  /* The global buffer where we dump everything.  It is there only for
     transitional purpose.  It is expected, in the near future, to be
     completely removed.  */
! static pretty_printer scratch_pretty_printer;
  #define cxx_pp (&scratch_pretty_printer)
  
  # define NEXT_CODE(T) (TREE_CODE (TREE_TYPE (T)))
--- 43,49 ----
  /* The global buffer where we dump everything.  It is there only for
     transitional purpose.  It is expected, in the near future, to be
     completely removed.  */
! static cxx_pretty_printer scratch_pretty_printer;
  #define cxx_pp (&scratch_pretty_printer)
  
  # define NEXT_CODE(T) (TREE_CODE (TREE_TYPE (T)))
*************** static void dump_function_name (tree, in
*** 78,84 ****
  static void dump_expr_list (tree, int);
  static void dump_global_iord (tree);
  static enum pad dump_qualifiers (tree, enum pad);
- static void dump_char (int);
  static void dump_parameters (tree, int);
  static void dump_exception_spec (tree, int);
  static const char *class_key_or_enum (tree);
--- 78,83 ----
*************** static void cp_diagnostic_finalizer (dia
*** 99,105 ****
  static void cp_print_error_function (diagnostic_context *, diagnostic_info *);
  
  static bool cp_printer (pretty_printer *, text_info *);
! static void pp_non_consecutive_character (pretty_printer *, int);
  static tree locate_error (const char *, va_list);
  static location_t location_of (tree);
  
--- 98,104 ----
  static void cp_print_error_function (diagnostic_context *, diagnostic_info *);
  
  static bool cp_printer (pretty_printer *, text_info *);
! static void pp_non_consecutive_character (cxx_pretty_printer *, int);
  static tree locate_error (const char *, va_list);
  static location_t location_of (tree);
  
*************** init_error (void)
*** 110,116 ****
    diagnostic_finalizer (global_dc) = cp_diagnostic_finalizer;
    diagnostic_format_decoder (global_dc) = cp_printer;
  
!   pp_construct (cxx_pp, NULL, 0);
  }
  
  /* Dump a scope, if deemed necessary.  */
--- 109,116 ----
    diagnostic_finalizer (global_dc) = cp_diagnostic_finalizer;
    diagnostic_format_decoder (global_dc) = cp_printer;
  
!   pp_construct (pp_base (cxx_pp), NULL, 0);
!   pp_cxx_pretty_printer_init (cxx_pp);
  }
  
  /* Dump a scope, if deemed necessary.  */
*************** dump_aggr_type (tree t, int flags)
*** 531,537 ****
        if (flags & TFF_CLASS_KEY_OR_ENUM)
          pp_identifier (cxx_pp, "<anonymous>");
        else
!         pp_printf (cxx_pp, "<anonymous %s>", variety);
      }
    else
      pp_tree_identifier (cxx_pp, name);
--- 531,537 ----
        if (flags & TFF_CLASS_KEY_OR_ENUM)
          pp_identifier (cxx_pp, "<anonymous>");
        else
!         pp_printf (pp_base (cxx_pp), "<anonymous %s>", variety);
      }
    else
      pp_tree_identifier (cxx_pp, name);
*************** dump_global_iord (tree t)
*** 758,764 ****
    else
      abort ();
  
!   pp_printf (cxx_pp, "(static %s for %s)", p, input_filename);
  }
  
  static void
--- 758,764 ----
    else
      abort ();
  
!   pp_printf (pp_base (cxx_pp), "(static %s for %s)", p, input_filename);
  }
  
  static void
*************** dump_template_parms (tree info, int prim
*** 1315,1364 ****
    pp_template_argument_list_end (cxx_pp);
  }
  
- static void
- dump_char (int c)
- {
-   switch (c)
-     {
-     case TARGET_NEWLINE:
-       pp_string (cxx_pp, "\\n");
-       break;
-     case TARGET_TAB:
-       pp_string (cxx_pp, "\\t");
-       break;
-     case TARGET_VT:
-       pp_string (cxx_pp, "\\v");
-       break;
-     case TARGET_BS:
-       pp_string (cxx_pp, "\\b");
-       break;
-     case TARGET_CR:
-       pp_string (cxx_pp, "\\r");
-       break;
-     case TARGET_FF:
-       pp_string (cxx_pp, "\\f");
-       break;
-     case TARGET_BELL:
-       pp_string (cxx_pp, "\\a");
-       break;
-     case '\\':
-       pp_string (cxx_pp, "\\\\");
-       break;
-     case '\'':
-       pp_string (cxx_pp, "\\'");
-       break;
-     case '\"':
-       pp_string (cxx_pp, "\\\"");
-       break;
-     default:
-       if (ISPRINT (c))
- 	pp_character (cxx_pp, c);
-       else
-         pp_scalar (cxx_pp, "\\%03o", (unsigned) c);
-       break;
-     }
- }
- 
  /* Print out a list of initializers (subr of dump_expr) */
  
  static void
--- 1315,1320 ----
*************** dump_expr (tree t, int flags)
*** 1418,1472 ****
                  pp_left_paren (cxx_pp);
                  dump_type (type, flags);
                  pp_right_paren (cxx_pp);
!                 goto do_int;
  	      }
  	  }
! 	else if (type == boolean_type_node)
! 	  {
! 	    if (t == boolean_false_node || integer_zerop (t))
! 	      pp_identifier (cxx_pp, "false");
! 	    else if (t == boolean_true_node)
! 	      pp_identifier (cxx_pp, "true");
! 	  }
! 	else if (type == char_type_node)
! 	  {
!             pp_quote (cxx_pp);
! 	    if (host_integerp (t, TREE_UNSIGNED (type)))
! 	      dump_char (tree_low_cst (t, TREE_UNSIGNED (type)));
! 	    else
! 	      pp_printf (cxx_pp, "\\x%x",
!                          (unsigned int) TREE_INT_CST_LOW (t));
!             pp_quote (cxx_pp);
! 	  }
! 	else
! 	  {
! 	    do_int:
! 	    if (! host_integerp (t, 0))
! 	      {
! 	        tree val = t;
! 
! 	        if (tree_int_cst_sgn (val) < 0)
! 	          {
!                     pp_minus (cxx_pp);
! 		    val = build_int_2 (-TREE_INT_CST_LOW (val),
! 				       ~TREE_INT_CST_HIGH (val)
! 	                               + !TREE_INT_CST_LOW (val));
! 	          }
! 		sprintf (cxx_pp->buffer->digit_buffer,
!                          HOST_WIDE_INT_PRINT_DOUBLE_HEX,
! 			 TREE_INT_CST_HIGH (val), TREE_INT_CST_LOW (val));
! 		pp_string (cxx_pp, cxx_pp->buffer->digit_buffer);
! 	      }
! 	    else
! 	      pp_wide_integer (cxx_pp, TREE_INT_CST_LOW (t));
! 	  }
        }
        break;
  
      case REAL_CST:
!       real_to_decimal (cxx_pp->buffer->digit_buffer, &TREE_REAL_CST (t),
! 		       sizeof (cxx_pp->buffer->digit_buffer), 0, 1);
!       pp_string (cxx_pp, cxx_pp->buffer->digit_buffer);
        break;
  
      case PTRMEM_CST:
--- 1374,1389 ----
                  pp_left_paren (cxx_pp);
                  dump_type (type, flags);
                  pp_right_paren (cxx_pp);
!                 pp_c_integer_literal (pp_c_base (cxx_pp), t);
  	      }
  	  }
!         else
!           pp_c_integer_literal (pp_c_base (cxx_pp), t);
        }
        break;
  
      case REAL_CST:
!       pp_c_real_literal (pp_c_base (cxx_pp), t);
        break;
  
      case PTRMEM_CST:
*************** dump_expr (tree t, int flags)
*** 1477,1492 ****
        break;
  
      case STRING_CST:
!       {
! 	const char *p = TREE_STRING_POINTER (t);
! 	int len = TREE_STRING_LENGTH (t) - 1;
! 	int i;
! 
! 	pp_doublequote (cxx_pp);
! 	for (i = 0; i < len; i++)
! 	  dump_char (p[i]);
! 	pp_doublequote (cxx_pp);
!       }
        break;
  
      case COMPOUND_EXPR:
--- 1394,1400 ----
        break;
  
      case STRING_CST:
!       pp_c_string_literal (pp_c_base (cxx_pp), t);
        break;
  
      case COMPOUND_EXPR:
*************** void
*** 2268,2274 ****
  cxx_print_error_function (diagnostic_context *context, const char *file)
  {
    lhd_print_error_function (context, file);
!   pp_set_prefix (context->printer, file);
    maybe_print_instantiation_context (context);
  }
  
--- 2176,2182 ----
  cxx_print_error_function (diagnostic_context *context, const char *file)
  {
    lhd_print_error_function (context, file);
!   pp_base_set_prefix (context->printer, file);
    maybe_print_instantiation_context (context);
  }
  
*************** cp_diagnostic_starter (diagnostic_contex
*** 2279,2292 ****
    diagnostic_report_current_module (context);
    cp_print_error_function (context, diagnostic);
    maybe_print_instantiation_context (context);
!   pp_set_prefix (context->printer, diagnostic_build_prefix (diagnostic));
  }
  
  static void
  cp_diagnostic_finalizer (diagnostic_context *context,
                           diagnostic_info *diagnostic ATTRIBUTE_UNUSED)
  {
!   pp_destroy_prefix (context->printer);
  }
  
  /* Print current function onto BUFFER, in the process of reporting
--- 2187,2200 ----
    diagnostic_report_current_module (context);
    cp_print_error_function (context, diagnostic);
    maybe_print_instantiation_context (context);
!   pp_base_set_prefix (context->printer, diagnostic_build_prefix (diagnostic));
  }
  
  static void
  cp_diagnostic_finalizer (diagnostic_context *context,
                           diagnostic_info *diagnostic ATTRIBUTE_UNUSED)
  {
!   pp_base_destroy_prefix (context->printer);
  }
  
  /* Print current function onto BUFFER, in the process of reporting
*************** cp_print_error_function (diagnostic_cont
*** 2302,2319 ****
          ? file_name_as_prefix (diagnostic->location.file)
          : NULL;
  
!       pp_set_prefix (context->printer, new_prefix);
  
        if (current_function_decl == NULL)
!         pp_string (context->printer, "At global scope:");
        else
          pp_printf (context->printer, "In %s `%s':",
                     function_category (current_function_decl),
                     cxx_printable_name (current_function_decl, 2));
!       pp_newline (context->printer);
  
        diagnostic_set_last_function (context);
!       pp_destroy_prefix (context->printer);
        context->printer->prefix = old_prefix;
      }
  }
--- 2210,2227 ----
          ? file_name_as_prefix (diagnostic->location.file)
          : NULL;
  
!       pp_base_set_prefix (context->printer, new_prefix);
  
        if (current_function_decl == NULL)
!         pp_base_string (context->printer, "At global scope:");
        else
          pp_printf (context->printer, "In %s `%s':",
                     function_category (current_function_decl),
                     cxx_printable_name (current_function_decl, 2));
!       pp_base_newline (context->printer);
  
        diagnostic_set_last_function (context);
!       pp_base_destroy_prefix (context->printer);
        context->printer->prefix = old_prefix;
      }
  }
*************** cp_printer (pretty_printer *pp, text_inf
*** 2461,2467 ****
        return false;
      }
  
!   pp_string (pp, result);
    return true;
  #undef next_tree
  #undef next_tcode
--- 2369,2375 ----
        return false;
      }
  
!   pp_base_string (pp, result);
    return true;
  #undef next_tree
  #undef next_tcode
*************** cp_printer (pretty_printer *pp, text_inf
*** 2470,2476 ****
  }
  
  static void
! pp_non_consecutive_character (pretty_printer *pp, int c)
  {
    const char *p = pp_last_position_in_text (pp);
  
--- 2378,2384 ----
  }
  
  static void
! pp_non_consecutive_character (cxx_pretty_printer *pp, int c)
  {
    const char *p = pp_last_position_in_text (pp);
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]