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]

[tree-ssa] fix warnings at end of function


This fixes a lot of tests which expected warnings at the end of
the function, rather than the beginning.  For things like
"function returns without value", frankly that's the placement
that I'd expect.

I also expect, but did not verify, that it'll get debugging correct
for the epilogue.

This may also allow clean up a bit in Java wherein we temporarily
encode both the start and end of the function into the same locus.
I'll take care of that with a separate patch.


r~


        * function.h (struct function): Add function_end_locus.
        * c-decl.c (finish_function): Set it.
        * tree-optimize.c (tree_rest_of_compilation): Set input_location
        to function_end_locus before expand_function_end.
cp/
        * decl.c (finish_function): Set cfun->function_end_locus.

Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.334.2.64
diff -c -p -d -r1.334.2.64 c-decl.c
*** c-decl.c	28 Sep 2003 06:06:03 -0000	1.334.2.64
--- c-decl.c	30 Sep 2003 21:16:22 -0000
*************** finish_function ()
*** 6094,6099 ****
--- 6094,6103 ----
        && current_function_returns_null)
      warning ("this function may return with or without a value");
  
+   /* Store the end of the function, so that we get good line number
+      info for the epilogue.  */
+   cfun->function_end_locus = input_location;
+ 
    /* Genericize before inlining.  */
    if (!flag_disable_gimple)
      c_genericize (fndecl);
Index: function.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.h,v
retrieving revision 1.83.2.13
diff -c -p -d -r1.83.2.13 function.h
*** function.h	2 Sep 2003 21:01:38 -0000	1.83.2.13
--- function.h	30 Sep 2003 21:16:23 -0000
*************** struct function GTY(())
*** 406,411 ****
--- 406,414 ----
       final flowgraph size.  */
    int max_jumptable_ents;
  
+   /* Line number of the end of the function.  */
+   location_t function_end_locus;
+ 
    /* Collected bit flags.  */
  
    /* Nonzero if function being compiled needs to be given an address
Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 1.1.4.53
diff -c -p -d -r1.1.4.53 tree-optimize.c
*** tree-optimize.c	30 Sep 2003 21:11:29 -0000	1.1.4.53
--- tree-optimize.c	30 Sep 2003 21:16:23 -0000
*************** tree_rest_of_compilation (tree fndecl, b
*** 339,344 ****
--- 339,349 ----
       zero.  */
    immediate_size_expand = 1;
  
+   /* Make sure the locus is set to the end of the function, so that 
+      epilogue line numbers and warnings are set properly.  */
+   if (cfun->function_end_locus.file)
+     input_location = cfun->function_end_locus;
+ 
    /* Allow language dialects to perform special processing.  */
    (*lang_hooks.rtl_expand.end) ();
  
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.911.2.46
diff -c -p -d -r1.911.2.46 decl.c
*** cp/decl.c	28 Sep 2003 06:07:24 -0000	1.911.2.46
--- cp/decl.c	30 Sep 2003 21:16:35 -0000
*************** finish_function (int flags)
*** 14047,14052 ****
--- 14047,14056 ----
        && (DECL_INLINE (fndecl) || processing_template_decl))
      warning ("no return statement in function returning non-void");
  
+   /* Store the end of the function, so that we get good line number
+      info for the epilogue.  */
+   cfun->function_end_locus = input_location;
+ 
    /* Genericize before inlining.  */
    if (!flag_disable_gimple && !processing_template_decl)
      c_genericize (fndecl);


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