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, committed] Re: Negative line numbers (PR 19195)


Erik Schnetter wrote:
> On Saturday 04 June 2005 19:31, Erik Schnetter wrote:
> 
>>I noticed that the functions gfc_{get,set}_backend_locus are not
>>inverses of each other.  One of them decrements the line number, the
>>other one does not increment it.  Could this be a problem?
> 
> 
> When I remove the "-1", the bug seems to go away.  I attached a 
> corresponding patch to the PR.  Is that a good way to suggest a patch?  
> I don't understand this piece of code, and I don't know whether just 
> removing the "-1" is even a good idea.

WRT your questions about where to post patches: if you post them in a PR only
the people in the CC list (and Andrew Pinski :-) will see it, so it's better
to mail it to the list, and leave a note in the PR so that someone who looks
at the bug at a later time will see this patch, if it's not dealt with right away.

The bug looks like a combination of two off-by-one errors: originally
gfc_{g|s}et_backend_locus falsely assumed that the Fortran FE counted lines
beginning from zero, and corrected for this when translating between ME and FE
data structures.  Then I changed these functions, and kept only one of these
adjustments, so that everytime this pair of functions was called the line
number was decreased by 1.

I've committed this slightly modified version of Erik's patch together with a
testcase.

2005-06-04  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
        Erik Schnetter  <schnetter@aei.mpg.de>

	PR fortran/19195
	* trans.c (gfc_get_backend_locus): Remove unnecessary adjustment,
	remove FIXME comment.

Index: trans.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans.c,v
retrieving revision 1.24
diff -u -p -r1.24 trans.c
--- trans.c     26 May 2005 18:36:10 -0000      1.24
+++ trans.c     4 Jun 2005 21:53:50 -0000
@@ -437,9 +437,9 @@ gfc_get_backend_locus (locus * loc)
 {
   loc->lb = gfc_getmem (sizeof (gfc_linebuf));
 #ifdef USE_MAPPED_LOCATION
-  loc->lb->location = input_location; /* FIXME adjust?? */
+  loc->lb->location = input_location;
 #else
-  loc->lb->linenum = input_line - 1;
+  loc->lb->linenum = input_line;
 #endif
   loc->lb->file = gfc_current_backend_file;
 }


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