This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gfortran] Fix line number debug info


gfc_trans_code had a mildly subtle error: we set the global source location at
the beginning of the function, then generated code, and then set the location
of the statement from the global variable. Unfortunately, gfc_trans_code is
recursive in the case of statements which are followed by blocks, i.e. IF, DO,
SELECT. Their location would then of course be set to that of the last
statement in their respective blocks.

This is turn messed up objdump, and maybe debugging, I haven't yet
investigated if that goes better now.

Built and tested with no regressions. Ok?

- Tobi

2004-10-07  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>

	* trans.c (gfc_trans_code): Set global locus after recursing. Fix
	comment typo.
Index: trans.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans.c,v
retrieving revision 1.18
diff -u -p -r1.18 trans.c
--- trans.c	17 Sep 2004 21:54:57 -0000	1.18
+++ trans.c	7 Oct 2004 23:02:08 -0000
@@ -479,8 +479,6 @@ gfc_trans_code (gfc_code * code)
      the end of this gfc_code branch.  */
   for (; code; code = code->next)
     {
-      gfc_set_backend_locus (&code->loc);
-
       if (code->here != 0)
 	{
 	  res = gfc_trans_label_here (code);
@@ -625,14 +623,16 @@ gfc_trans_code (gfc_code * code)
 	  internal_error ("gfc_trans_code(): Bad statement code");
 	}
 
+      gfc_set_backend_locus (&code->loc);
+
       if (res != NULL_TREE && ! IS_EMPTY_STMT (res))
 	{
 	  if (TREE_CODE (res) == STATEMENT_LIST)
 	    annotate_all_with_locus (&res, input_location);
 	  else
 	    SET_EXPR_LOCATION (res, input_location);
-
-	  /* Add the new statemment to the block.  */
+	    
+	  /* Add the new statement to the block.  */
 	  gfc_add_expr_to_block (&block, res);
 	}
     }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]