Patchwork Fix oversight during try-finally lowering

login
register
mail settings
Submitter Eric Botcazou
Date June 29, 2012, 10:34 p.m.
Message ID <201206300034.10660.ebotcazou@adacore.com>
Download mbox | patch
Permalink /patch/168269/
State New
Headers show

Comments

Eric Botcazou - June 29, 2012, 10:34 p.m.
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.

Patch

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);