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]

3.3 PATCH: Remove error_with_file_line use in cp/spew.c


Ths patchlet removes uses of error_with_file_line() in cp/spew.c now
that we have support for location formatting in the diagnostic library.
Another patch will follow to remove pedwarn_with_file_line() from
cp/decl.c. 

Bootstrapped and tested on an i686-pc-linux-gnu.  No regression.
Applied to mainline.

-- Gaby
2002-07-20  Gabriel Dos Reis  <gdr@nerim.net>

	* spew.c (struct uinparsed_test): Replace 'filename' and 'lineno'
	members with 'locus'.  Adjust use throughout.
	(struct feed):  Likewise.
	(alloc_unparsed_test): Change prototype, take a 'const location_t *'.
	Adjust use.
	(snarf_defarg): Use error(), not error_with_file_and_line().

Index: spew.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/spew.c,v
retrieving revision 1.67
diff -p -r1.67 spew.c
*** spew.c	20 Jun 2002 17:38:23 -0000	1.67
--- spew.c	20 Jul 2002 12:44:26 -0000
*************** struct unparsed_text GTY(())
*** 79,86 ****
  {
    struct unparsed_text *next;	/* process this one next */
    tree decl;		/* associated declaration */
!   const char *filename;	/* name of file we were processing */
!   int lineno;		/* line number we got the text from */
    int interface;	/* remembering interface_unknown and interface_only */
  
    struct token_chunk * tokens; /* Start of the token list.  */
--- 79,85 ----
  {
    struct unparsed_text *next;	/* process this one next */
    tree decl;		/* associated declaration */
!   location_t locus;     /* location we got the text from */
    int interface;	/* remembering interface_unknown and interface_only */
  
    struct token_chunk * tokens; /* Start of the token list.  */
*************** struct unparsed_text GTY(())
*** 98,105 ****
  struct feed GTY(())
  {
    struct unparsed_text *input;
!   const char *filename;
!   int lineno;
    int yychar;
    YYSTYPE GTY ((desc ("%1.yychar"))) yylval;
    int first_token;
--- 97,103 ----
  struct feed GTY(())
  {
    struct unparsed_text *input;
!   location_t locus;
    int yychar;
    YYSTYPE GTY ((desc ("%1.yychar"))) yylval;
    int first_token;
*************** static SPEW_INLINE struct token * space_
*** 131,137 ****
  static SPEW_INLINE struct token * remove_last_token
    PARAMS ((struct unparsed_text *t));
  static struct unparsed_text * alloc_unparsed_text
!   PARAMS ((const char *fn, int li, tree decl, int interface));
  
  static void snarf_block PARAMS ((struct unparsed_text *t));
  static tree snarf_defarg PARAMS ((void));
--- 129,135 ----
  static SPEW_INLINE struct token * remove_last_token
    PARAMS ((struct unparsed_text *t));
  static struct unparsed_text * alloc_unparsed_text
!   PARAMS ((const location_t *, tree decl, int interface));
  
  static void snarf_block PARAMS ((struct unparsed_text *t));
  static tree snarf_defarg PARAMS ((void));
*************** feed_input (input)
*** 403,422 ****
  #ifdef SPEW_DEBUG
    if (spew_debug)
      fprintf (stderr, "\tfeeding %s:%d [%d tokens]\n",
! 	     input->filename, input->lineno, input->limit - input->pos);
  #endif
  
    f->input = input;
!   f->filename = input_filename;
!   f->lineno = lineno;
    f->yychar = yychar;
    f->yylval = yylval;
    f->first_token = first_token;
    f->token_obstack = token_obstack;
    f->next = feed;
  
!   input_filename = input->filename;
!   lineno = input->lineno;
    yychar = YYEMPTY;
    yylval.ttype = NULL_TREE;
    first_token = 0;
--- 401,420 ----
  #ifdef SPEW_DEBUG
    if (spew_debug)
      fprintf (stderr, "\tfeeding %s:%d [%d tokens]\n",
! 	     input->locus.file, input->locus.line, input->limit - input->pos);
  #endif
  
    f->input = input;
!   f->locus.file = input_filename;
!   f->locus.line = lineno;
    f->yychar = yychar;
    f->yylval = yylval;
    f->first_token = first_token;
    f->token_obstack = token_obstack;
    f->next = feed;
  
!   input_filename = input->locus.file;
!   lineno = input->locus.line;
    yychar = YYEMPTY;
    yylval.ttype = NULL_TREE;
    first_token = 0;
*************** end_input ()
*** 429,436 ****
  {
    struct feed *f = feed;
  
!   input_filename = f->filename;
!   lineno = f->lineno;
    yychar = f->yychar;
    yylval = f->yylval;
    first_token = f->first_token;
--- 427,434 ----
  {
    struct feed *f = feed;
  
!   input_filename = f->locus.file;
!   lineno = f->locus.line;
    yychar = f->yychar;
    yylval = f->yylval;
    first_token = f->first_token;
*************** remove_last_token (t)
*** 1070,1086 ****
  
  /* Allocate an 'unparsed_text' structure, ready to use space_for_token.  */
  static struct unparsed_text *
! alloc_unparsed_text (fn, li, decl, interface)
!      const char *fn;
!      int li;
       tree decl;
       int interface;
  {
    struct unparsed_text *r;
    r = ggc_alloc_cleared (sizeof (*r));
    r->decl = decl;
!   r->filename = fn;
!   r->lineno = li;
    r->interface = interface;
    r->tokens = r->last_chunk = ggc_alloc_cleared (sizeof (*r->tokens));
    return r;
--- 1068,1082 ----
  
  /* Allocate an 'unparsed_text' structure, ready to use space_for_token.  */
  static struct unparsed_text *
! alloc_unparsed_text (locus, decl, interface)
!      const location_t *locus;
       tree decl;
       int interface;
  {
    struct unparsed_text *r;
    r = ggc_alloc_cleared (sizeof (*r));
    r->decl = decl;
!   r->locus = *locus;
    r->interface = interface;
    r->tokens = r->last_chunk = ggc_alloc_cleared (sizeof (*r->tokens));
    return r;
*************** snarf_block (t)
*** 1166,1173 ****
  	}
        else if (yyc == 0)
  	{
! 	  error_with_file_and_line (t->filename, t->lineno,
! 				    "end of file read inside definition");
  	  break;
  	}
      }
--- 1162,1168 ----
  	}
        else if (yyc == 0)
  	{
! 	  error ("%Hend of file read inside definition", &t->locus);
  	  break;
  	}
      }
*************** void
*** 1179,1191 ****
  snarf_method (decl)
       tree decl;
  {
-   int starting_lineno = lineno;
-   const char *starting_filename = input_filename;
    struct unparsed_text *meth;
  
!   meth = alloc_unparsed_text (starting_filename, starting_lineno, decl,
! 			      (interface_unknown ? 1
! 			       : (interface_only ? 0 : 2)));
  
    snarf_block (meth);
  
--- 1174,1186 ----
  snarf_method (decl)
       tree decl;
  {
    struct unparsed_text *meth;
+   location_t starting;
+   starting.file = input_filename;
+   starting.line = lineno;
  
!   meth = alloc_unparsed_text (&starting, decl, (interface_unknown ? 1
! 						: (interface_only ? 0 : 2)));
  
    snarf_block (meth);
  
*************** snarf_method (decl)
*** 1198,1205 ****
  #ifdef SPEW_DEBUG
    if (spew_debug)
      fprintf (stderr, "\tsaved method of %d tokens from %s:%d\n",
! 	     meth->limit,
! 	     starting_filename, starting_lineno);
  #endif
  
    DECL_PENDING_INLINE_INFO (decl) = meth;
--- 1193,1199 ----
  #ifdef SPEW_DEBUG
    if (spew_debug)
      fprintf (stderr, "\tsaved method of %d tokens from %s:%d\n",
! 	     meth->limit, starting.file, starting.line);
  #endif
  
    DECL_PENDING_INLINE_INFO (decl) = meth;
*************** snarf_method (decl)
*** 1218,1231 ****
  static tree
  snarf_defarg ()
  {
-   int starting_lineno = lineno;
-   const char *starting_filename = input_filename;
    int yyc;
    int plev = 0;
    struct unparsed_text *buf;
    tree arg;
  
!   buf = alloc_unparsed_text (starting_filename, starting_lineno, 0, 0);
  
    for (;;)
      {
--- 1212,1226 ----
  static tree
  snarf_defarg ()
  {
    int yyc;
    int plev = 0;
    struct unparsed_text *buf;
    tree arg;
+   location_t starting;
+   starting.file = input_filename;
+   starting.line = lineno;
  
!   buf = alloc_unparsed_text (&starting, 0, 0);
  
    for (;;)
      {
*************** snarf_defarg ()
*** 1239,1246 ****
  	--plev;
        else if (yyc == 0)
  	{
! 	  error_with_file_and_line (starting_filename, starting_lineno,
! 				    "end of file read inside default argument");
  	  goto done;
  	}
      }
--- 1234,1240 ----
  	--plev;
        else if (yyc == 0)
  	{
! 	  error ("%Hend of file read inside default argument", &starting);
  	  goto done;
  	}
      }
*************** snarf_defarg ()
*** 1252,1259 ****
  #ifdef SPEW_DEBUG
    if (spew_debug)
      fprintf (stderr, "\tsaved defarg of %d tokens from %s:%d\n",
! 	     buf->limit,
! 	     starting_filename, starting_lineno);
  #endif
  
    arg = make_node (DEFAULT_ARG);
--- 1246,1252 ----
  #ifdef SPEW_DEBUG
    if (spew_debug)
      fprintf (stderr, "\tsaved defarg of %d tokens from %s:%d\n",
! 	     buf->limit, starting.file, starting.line);
  #endif
  
    arg = make_node (DEFAULT_ARG);


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