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]

[PATCH] Another location_t cleanup


Hi,
this patch replaces the save_filename and save_lineno rules with
a save_location one.

booted & tested on i686-pc-linux-gnu, ok?

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
         The voices in my head said this was stupid too
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2003-06-27  Nathan Sidwell  <nathan@codesourcery.com>

	* c-parse.in (%union): Replace filename & lineno with location.
	(save_filename, save_lineno): Remove.
	(save_location): New.
	(fndef, old_style_parm_decls_1, lineno_datadecl, lineno_decl,
	nested_function, notype_nested_function, if_prefix, lineno_stmt,
	lineno_label, label): Adjust.

Index: c-parse.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-parse.in,v
retrieving revision 1.162
diff -c -3 -p -r1.162 c-parse.in
*** c-parse.in	27 Jun 2003 09:05:45 -0000	1.162
--- c-parse.in	27 Jun 2003 09:11:16 -0000
*************** do {									\
*** 108,114 ****
  %start program
  
  %union {long itype; tree ttype; enum tree_code code;
! 	const char *filename; int lineno; }
  
  /* All identifiers that are not reserved words
     and are not declared typedefs in the current block */
--- 108,114 ----
  %start program
  
  %union {long itype; tree ttype; enum tree_code code;
! 	location_t location; }
  
  /* All identifiers that are not reserved words
     and are not declared typedefs in the current block */
*************** do {									\
*** 238,245 ****
  
  %type <itype> setspecs setspecs_fp
  
! %type <filename> save_filename
! %type <lineno> save_lineno
  
  ifobjc
  /* the Objective-C nonterminals */
--- 238,244 ----
  
  %type <itype> setspecs setspecs_fp
  
! %type <location> save_location
  
  ifobjc
  /* the Objective-C nonterminals */
*************** fndef:
*** 434,444 ****
  					all_prefix_attributes))
  		    YYERROR1;
  		}
! 	  old_style_parm_decls  save_filename save_lineno
! 		{ DECL_SOURCE_FILE (current_function_decl) = $6;
! 		  DECL_SOURCE_LINE (current_function_decl) = $7;
  		  store_parm_decls (); }
! 	 compstmt_or_error
  		{ finish_function (0, 1);
  		  POP_DECLSPEC_STACK; }
  	| declspecs_ts setspecs declarator error
--- 433,442 ----
  					all_prefix_attributes))
  		    YYERROR1;
  		}
! 	  old_style_parm_decls save_location
! 		{ DECL_SOURCE_LOCATION (current_function_decl) = $6;
  		  store_parm_decls (); }
! 	  compstmt_or_error
  		{ finish_function (0, 1);
  		  POP_DECLSPEC_STACK; }
  	| declspecs_ts setspecs declarator error
*************** fndef:
*** 448,456 ****
  					all_prefix_attributes))
  		    YYERROR1;
  		}
! 	  old_style_parm_decls save_filename save_lineno
! 		{ DECL_SOURCE_FILE (current_function_decl) = $6;
! 		  DECL_SOURCE_LINE (current_function_decl) = $7;
  		  store_parm_decls (); }
  	  compstmt_or_error
  		{ finish_function (0, 1);
--- 446,453 ----
  					all_prefix_attributes))
  		    YYERROR1;
  		}
! 	  old_style_parm_decls save_location
! 		{ DECL_SOURCE_LOCATION (current_function_decl) = $6;
  		  store_parm_decls (); }
  	  compstmt_or_error
  		{ finish_function (0, 1);
*************** fndef:
*** 462,470 ****
  					all_prefix_attributes))
  		    YYERROR1;
  		}
! 	  old_style_parm_decls save_filename save_lineno
! 		{ DECL_SOURCE_FILE (current_function_decl) = $5;
! 		  DECL_SOURCE_LINE (current_function_decl) = $6;
  		  store_parm_decls (); }
  	  compstmt_or_error
  		{ finish_function (0, 1);
--- 459,466 ----
  					all_prefix_attributes))
  		    YYERROR1;
  		}
! 	  old_style_parm_decls save_location
! 		{ DECL_SOURCE_LOCATION (current_function_decl) = $5;
  		  store_parm_decls (); }
  	  compstmt_or_error
  		{ finish_function (0, 1);
*************** old_style_parm_decls_1:
*** 805,811 ****
     except that they do not allow nested functions.
     They are used for old-style parm decls.  */
  lineno_datadecl:
! 	  save_filename save_lineno datadecl
  		{ }
  	;
  
--- 801,807 ----
     except that they do not allow nested functions.
     They are used for old-style parm decls.  */
  lineno_datadecl:
! 	  save_location datadecl
  		{ }
  	;
  
*************** datadecl:
*** 837,843 ****
     This is to avoid shift/reduce conflicts in contexts
     where statement labels are allowed.  */
  lineno_decl:
! 	  save_filename save_lineno decl
  		{ }
  	;
  
--- 833,839 ----
     This is to avoid shift/reduce conflicts in contexts
     where statement labels are allowed.  */
  lineno_decl:
! 	  save_location decl
  		{ }
  	;
  
*************** nested_function:
*** 1593,1602 ****
  		    }
  		  parsing_iso_function_signature = false; /* Don't warn about nested functions.  */
  		}
