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] PATCH to cp/error.c


This patch cleans up some code in cp/error.c

Bootstrapped and regtested on an i686-pc-linux.
Applied.

-- Gaby

2003-06-29  Gabriel Dos Reis  <gdr@integrable-solutions.net>
  
	* cp-tree.h (language_to_string): Adjust declaration.
	* dump.c (cp_dump_tree): Adjust usage.
	* error.c (dump_char): Use output_formatted_scalar. Tidy.
	(parm_to_string): Lose unused parameter.  Tidy.
	(expr_to_string): Likewise.
	(code_to_string): Likewise.
	(language_to_string): Likewise.
	(op_to_string): Likewise.
	(assop_to_string): Likewise.
	(digit_buffer): Remove.
	(dump_type): Format builtin vector type as __vector__.

Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.861
diff -p -r1.861 cp-tree.h
*** cp-tree.h	28 Jun 2003 16:23:25 -0000	1.861
--- cp-tree.h	29 Jun 2003 11:58:51 -0000
*************** extern const char *decl_as_string		(tree
*** 3820,3826 ****
  extern const char *expr_as_string		(tree, int);
  extern const char *context_as_string            (tree, int);
  extern const char *lang_decl_name		(tree, int);
! extern const char *language_to_string           (enum languages, int);
  extern void print_instantiation_context         (void);
  
  /* in except.c */
--- 3820,3826 ----
  extern const char *expr_as_string		(tree, int);
  extern const char *context_as_string            (tree, int);
  extern const char *lang_decl_name		(tree, int);
! extern const char *language_to_string           (enum languages);
  extern void print_instantiation_context         (void);
  
  /* in except.c */
Index: dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/dump.c,v
retrieving revision 1.71
diff -p -r1.71 dump.c
*** dump.c	19 Mar 2003 20:34:07 -0000	1.71
--- dump.c	29 Jun 2003 11:58:51 -0000
*************** cp_dump_tree (void* dump_info, tree t)
*** 214,220 ****
    if (DECL_P (t))
      {
        if (DECL_LANG_SPECIFIC (t) && DECL_LANGUAGE (t) != lang_cplusplus)
! 	dump_string (di, language_to_string (DECL_LANGUAGE (t), 0));
      }
  
    switch (code)
--- 214,220 ----
    if (DECL_P (t))
      {
        if (DECL_LANG_SPECIFIC (t) && DECL_LANGUAGE (t) != lang_cplusplus)
! 	dump_string (di, language_to_string (DECL_LANGUAGE (t)));
      }
  
    switch (code)
Index: error.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/error.c,v
retrieving revision 1.211
diff -p -r1.211 error.c
*** error.c	29 Jun 2003 10:55:33 -0000	1.211
--- error.c	29 Jun 2003 11:58:52 -0000
*************** static output_buffer *scratch_buffer = &
*** 63,76 ****
     output_clear_message_text (scratch_buffer)
  
  static const char *args_to_string (tree, int);
! static const char *assop_to_string (enum tree_code, int);
! static const char *code_to_string (enum tree_code, int);
  static const char *cv_to_string (tree, int);
  static const char *decl_to_string (tree, int);
! static const char *expr_to_string (tree, int);
  static const char *fndecl_to_string (tree, int);
! static const char *op_to_string	(enum tree_code, int);
! static const char *parm_to_string (int, int);
  static const char *type_to_string (tree, int);
  
  static void dump_type (tree, int);
--- 63,76 ----
     output_clear_message_text (scratch_buffer)
  
  static const char *args_to_string (tree, int);
! static const char *assop_to_string (enum tree_code);
! static const char *code_to_string (enum tree_code);
  static const char *cv_to_string (tree, int);
  static const char *decl_to_string (tree, int);
! static const char *expr_to_string (tree);
  static const char *fndecl_to_string (tree, int);
! static const char *op_to_string	(enum tree_code);
! static const char *parm_to_string (int);
  static const char *type_to_string (tree, int);
  
  static void dump_type (tree, int);
*************** dump_qualifiers (tree t, enum pad p)
*** 186,195 ****
    return p;
  }
  
