[backport from gcc-4.7.2 r189087 ] From: Eric Botcazou Subject: Fix oversight during try-finally lowering Date: Sat, 30 Jun 2012 00:34:10 +0200 List-Archive: 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. gcc/ 2012-06-29 Eric Botcazou * tree-eh.c (lower_try_finally_switch): Really put the location of the last statement of the finally block onto the switch. --- gcc-4.6.3/gcc/tree-eh.c.~1~ 2011-07-05 20:44:32.000000000 +0200 +++ gcc-4.6.3/gcc/tree-eh.c 2012-08-11 17:55:33.000000000 +0200 @@ -1305,9 +1305,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);