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]

[C patch]: set function's location


Hi,
this patch tweaks the grammar so that a function definition's location is
updated slightly earlier.

This change will make it possible for init_function to simply use
the function decl's location rather than being passed a location.

booted and 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-05-09  Nathan Sidwell  <nathan@codesourcery.com>

	* c-parse.in (fndef): Set DECL_SOURCE_LINE and FILE earlier.
	(nested_function): Likewise.
	(notype_nested_function): Likewise.

Index: c-parse.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-parse.in,v
retrieving revision 1.157
diff -c -3 -p -r1.157 c-parse.in
*** c-parse.in	1 May 2003 16:13:27 -0000	1.157
--- c-parse.in	9 May 2003 19:40:41 -0000
*************** fndef:
*** 434,445 ****
  					all_prefix_attributes))
  		    YYERROR1;
  		}
! 	  old_style_parm_decls
! 		{ store_parm_decls (); }
! 	  save_filename save_lineno compstmt_or_error
! 		{ DECL_SOURCE_FILE (current_function_decl) = $7;
! 		  DECL_SOURCE_LINE (current_function_decl) = $8;
! 		  finish_function (0, 1);
  		  POP_DECLSPEC_STACK; }
  	| declspecs_ts setspecs declarator error
  		{ POP_DECLSPEC_STACK; }
--- 434,445 ----
  					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
  		{ POP_DECLSPEC_STACK; }
*************** fndef:
*** 448,459 ****
  					all_prefix_attributes))
  		    YYERROR1;
  		}
! 	  old_style_parm_decls
! 		{ store_parm_decls (); }
! 	  save_filename save_lineno compstmt_or_error
! 		{ DECL_SOURCE_FILE (current_function_decl) = $7;
! 		  DECL_SOURCE_LINE (current_function_decl) = $8;
! 		  finish_function (0, 1);
  		  POP_DECLSPEC_STACK; }
  	| declspecs_nots setspecs notype_declarator error
  		{ POP_DECLSPEC_STACK; }
--- 448,459 ----
  					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_nots setspecs notype_declarator error
  		{ POP_DECLSPEC_STACK; }
*************** fndef:
*** 462,473 ****
  					all_prefix_attributes))
  		    YYERROR1;
  		}
! 	  old_style_parm_decls
! 		{ store_parm_decls (); }
! 	  save_filename save_lineno compstmt_or_error
! 		{ DECL_SOURCE_FILE (current_function_decl) = $6;
! 		  DECL_SOURCE_LINE (current_function_decl) = $7;
! 		  finish_function (0, 1);
  		  POP_DECLSPEC_STACK; }
  	| setspecs notype_declarator error
  		{ POP_DECLSPEC_STACK; }
--- 462,473 ----
  					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);
  		  POP_DECLSPEC_STACK; }
  	| setspecs notype_declarator error
  		{ POP_DECLSPEC_STACK; }
*************** nested_function:
*** 1593,1610 ****
  		    }
  		  parsing_iso_function_signature = false; /* Don't warn about nested functions.  */
  		}
! 	   old_style_parm_decls
! 		{ store_parm_decls (); }
  /* This used to use compstmt_or_error.
     That caused a bug with input `f(g) int g {}',
     where the use of YYERROR1 above caused an error
     which then was handled by compstmt_or_error.
     There followed a repeated execution of that same rule,
     which called YYERROR1 again, and so on.  */
! 	  save_filename save_lineno compstmt
  		{ tree decl = current_function_decl;
- 		  DECL_SOURCE_FILE (decl) = $5;
- 		  DECL_SOURCE_LINE (decl) = $6;
  		  finish_function (1, 1);
  		  pop_function_context ();
  		  add_decl_stmt (decl); }
--- 1593,1611 ----
  		    }
  		  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 {}',
     where the use of YYERROR1 above caused an error
     which then was handled by compstmt_or_error.
     There followed a repeated execution of that same rule,
     which called YYERROR1 again, and so on.  */
! 	  compstmt
  		{ tree decl = current_function_decl;
  		  finish_function (1, 1);
  		  pop_function_context ();
  		  add_decl_stmt (decl); }
*************** notype_nested_function:
*** 1624,1641 ****
  		    }
  		  parsing_iso_function_signature = false; /* Don't warn about nested functions.  */
  		}
! 	  old_style_parm_decls
! 		{ store_parm_decls (); }
  /* This used to use compstmt_or_error.
     That caused a bug with input `f(g) int g {}',
     where the use of YYERROR1 above caused an error
     which then was handled by compstmt_or_error.
     There followed a repeated execution of that same rule,
     which called YYERROR1 again, and so on.  */
! 	  save_filename save_lineno compstmt
  		{ tree decl = current_function_decl;
- 		  DECL_SOURCE_FILE (decl) = $5;
- 		  DECL_SOURCE_LINE (decl) = $6;
  		  finish_function (1, 1);
  		  pop_function_context ();
  		  add_decl_stmt (decl); }
--- 1625,1643 ----
  		    }
  		  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 {}',
     where the use of YYERROR1 above caused an error
     which then was handled by compstmt_or_error.
     There followed a repeated execution of that same rule,
     which called YYERROR1 again, and so on.  */
! 	  compstmt
  		{ tree decl = current_function_decl;
  		  finish_function (1, 1);
  		  pop_function_context ();
  		  add_decl_stmt (decl); }

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