- /* This must be large enough to hold any printed integer or floating-point
-    value.  */
- static char digit_buffer[128];
- 
  /* Dump the template ARGument under control of FLAGS.  */
  
  static void
--- 186,191 ----
*************** dump_type (tree t, int flags)
*** 359,365 ****
        break;
  
      case VECTOR_TYPE:
!       output_add_string (scratch_buffer, "vector ");
        {
  	/* The subtype of a VECTOR_TYPE is something like intQI_type_node,
  	   which has no name and is not very useful for diagnostics.  So
--- 355,361 ----
        break;
  
      case VECTOR_TYPE:
!       output_add_string (scratch_buffer, "__vector__ ");
        {
  	/* The subtype of a VECTOR_TYPE is something like intQI_type_node,
  	   which has no name and is not very useful for diagnostics.  So
*************** dump_char (int c)
*** 1371,1380 ****
        if (ISPRINT (c))
  	output_add_character (scratch_buffer, c);
        else
! 	{
! 	  sprintf (digit_buffer, "\\%03o", (int) c);
! 	  output_add_string (scratch_buffer, digit_buffer);
! 	}
      }
  }
  
--- 1367,1374 ----
        if (ISPRINT (c))
  	output_add_character (scratch_buffer, c);
        else
!         output_formatted_scalar (scratch_buffer, "\\%03o", (unsigned) c);
!       break;
      }
  }
  
*************** dump_expr (tree t, int flags)
*** 1471,1479 ****
  				       ~TREE_INT_CST_HIGH (val)
  	                               + !TREE_INT_CST_LOW (val));
  	          }
! 		sprintf (digit_buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
  			 TREE_INT_CST_HIGH (val), TREE_INT_CST_LOW (val));
! 		output_add_string (scratch_buffer, digit_buffer);
  	      }
  	    else
  	      output_host_wide_integer (scratch_buffer, TREE_INT_CST_LOW (t));
--- 1465,1475 ----
  				       ~TREE_INT_CST_HIGH (val)
  	                               + !TREE_INT_CST_LOW (val));
  	          }
! 		sprintf (scratch_buffer->digit_buffer,
!                          HOST_WIDE_INT_PRINT_DOUBLE_HEX,
  			 TREE_INT_CST_HIGH (val), TREE_INT_CST_LOW (val));
! 		output_add_string
!                   (scratch_buffer, scratch_buffer->digit_buffer);
  	      }
  	    else
  	      output_host_wide_integer (scratch_buffer, TREE_INT_CST_LOW (t));
*************** dump_expr (tree t, int flags)
*** 1482,1490 ****
        break;
  
      case REAL_CST:
!       real_to_decimal (digit_buffer, &TREE_REAL_CST (t),
! 		       sizeof (digit_buffer), 0, 1);
!       output_add_string (scratch_buffer, digit_buffer);
        break;
  
      case PTRMEM_CST:
--- 1478,1486 ----
        break;
  
      case REAL_CST:
!       real_to_decimal (scratch_buffer->digit_buffer, &TREE_REAL_CST (t),
! 		       sizeof (scratch_buffer->digit_buffer), 0, 1);
!       output_add_string (scratch_buffer, scratch_buffer->digit_buffer);
        break;
  
      case PTRMEM_CST:
*************** decl_to_string (tree decl, int verbose)
*** 2160,2166 ****
  }
  
  static const char *
! expr_to_string (tree decl, int verbose ATTRIBUTE_UNUSED)
  {
    reinit_global_formatting_buffer ();
  
--- 2156,2162 ----
  }
  
  static const char *
! expr_to_string (tree decl)
  {
    reinit_global_formatting_buffer ();
  
*************** fndecl_to_string (tree fndecl, int verbo
*** 2186,2198 ****
  
  
  static const char *
! code_to_string (enum tree_code c, int v ATTRIBUTE_UNUSED)
  {
    return tree_code_name [c];
  }
  
  const char *
! language_to_string (enum languages c, int v ATTRIBUTE_UNUSED)
  {
    switch (c)
      {
--- 2182,2194 ----
  
  
  static const char *
! code_to_string (enum tree_code c)
  {
    return tree_code_name [c];
  }
  
  const char *
! language_to_string (enum languages c)
  {
    switch (c)
      {
*************** language_to_string (enum languages c, in
*** 2214,2235 ****
  /* Return the proper printed version of a parameter to a C++ function.  */
  
  static const char *
! parm_to_string (int p, int v ATTRIBUTE_UNUSED)
  {
    if (p < 0)
!     return "`this'";
  
!   sprintf (digit_buffer, "%d", p+1);
!   return digit_buffer;
  }
  
  static const char *
! op_to_string (enum tree_code p, int v ATTRIBUTE_UNUSED)
  {
    tree id;
  
    id = operator_name_info[(int) p].identifier;
!   return id ? IDENTIFIER_POINTER (id) : "{unknown}";
  }
  
  static const char *
--- 2210,2232 ----
  /* Return the proper printed version of a parameter to a C++ function.  */
  
  static const char *
! parm_to_string (int p)
  {
    if (p < 0)
!     output_add_string (scratch_buffer, "'this'");
!   else
!     output_decimal (scratch_buffer, p + 1);
  
!   return output_finalize_message (scratch_buffer);
  }
  
  static const char *
! op_to_string (enum tree_code p)
  {
    tree id;
  
    id = operator_name_info[(int) p].identifier;
!   return id ? IDENTIFIER_POINTER (id) : "<unknown>";
  }
  
  static const char *
*************** type_to_string (tree typ, int verbose)
*** 2250,2256 ****
  }
  
  static const char *
