[Patch, fortran] Fix PR19101 missing & in character continuation not caught

Steve Kargl sgk@troutmask.apl.washington.edu
Wed Mar 8 15:55:00 GMT 2006


On Wed, Mar 08, 2006 at 03:31:36PM +0100, Tobias Schl?ter wrote:
> Quoting Jerry DeLisle <jvdelisle@verizon.net>:
> > The attached patch fixes the bug.  I used gfc_fatal_error because the match
> > routines backup a lot and you can get multiple error messages similar to the
> > "tabs are evil" patch.
> 
> I'm not going to obstruct this patch beyond this mail, my contributions
> have been too few lately that I would feel in a position to do so, but
> I'm strongly opposed to issuing a fatal error for an error such a trivial
> error (and the same goes for Steve's patch to kill tabs).  I'd even go so
> far as claiming that issuing a fatal error would be worse than silently
> accepting the erroneous code, as the error is really rather trivial.  Is
> there really no way of recovering gracefully, say by simply skipping the
> rest of the line, issuing a gfc_error, and calling reject_statement, or
> some permutation thereof?
> 

As Jerry stated a single line can be scanned multiple times by
different matchers.  If you simply use gfc_error(), then you will
get multiple error messages about the same tab, and in many cases
there are multiple tabs in a single line.  There is the additional
problem that gfortran expands a tab in column 1 of a fixed-form
source to 6 spaces.  This expansion occurs before the gfortran error
machinery is available, and hence, I can't use gfc_error().  Finally,
you'll note that I had to modify gfc_gobble_whitespace(), which is
called an enormous number of times.  Do you really want to slow down
gfortran's parsing?  I currently have (with comments removed)

void
gfc_gobble_whitespace (void)
{
  locus old_loc;
  int c;
  do
    {
      old_loc = gfc_current_locus;
      c = gfc_next_char_literal (0);
      if (!gfc_option.flag_tabs && c == '\t')
        gfc_fatal_error ("Nonconforming tab character at %C");
    }
  while (gfc_is_whitespace (c));

  gfc_current_locus = old_loc;
}

I might be able to do

void
gfc_gobble_whitespace (void)
{
  static locus seen_locus = NULL;
  locus old_loc;
  int c;
  do
    {
      old_loc = gfc_current_locus;
      c = gfc_next_char_literal (0);
      if (!gfc_option.flag_tabs && c == '\t'
          && gfc_current_locus != seen_locus)
        {
           gfc_error ("Nonconforming tab character at %C");
           seen_locus = gfc_current_locus;
        }
    }
  while (gfc_is_whitespace (c));

  gfc_current_locus = old_loc;
}

But, this can't deal with the fixed-form, column 1, issue.

Finally, I note the the error is fatal, but you are asking 
for this behavior by using -fno-tabs or -pedantic or -std=f95.
Otherwise, gfortran happily treats tabs as whitespace.

-- 
Steve



More information about the Fortran mailing list