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 oversight during try-finally lowering


It pertains to the source location assigned to the finally switch: the comment 
in lower_try_finally_switch reads:

   /* The location of the finally is either the last stmt in the finally
      block or the location of the TRY_FINALLY itself.  */

but the code reads:

  finally_loc = gimple_seq_last_stmt (tf->top_p_seq) != NULL ?
    gimple_location (gimple_seq_last_stmt (tf->top_p_seq))
    : tf_loc;

so it uses the location of last stmt of the eval block.  Needless to say that 
this seriously screws up the coverage of the construct: the last stmt of the 
eval block is always reported as covered!

Fixed thusly, tested on x86_64-suse-linux, applied on the mainline as obvious.
This isn't a recent regression, but I took the liberty to put it on the 4.7 
branch as well.


2012-06-29  Eric Botcazou  <ebotcazou@adacore.com>

	* tree-eh.c (lower_try_finally_switch): Really put the location of the
	last statement of the finally block onto the switch.


-- 
Eric Botcazou
Index: tree-eh.c
===================================================================
--- tree-eh.c	(revision 189034)
+++ tree-eh.c	(working copy)
@@ -1320,9 +1320,8 @@ lower_try_finally_switch (struct leh_sta
 
   /* The location of the finally is either the last stmt in the finally
      block or the location of the TRY_FINALLY itself.  */
-  finally_loc = gimple_seq_last_stmt (tf->top_p_seq) != NULL ?
-    gimple_location (gimple_seq_last_stmt (tf->top_p_seq))
-    : tf_loc;
+  x = gimple_seq_last_stmt (finally);
+  finally_loc = x ? gimple_location (x) : tf_loc;
 
   /* Lower the finally block itself.  */
   lower_eh_constructs_1 (state, &finally);

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