! assop_to_string (enum tree_code p, int v ATTRIBUTE_UNUSED)
  {
    tree id;
  
--- 2247,2253 ----
  }
  
  static const char *
! assop_to_string (enum tree_code p)
  {
    tree id;
  
*************** cp_printer (output_buffer *buffer, text_
*** 2478,2491 ****
    switch (*text->format_spec)
      {
      case 'A': result = args_to_string (next_tree, verbose);	break;
!     case 'C': result = code_to_string (next_tcode, verbose);	break;
      case 'D': result = decl_to_string (next_tree, verbose);	break;
!     case 'E': result = expr_to_string (next_tree, verbose);	break;
      case 'F': result = fndecl_to_string (next_tree, verbose);	break;
!     case 'L': result = language_to_string (next_lang, verbose); break;
!     case 'O': result = op_to_string (next_tcode, verbose);	break;
!     case 'P': result = parm_to_string (next_int, verbose);	break;
!     case 'Q': result = assop_to_string (next_tcode, verbose);	break;
      case 'T': result = type_to_string (next_tree, verbose);	break;
      case 'V': result = cv_to_string (next_tree, verbose);	break;
   
--- 2475,2488 ----
    switch (*text->format_spec)
      {
      case 'A': result = args_to_string (next_tree, verbose);	break;
!     case 'C': result = code_to_string (next_tcode);	        break;
      case 'D': result = decl_to_string (next_tree, verbose);	break;
!     case 'E': result = expr_to_string (next_tree);      	break;
      case 'F': result = fndecl_to_string (next_tree, verbose);	break;
!     case 'L': result = language_to_string (next_lang);          break;
!     case 'O': result = op_to_string (next_tcode);       	break;
!     case 'P': result = parm_to_string (next_int);	        break;
!     case 'Q': result = assop_to_string (next_tcode);	        break;
      case 'T': result = type_to_string (next_tree, verbose);	break;
      case 'V': result = cv_to_string (next_tree, verbose);	break;
   
 


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