diff mbox

[Fortran] PR 41359 - fix debug line for IF conditions

Message ID 4D636C64.5020304@net-b.de
State New
Headers show

Commit Message

Tobias Burnus Feb. 22, 2011, 7:57 a.m. UTC
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.

Comments

Paul Richard Thomas Feb. 22, 2011, 10:12 a.m. UTC | #1
Dear Tobias,

This is OK - thanks for the patch.

Cheers

Paul

On Tue, Feb 22, 2011 at 8:57 AM, Tobias Burnus <burnus@net-b.de> wrote:
> 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.
>
diff mbox

Patch

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