http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41359
--- Comment #9 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-02-21
21:47:59 UTC ---
I think the current gcov output is OK:
1: 1:program main
-: 2: implicit none
-: 3: integer :: a = 7
1: 4: if( a == 0 ) then
#####: 5: print *, "a is null"
1: 6: else if( a > 0 ) then
1: 7: print *, "a is positif"
-: 8: else
#####: 9: print *, "a is negatif"
-: 10: end if
2: 11:end program
Though the following is still partially wrong:
[foo.f90 : 6] if ([foo.f90 : 5] a > 0)
With patch:
[foo.f90 : 6] if ([foo.f90 : 6] a > 0)
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -718,6 +718,7 @@ gfc_trans_if_1 (gfc_code * code)
{
gfc_se if_se;
tree stmt, elsestmt;
+ locus saved_loc;
location_t loc;
/* Check for an unconditional ELSE clause. */
@@ -729,7 +730,10 @@ gfc_trans_if_1 (gfc_code * code)
gfc_start_block (&if_se.pre);
/* Calculate the IF condition expression. */
+ gfc_save_backend_locus (&saved_loc);
+ gfc_set_backend_locus (&code->expr1->where);
gfc_conv_expr_val (&if_se, code->expr1);
+ gfc_restore_backend_locus (&saved_loc);
/* Translate the THEN clause. */
stmt = gfc_trans_code (code->next);