! 	   old_style_parm_decls save_filename save_lineno
  		{ tree decl = current_function_decl;
! 		  DECL_SOURCE_FILE (decl) = $4;
! 		  DECL_SOURCE_LINE (decl) = $5;
  		  store_parm_decls (); }
  /* This used to use compstmt_or_error.
     That caused a bug with input `f(g) int g {}',
--- 1589,1597 ----
  		    }
  		  parsing_iso_function_signature = false; /* Don't warn about nested functions.  */
  		}
! 	   old_style_parm_decls save_location
  		{ tree decl = current_function_decl;
! 		  DECL_SOURCE_LOCATION (decl) = $4;
  		  store_parm_decls (); }
  /* This used to use compstmt_or_error.
     That caused a bug with input `f(g) int g {}',
*************** notype_nested_function:
*** 1625,1634 ****
  		    }
  		  parsing_iso_function_signature = false; /* Don't warn about nested functions.  */
  		}
! 	  old_style_parm_decls save_filename save_lineno
  		{ tree decl = current_function_decl;
! 		  DECL_SOURCE_FILE (decl) = $4;
! 		  DECL_SOURCE_LINE (decl) = $5;
  		  store_parm_decls (); }
  /* This used to use compstmt_or_error.
     That caused a bug with input `f(g) int g {}',
--- 1620,1628 ----
  		    }
  		  parsing_iso_function_signature = false; /* Don't warn about nested functions.  */
  		}
! 	  old_style_parm_decls save_location
  		{ tree decl = current_function_decl;
! 		  DECL_SOURCE_LOCATION (decl) = $4;
  		  store_parm_decls (); }
  /* This used to use compstmt_or_error.
     That caused a bug with input `f(g) int g {}',
*************** if_prefix:
*** 2233,2240 ****
  		{ c_expand_start_cond (c_common_truthvalue_conversion ($4),
  				       compstmt_count,$<ttype>2);
  		  $<itype>$ = stmt_count;
! 		  if_stmt_locus.file = $<filename>-2;
! 		  if_stmt_locus.line = $<lineno>-1; }
          ;
  
  /* This is a subroutine of stmt.
--- 2227,2233 ----
  		{ c_expand_start_cond (c_common_truthvalue_conversion ($4),
  				       compstmt_count,$<ttype>2);
  		  $<itype>$ = stmt_count;
! 		  if_stmt_locus = $<location>-1; }
          ;
  
  /* This is a subroutine of stmt.
*************** do_stmt_start:
*** 2259,2275 ****
  
  /* The forced readahead in here is because we might be at the end of a
     line, and the line and file won't be bumped until yylex absorbs the
!    first token on the next line.  */
! save_filename:
! 		{ if (yychar == YYEMPTY)
! 		    yychar = YYLEX;
! 		  $$ = input_filename; }
! 	;
  
! save_lineno:
  		{ if (yychar == YYEMPTY)
  		    yychar = YYLEX;
! 		  $$ = input_line; }
  	;
  
  lineno_labeled_stmt:
--- 2252,2263 ----
  
  /* The forced readahead in here is because we might be at the end of a
     line, and the line and file won't be bumped until yylex absorbs the
!    first token on the next line. Must be balanced with a call to unsave_loc */
  
! save_location:
  		{ if (yychar == YYEMPTY)
  		    yychar = YYLEX;
! 		  $$ = input_location; }
  	;
  
  lineno_labeled_stmt:
*************** c99_block_lineno_labeled_stmt:
*** 2285,2294 ****
  	;
  
  lineno_stmt:
! 	  save_filename save_lineno stmt
! 		{ if ($3)
  		    {
! 		      STMT_LINENO ($3) = $2;
  		      /* ??? We currently have no way of recording
  			 the filename for a statement.  This probably
  			 matters little in practice at the moment,
--- 2273,2282 ----
  	;
  
  lineno_stmt:
! 	  save_location stmt
! 		{ if ($2)
  		    {
! 		      STMT_LINENO ($2) = $1.line;
  		      /* ??? We currently have no way of recording
  			 the filename for a statement.  This probably
  			 matters little in practice at the moment,
*************** lineno_stmt:
*** 2299,2308 ****
  	;
  
  lineno_label:
! 	  save_filename save_lineno label
! 		{ if ($3)
  		    {
! 		      STMT_LINENO ($3) = $2;
  		    }
  		}
  	;
--- 2287,2296 ----
  	;
  
  lineno_label:
! 	  save_location label
! 		{ if ($2)
  		    {
! 		      STMT_LINENO ($2) = $1.line;
  		    }
  		}
  	;
*************** label:	  CASE expr_no_commas ':'
*** 2457,2468 ****
  	| DEFAULT ':'
                  { stmt_count++;
  		  $$ = do_case (NULL_TREE, NULL_TREE); }
! 	| identifier save_filename save_lineno ':' maybe_attribute
! 		{ tree label = define_label ($2, $3, $1);
  		  stmt_count++;
  		  if (label)
  		    {
! 		      decl_attributes (&label, $5, 0);
  		      $$ = add_stmt (build_stmt (LABEL_STMT, label));
  		    }
  		  else
--- 2445,2456 ----
  	| DEFAULT ':'
                  { stmt_count++;
  		  $$ = do_case (NULL_TREE, NULL_TREE); }
! 	| identifier save_location ':' maybe_attribute
! 		{ tree label = define_label ($2.file, $2.line, $1);
  		  stmt_count++;
  		  if (label)
  		    {
! 		      decl_attributes (&label, $4, 0);
  		      $$ = add_stmt (build_stmt (LABEL_STMT, label));
  		    }
  		  else

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