This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, Fortran] PR 41359 - fix debug line for IF conditions
- From: Tobias Burnus <burnus at net-b dot de>
- To: gfortran pa <fortran at gcc dot gnu dot org>, gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 22 Feb 2011 08:57:24 +0100
- Subject: [Patch, Fortran] PR 41359 - fix debug line for IF conditions
The patch corrects the line of the IF conditions; the line of the IF
itself is already correct. See PR for an example.
Without patch (-fdump-tree-original-lineno):
[foo.f90 : 6] if ([foo.f90 : 5] a> 0)
with patch
[foo.f90 : 6] if ([foo.f90 : 6] a> 0)
Build and regtested on x86-64-linux.
OK?
Tobias
PS: Without the where.lb condition, it segfaults for pointer_check_8.f90.
2011-02-22 Tobias Burnus <burnus@net-b.de>
PR fortran/41359
* trans-stmt.c (gfc_trans_if_1): Use correct line for
expressions in the if condition.
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index 6ddb2ca..e120285 100644
--- 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,8 +730,17 @@ gfc_trans_if_1 (gfc_code * code)
gfc_start_block (&if_se.pre);
/* Calculate the IF condition expression. */
+ if (code->expr1->where.lb)
+ {
+ gfc_save_backend_locus (&saved_loc);
+ gfc_set_backend_locus (&code->expr1->where);
+ }
+
gfc_conv_expr_val (&if_se, code->expr1);
+ if (code->expr1->where.lb)
+ gfc_restore_backend_locus (&saved_loc);
+
/* Translate the THEN clause. */
stmt = gfc_trans_code (code->next);