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]

fix input_location around t_r_o_c


The problem can be seen with 

======
/* { dg-do compile } */
/* { dg-options "" } */
/* Test that "test" gets associated with the correct file after
   queuing and emitting "foo" out of turn.  */
# 1 "foo.c"
static inline int foo(void) { return 0; }
# 8 "test.c"
void* bar(void)
{
  return foo;
}
void test(void)
{
  return 0; /* { dg-warning "function returning void" } */
}
=====

both in the warning message and in the debug info for test.  Except that
dg-warning doesn't actually look at the filename that the message appears
in, so the test passes no matter what.  I don't know how to write a test
that validates proper debug info.  Presumably this bug caused gdb test
failures, but I havn't verified that.

Anyway, the tricky bit here required to see the bug is that cgraph queue
a function from a different file, which we then compile.  That leaves us
in that foreign file when we come back.  We reaquire the correct line
number from cpplib immediately on the next token, so we never get out of
sync there.

Fixed thus.


r~


        * tree-optimize.c (tree_rest_of_compilation): Save and restore
        input_location.

        * semantics.c (expand_body): Don't save/restore input_location.

Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 2.2
diff -c -p -d -r2.2 tree-optimize.c
*** tree-optimize.c	8 Sep 2003 15:56:18 -0000	2.2
--- tree-optimize.c	18 Sep 2003 01:57:24 -0000
*************** clear_decl_rtl (tree *tp, int *walk_subt
*** 95,100 ****
--- 95,102 ----
  void
  tree_rest_of_compilation (tree fndecl, bool nested_p)
  {
+   location_t saved_loc;
+ 
    timevar_push (TV_EXPAND);
  
    if (flag_unit_at_a_time && !cgraph_global_info_ready)
*************** tree_rest_of_compilation (tree fndecl, b
*** 102,107 ****
--- 104,110 ----
  
    /* Initialize the RTL code for the function.  */
    current_function_decl = fndecl;
+   saved_loc = input_location;
    input_location = DECL_SOURCE_LOCATION (fndecl);
    init_function_start (fndecl);
  
*************** tree_rest_of_compilation (tree fndecl, b
*** 231,236 ****
--- 234,241 ----
  
        DECL_ARGUMENTS (fndecl) = 0;
      }
+ 
+   input_location = saved_loc;
  
    timevar_pop (TV_EXPAND);
  }
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.363
diff -c -p -d -r1.363 semantics.c
*** cp/semantics.c	17 Sep 2003 19:26:23 -0000	1.363
--- cp/semantics.c	18 Sep 2003 01:57:24 -0000
*************** emit_associated_thunks (tree fn)
*** 2845,2851 ****
  void
  expand_body (tree fn)
  {
-   location_t saved_loc;
    tree saved_function;
    
    /* Compute the appropriate object-file linkage for inline
--- 2845,2850 ----
*************** expand_body (tree fn)
*** 2862,2868 ****
      return;
  
    /* ??? When is this needed?  */
-   saved_loc = input_location;
    saved_function = current_function_decl;
  
    timevar_push (TV_INTEGRATION);
--- 2861,2866 ----
*************** expand_body (tree fn)
*** 2872,2878 ****
    tree_rest_of_compilation (fn, function_depth > 1);
  
    current_function_decl = saved_function;
-   input_location = saved_loc;
  
    extract_interface_info ();
  
--- 2870,2875 ----


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