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]: start using location_t directly


Hi,
I've installed this obvious patch which starts using location_t as
an opaque type in the C directory. Again, this patch changes no interfaces.

booted & tested on i686-pc-linux-gnu.

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
         The voices in my head said this was stupid too
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org

2003-05-03  Nathan Sidwell  <nathan@codesourcery.com>

	* c-decl.c (pending_invalid_xref_file): Remove.
	(pending_invalid_xref_line): Remove.
	(pending_invalid_xref_location): New.
	(lookup_label): Use location_t and input_location directly.
	(lookup_tag): Likewise.
	(pending_xref_error): Likewise.
	(c_expand_body_1): Likewise.
	* c-common.c (x_expand_start_cond): Likewise.
	* c-semantics.c (genrtl_for_stmt): Likewise.
	(find_reachable_label): Likewise.
	* expr.c (expand_expr): Likewise.
	* integrate.c (output_inline_function): Likewise.
	* tree-inline.c (find_alloca_call): Likewise.
	(find_builtin_longjmp_call): Likewise.
	* gcc.c (input_filename): Make static.
	
Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.412
diff -c -3 -p -r1.412 c-common.c
*** c-common.c	1 May 2003 16:13:23 -0000	1.412
--- c-common.c	3 May 2003 11:51:15 -0000
*************** c_expand_start_cond (cond, compstmt_coun
*** 918,925 ****
  
    /* Record this if statement.  */
    if_stack[if_stack_pointer].compstmt_count = compstmt_count;
!   if_stack[if_stack_pointer].locus.file = input_filename;
!   if_stack[if_stack_pointer].locus.line = input_line;
    if_stack[if_stack_pointer].needs_warning = 0;
    if_stack[if_stack_pointer].if_stmt = if_stmt;
    if_stack_pointer++;
--- 918,924 ----
  
    /* Record this if statement.  */
    if_stack[if_stack_pointer].compstmt_count = compstmt_count;
!   if_stack[if_stack_pointer].locus = input_location;
    if_stack[if_stack_pointer].needs_warning = 0;
    if_stack[if_stack_pointer].if_stmt = if_stmt;
    if_stack_pointer++;
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.384
diff -c -3 -p -r1.384 c-decl.c
*** c-decl.c	1 May 2003 16:13:24 -0000	1.384
--- c-decl.c	3 May 2003 11:51:30 -0000
*************** enum decl_context
*** 65,72 ****
  
  tree pending_invalid_xref;
  /* File and line to appear in the eventual error message.  */
! const char *pending_invalid_xref_file;
! int pending_invalid_xref_line;
  
  /* While defining an enum type, this is 1 plus the last enumerator
     constant value.  Note that will do not have to save this or `enum_overflow'
--- 65,71 ----
  
  tree pending_invalid_xref;
  /* File and line to appear in the eventual error message.  */
! location_t pending_invalid_xref_location;
  
  /* While defining an enum type, this is 1 plus the last enumerator
     constant value.  Note that will do not have to save this or `enum_overflow'
*************** lookup_label (id)
*** 2019,2026 ****
  
    /* Say where one reference is to the label,
       for the sake of the error if it is not defined.  */
!   DECL_SOURCE_LINE (decl) = input_line;
!   DECL_SOURCE_FILE (decl) = input_filename;
  
    IDENTIFIER_LABEL_VALUE (id) = decl;
  
--- 2018,2024 ----
  
    /* Say where one reference is to the label,
       for the sake of the error if it is not defined.  */
!   DECL_SOURCE_LOCATION (decl) = input_location;
  
    IDENTIFIER_LABEL_VALUE (id) = decl;
  
*************** lookup_tag (code, name, thislevel_only)
*** 2183,2190 ****
      {
        /* Definition isn't the kind we were looking for.  */
        pending_invalid_xref = name;
!       pending_invalid_xref_file = input_filename;
!       pending_invalid_xref_line = input_line;
  
        /* If in the same binding level as a declaration as a tag
  	 of a different type, this must not be allowed to
--- 2181,2187 ----
      {
        /* Definition isn't the kind we were looking for.  */
        pending_invalid_xref = name;
!       pending_invalid_xref_location = input_location;
  
        /* If in the same binding level as a declaration as a tag
  	 of a different type, this must not be allowed to
*************** void
*** 2205,2212 ****
  pending_xref_error ()
  {
    if (pending_invalid_xref != 0)
!     error_with_file_and_line (pending_invalid_xref_file,
! 			      pending_invalid_xref_line,
  			      "`%s' defined as wrong kind of tag",
  			      IDENTIFIER_POINTER (pending_invalid_xref));
    pending_invalid_xref = 0;
--- 2202,2209 ----
  pending_xref_error ()
  {
    if (pending_invalid_xref != 0)
!     error_with_file_and_line (pending_invalid_xref_location.file,
! 			      pending_invalid_xref_location.line,
  			      "`%s' defined as wrong kind of tag",
  			      IDENTIFIER_POINTER (pending_invalid_xref));
    pending_invalid_xref = 0;
*************** c_expand_body_1 (fndecl, nested_p)
*** 6337,6345 ****
  
    /* Initialize the RTL code for the function.  */
    current_function_decl = fndecl;
!   input_filename = DECL_SOURCE_FILE (fndecl);
    init_function_start (fndecl, input_filename, DECL_SOURCE_LINE (fndecl));
-   input_line = DECL_SOURCE_LINE (fndecl);
  
    /* This function is being processed in whole-function mode.  */
    cfun->x_whole_function_mode_p = 1;
--- 6334,6341 ----
  
    /* Initialize the RTL code for the function.  */
    current_function_decl = fndecl;
!   input_location = DECL_SOURCE_LOCATION (fndecl);
    init_function_start (fndecl, input_filename, DECL_SOURCE_LINE (fndecl));
  
    /* This function is being processed in whole-function mode.  */
    cfun->x_whole_function_mode_p = 1;
Index: c-semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-semantics.c,v
retrieving revision 1.57
diff -c -3 -p -r1.57 c-semantics.c
*** c-semantics.c	1 May 2003 16:13:28 -0000	1.57
--- c-semantics.c	3 May 2003 11:51:33 -0000
*************** genrtl_for_stmt (t)
*** 542,549 ****
       tree t;
  {
    tree cond = FOR_COND (t);
!   const char *saved_filename;
!   int saved_lineno;
  
    if (NEW_FOR_SCOPE_P (t))
      genrtl_do_pushlevel ();
--- 542,548 ----
       tree t;
  {
    tree cond = FOR_COND (t);
!   location_t saved_loc;
  
    if (NEW_FOR_SCOPE_P (t))
      genrtl_do_pushlevel ();
*************** genrtl_for_stmt (t)
*** 561,568 ****
  
    /* Save the filename and line number so that we expand the FOR_EXPR
       we can reset them back to the saved values.  */
!   saved_filename = input_filename;
!   saved_lineno = input_line;
  
    /* Expand the condition.  */
    if (cond && !integer_nonzerop (cond))
--- 560,566 ----
  
    /* Save the filename and line number so that we expand the FOR_EXPR
       we can reset them back to the saved values.  */
!   saved_loc = input_location;
  
    /* Expand the condition.  */
    if (cond && !integer_nonzerop (cond))
*************** genrtl_for_stmt (t)
*** 577,584 ****
    expand_stmt (FOR_BODY (t));
  
    /* Expand the increment expression.  */
!   input_filename = saved_filename;
!   input_line = saved_lineno;
    emit_line_note (input_filename, input_line);
    if (FOR_EXPR (t))
      {
--- 575,581 ----
    expand_stmt (FOR_BODY (t));
  
    /* Expand the increment expression.  */
!   input_location = saved_loc;
    emit_line_note (input_filename, input_line);
    if (FOR_EXPR (t))
      {
*************** static tree
*** 951,961 ****
  find_reachable_label (exp)
       tree exp;
  {
!   int line = input_line;
!   const char *file = input_filename;
    tree ret = walk_tree (&exp, find_reachable_label_1, NULL, NULL);
!   input_filename = file;
!   input_line = line;
    return ret;
  }
  
--- 948,956 ----
  find_reachable_label (exp)
       tree exp;
  {
!   location_t saved_loc = input_location;
    tree ret = walk_tree (&exp, find_reachable_label_1, NULL, NULL);
!   input_location = saved_loc;
    return ret;
  }
  
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.531
diff -c -3 -p -r1.531 expr.c
*** expr.c	1 May 2003 16:13:28 -0000	1.531
--- expr.c	3 May 2003 11:51:54 -0000
*************** expand_expr (exp, target, tmode, modifie
*** 6932,6947 ****
      case EXPR_WITH_FILE_LOCATION:
        {
  	rtx to_return;
! 	const char *saved_input_filename = input_filename;
! 	int saved_lineno = input_line;
  	input_filename = EXPR_WFL_FILENAME (exp);
  	input_line = EXPR_WFL_LINENO (exp);
  	if (EXPR_WFL_EMIT_LINE_NOTE (exp))
  	  emit_line_note (input_filename, input_line);
  	/* Possibly avoid switching back and forth here.  */
  	to_return = expand_expr (EXPR_WFL_NODE (exp), target, tmode, modifier);
! 	input_filename = saved_input_filename;
! 	input_line = saved_lineno;
  	return to_return;
        }
  
--- 6932,6945 ----
      case EXPR_WITH_FILE_LOCATION:
        {
  	rtx to_return;
! 	location_t saved_loc = input_location;
  	input_filename = EXPR_WFL_FILENAME (exp);
  	input_line = EXPR_WFL_LINENO (exp);
  	if (EXPR_WFL_EMIT_LINE_NOTE (exp))
  	  emit_line_note (input_filename, input_line);
  	/* Possibly avoid switching back and forth here.  */
  	to_return = expand_expr (EXPR_WFL_NODE (exp), target, tmode, modifier);
! 	input_location = saved_loc;
  	return to_return;
        }
  
Index: gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.372
diff -c -3 -p -r1.372 gcc.c
*** gcc.c	29 Apr 2003 14:16:37 -0000	1.372
--- gcc.c	3 May 2003 11:52:08 -0000
*************** set_collect_gcc_options ()
*** 4150,4156 ****
     sans all directory names, and basename_length is the number
     of characters starting there excluding the suffix .c or whatever.  */
  
! const char *input_filename;
  static int input_file_number;
  size_t input_filename_length;
  static int basename_length;
--- 4150,4156 ----
     sans all directory names, and basename_length is the number
     of characters starting there excluding the suffix .c or whatever.  */
  
! static const char *input_filename;
  static int input_file_number;
  size_t input_filename_length;
  static int basename_length;
Index: integrate.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/integrate.c,v
retrieving revision 1.218
diff -c -3 -p -r1.218 integrate.c
*** integrate.c	1 May 2003 16:13:28 -0000	1.218
--- integrate.c	3 May 2003 11:52:16 -0000
*************** output_inline_function (fndecl)
*** 3040,3047 ****
  
    /* Make sure warnings emitted by the optimizers (e.g. control reaches
       end of non-void function) is not wildly incorrect.  */
!   input_filename = DECL_SOURCE_FILE (fndecl);
!   input_line = DECL_SOURCE_LINE (fndecl);
  
    /* Compile this function all the way down to assembly code.  As a
       side effect this destroys the saved RTL representation, but
--- 3040,3046 ----
  
    /* Make sure warnings emitted by the optimizers (e.g. control reaches
       end of non-void function) is not wildly incorrect.  */
!   input_location = DECL_SOURCE_LOCATION (fndecl);
  
    /* Compile this function all the way down to assembly code.  As a
       side effect this destroys the saved RTL representation, but
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.749
diff -c -3 -p -r1.749 toplev.c
*** toplev.c	2 May 2003 11:33:03 -0000	1.749
--- toplev.c	3 May 2003 11:52:27 -0000
*************** check_global_declarations (vec, len)
*** 2130,2138 ****
      }
  }
  
! /* Save the current INPUT_FILENAME and LINENO on the top entry in the
     INPUT_FILE_STACK.  Push a new entry for FILE and LINE, and set the
!    INPUT_FILENAME and LINENO accordingly.  */
  
  void
  push_srcloc (file, line)
--- 2130,2138 ----
      }
  }
  
! /* Save the current INPUT_LOCATION on the top entry in the
     INPUT_FILE_STACK.  Push a new entry for FILE and LINE, and set the
!    INPUT_LOCATION accordingly.  */
  
  void
  push_srcloc (file, line)
*************** push_srcloc (file, line)
*** 2154,2161 ****
  }
  
  /* Pop the top entry off the stack of presently open source files.
!    Restore the INPUT_FILENAME and LINENO from the new topmost entry on
!    the stack.  */
  
  void
  pop_srcloc ()
--- 2154,2161 ----
  }
  
  /* Pop the top entry off the stack of presently open source files.
!    Restore the INPUT_LOCATION from the new topmost entry on the
!    stack.  */
  
  void
  pop_srcloc ()
Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.57
diff -c -3 -p -r1.57 tree-inline.c
*** tree-inline.c	1 May 2003 16:13:29 -0000	1.57
--- tree-inline.c	3 May 2003 11:52:31 -0000
*************** static tree
*** 900,910 ****
  find_alloca_call (exp)
       tree exp;
  {
!   int line = input_line;
!   const char *file = input_filename;
    tree ret = walk_tree (&exp, find_alloca_call_1, NULL, NULL);
!   input_line = line;
!   input_filename = file;
    return ret;
  }
  
--- 900,908 ----
  find_alloca_call (exp)
       tree exp;
  {
!   location_t saved_loc = input_location;
    tree ret = walk_tree (&exp, find_alloca_call_1, NULL, NULL);
!   input_location = saved_loc;
    return ret;
  }
  
*************** static tree
*** 931,941 ****
  find_builtin_longjmp_call (exp)
       tree exp;
  {
!   int line = input_line;
!   const char *file = input_filename;
    tree ret = walk_tree (&exp, find_builtin_longjmp_call_1, NULL, NULL);
!   input_line = line;
!   input_filename = file;
    return ret;
  }
  
--- 929,937 ----
  find_builtin_longjmp_call (exp)
       tree exp;
  {
!   location_t saved_loc = input_location;
    tree ret = walk_tree (&exp, find_builtin_longjmp_call_1, NULL, NULL);
!   input_location = saved_loc;
    return ret;
  }
  

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