At the end of gfc_trans_code one finds the following:
gfc_set_backend_locus (&code->loc); if (res != NULL_TREE && ! IS_EMPTY_STMT (res)) { if (TREE_CODE (res) != STATEMENT_LIST) SET_EXPR_LOCATION (res, input_location); /* Add the new statement to the block. */ gfc_add_expr_to_block (&block, res); } } /* Return the finished block. */ return gfc_finish_block (&block); } In principle the call to SET_EXPR_LOCATION should not be needed here, since the location should already be set correctly at this point; cf. the discussion in http://gcc.gnu.org/ml/fortran/2009-10/msg00205.html and follow-ups. However, this patch Index: gcc/fortran/trans.c =================================================================== --- gcc/fortran/trans.c (Revision 153547) +++ gcc/fortran/trans.c (Arbeitskopie) @@ -1281,9 +1281,6 @@ gfc_trans_code (gfc_code * code) if (res != NULL_TREE && ! IS_EMPTY_STMT (res)) { - if (TREE_CODE (res) != STATEMENT_LIST) - SET_EXPR_LOCATION (res, input_location); - /* Add the new statement to the block. */ gfc_add_expr_to_block (&block, res); } yields (at least) the following regressions: FAIL: gfortran.dg/gomp/appendix-a/a.24.1.f90 -O (test for errors, line 20) FAIL: gfortran.dg/gomp/appendix-a/a.24.1.f90 -O (test for errors, line 14) FAIL: gfortran.dg/gomp/appendix-a/a.24.1.f90 -O (test for errors, line 20) FAIL: gfortran.dg/gomp/appendix-a/a.24.1.f90 -O (test for excess errors) FAIL: gfortran.dg/gomp/appendix-a/a.35.1.f90 -O (test for warnings, line 13) FAIL: gfortran.dg/gomp/appendix-a/a.35.1.f90 -O (test for excess errors) FAIL: gfortran.dg/gomp/appendix-a/a.35.3.f90 -O (test for warnings, line 10) FAIL: gfortran.dg/gomp/appendix-a/a.35.3.f90 -O (test for excess errors) FAIL: gfortran.dg/gomp/appendix-a/a.35.4.f90 -O (test for warnings, line 11) FAIL: gfortran.dg/gomp/appendix-a/a.35.4.f90 -O (test for excess errors) FAIL: gfortran.dg/gomp/appendix-a/a.35.6.f90 -O (test for warnings, line 9) FAIL: gfortran.dg/gomp/appendix-a/a.35.6.f90 -O (test for excess errors) FAIL: gfortran.dg/gomp/block-1.f90 -O (test for errors, line 5) FAIL: gfortran.dg/gomp/block-1.f90 -O (test for excess errors) FAIL: gfortran.dg/gomp/crayptr3.f90 -O (test for errors, line 19) FAIL: gfortran.dg/gomp/crayptr3.f90 -O (test for errors, line 20) FAIL: gfortran.dg/gomp/crayptr3.f90 -O (test for excess errors) FAIL: gfortran.dg/gomp/pr33439.f90 -O (test for errors, line 8) FAIL: gfortran.dg/gomp/pr33439.f90 -O (test for errors, line 10) FAIL: gfortran.dg/gomp/pr33439.f90 -O (test for errors, line 21) FAIL: gfortran.dg/gomp/pr33439.f90 -O (test for errors, line 22) FAIL: gfortran.dg/gomp/pr33439.f90 -O (test for errors, line 33) FAIL: gfortran.dg/gomp/pr33439.f90 -O (test for excess errors) FAIL: gfortran.dg/gomp/sharing-1.f90 -O (test for errors, line 12) FAIL: gfortran.dg/gomp/sharing-1.f90 -O (test for errors, line 24) FAIL: gfortran.dg/gomp/sharing-1.f90 -O (test for errors, line 25) FAIL: gfortran.dg/gomp/sharing-1.f90 -O (test for errors, line 26) FAIL: gfortran.dg/gomp/sharing-1.f90 -O (test for excess errors) FAIL: gfortran.dg/gomp/sharing-2.f90 -O (test for errors, line 12) FAIL: gfortran.dg/gomp/sharing-2.f90 -O (test for errors, line 16) FAIL: gfortran.dg/gomp/sharing-2.f90 -O (test for errors, line 57) FAIL: gfortran.dg/gomp/sharing-2.f90 -O (test for errors, line 58) FAIL: gfortran.dg/gomp/sharing-2.f90 -O (test for errors, line 64) FAIL: gfortran.dg/gomp/sharing-2.f90 -O (test for errors, line 65) FAIL: gfortran.dg/gomp/sharing-2.f90 -O (test for excess errors) FAIL: gfortran.dg/gomp/sharing-3.f90 -O (test for errors, line 28) FAIL: gfortran.dg/gomp/sharing-3.f90 -O (test for errors, line 30) FAIL: gfortran.dg/gomp/sharing-3.f90 -O (test for errors, line 33) FAIL: gfortran.dg/gomp/sharing-3.f90 -O (test for errors, line 34) FAIL: gfortran.dg/gomp/sharing-3.f90 -O (test for excess errors) One should find out for which kind of statements the SET_EXPR_LOCATION is actually needed, and fix those in an appropriate way. -- Summary: [Cleanup] Remove SET_EXPR_LOCATION in gfc_trans_code Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: janus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41827