public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/35882]  New: Miscounted continuation lines when interspersed with data
@ 2008-04-09  8:08 J dot Hogg at rl dot ac dot uk
  2008-04-09  9:06 ` [Bug fortran/35882] " burnus at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: J dot Hogg at rl dot ac dot uk @ 2008-04-09  8:08 UTC (permalink / raw)
  To: gcc-bugs

gfortran seems to misreport a warning about exceeding the number of
continuation lines limit (39 lines of continuation) in certain cases when
compiled with -pedantic.

We found the bug when using a very long write statement, with alternating
continuation lines of string literals and data. The bug does not appear if only
string literals are used.

The bug results in reporting the wrong line as the first invalid continuation
line (if there are indeed more than 39) or that there are too many (in the case
where there are 39 or fewer).

Thanks,
Jonathan.

Full test case:
[user@host] ~/bugs/gfortran-4.3/continuation  $ gfortran-4.3 -pedantic -o test
test.f90 
test.f90:23:

      "Line 15", &
1
Warning: Limit of 39 continuations exceeded in statement at (1)
[user@host] ~/bugs/gfortran-4.3/continuation  $ gfortran-4.3 -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --program-suffix=-4.3
Thread model: posix
gcc version 4.3.0 (GCC)
[user@host] ~/bugs/gfortran-4.3/continuation  $ cat test.f90
program test_mod
   implicit none

   integer, dimension(50) :: array

   array = 1

   print "(a, i8)", &
      "Line 1", &
      array(2), &
      "Line 3", &
      array(4), &
      "Line 5", &
      array(6), &
      "Line 7", &
      array(8), &
      "Line 9", &
      array(10), &
      "Line 11", &
      array(12), &
      "Line 13", &
      array(14), &
      "Line 15", &
      array(16), &
      "Line 17", &
      array(18), &
      "Line 19", &
      array(20), &
      "Line 21", &
      array(22), &
      "Line 23", &
      array(24), &
      "Line 25", &
      array(26), &
      "Line 27", &
      array(28), &
      "Line 29", &
      array(30), &
      "Line 31", &
      array(32), &
      "Line 33", &
      array(34), &
      "Line 35", &
      array(36), &
      "Line 37", &
      array(38), &
      "Line 39", &
      array(40), &
      "Line 41", &
      array(42), &
      "Line 43"
end program


-- 
           Summary: Miscounted continuation lines when interspersed with
                    data
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: J dot Hogg at rl dot ac dot uk
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35882


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/35882] Miscounted continuation lines when interspersed with data
  2008-04-09  8:08 [Bug fortran/35882] New: Miscounted continuation lines when interspersed with data J dot Hogg at rl dot ac dot uk
@ 2008-04-09  9:06 ` burnus at gcc dot gnu dot org
  2008-04-09  9:19 ` burnus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-04-09  9:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2008-04-09 09:05 -------
Confirm.

The problem is not the settings, but that the counting goes wrong. This can
also be seen if one adds comment or empty lines in between. One would expect
that this should not affect the line count (i.e. error still in line 15) or
that the number decreases, however, it increases.

There is also another bug: The default value for -std=gnu/legacy should be 255
(Fortran 2003) and not 39 (Fortran 95). Currently, "-std=gnu -pedantic" warns
for >39 continuation lines but with "-std=f2003 -pedantic" only for >255
continuation lines!

Note: For fixed form source it actually works, even if one adds empty
lines/comment lines.

The additional bug is fixed by the following patch. The reported bug needs some
studying of scanner.c

Index: options.c
===================================================================
--- options.c   (revision 134131)
+++ options.c   (working copy)
@@ -61,2 +61,2 @@ gfc_init_options (unsigned int argc ATTR
-  gfc_option.max_continue_fixed = 19;
-  gfc_option.max_continue_free = 39;
+  gfc_option.max_continue_fixed = 255;
+  gfc_option.max_continue_free = 255;
@@ -736,0 +737,2 @@ gfc_handle_option (size_t scode, const c
+      gfc_option.max_continue_fixed = 19;
+     gfc_option.max_continue_free = 39;
@@ -745,2 +746,0 @@ gfc_handle_option (size_t scode, const c
-      gfc_option.max_continue_fixed = 255;
-      gfc_option.max_continue_free = 255;
@@ -756,2 +755,0 @@ gfc_handle_option (size_t scode, const c
-      gfc_option.max_continue_fixed = 255;
-      gfc_option.max_continue_free = 255;


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
  GCC build triplet|x86_64-unknown-linux-gnu    |
   GCC host triplet|x86_64-unknown-linux-gnu    |
 GCC target triplet|x86_64-unknown-linux-gnu    |
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2008-04-09 09:05:55
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35882


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/35882] Miscounted continuation lines when interspersed with data
  2008-04-09  8:08 [Bug fortran/35882] New: Miscounted continuation lines when interspersed with data J dot Hogg at rl dot ac dot uk
  2008-04-09  9:06 ` [Bug fortran/35882] " burnus at gcc dot gnu dot org
@ 2008-04-09  9:19 ` burnus at gcc dot gnu dot org
  2008-04-14  0:45 ` jvdelisle at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-04-09  9:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2008-04-09 09:19 -------
> We found the bug when using a very long write statement, with alternating
> continuation lines of string literals and data. The bug does not appear if
> only string literals are used.

I forget to say thank you for the bug report.

The problem that the number miscounts for comment/empty lines should be fixed
by the following patch (untested), but I did not see the actual problem.
... I think it is caused by repeatedly parsing the same line; one could try to
fix it as follows:

Index: scanner.c
===================================================================
--- scanner.c   (revision 134131)
+++ scanner.c   (working copy)
@@ -811,18 +811,19 @@ restart:

       /* We've got a continuation line.  If we are on the very next line after
         the last continuation, increment the continuation line count and
         check whether the limit has been exceeded.  */
-      if (gfc_linebuf_linenum (gfc_current_locus.lb) == continue_line + 1)
+      if (gfc_linebuf_linenum (gfc_current_locus.lb) > continue_line)
        {
          if (++continue_count == gfc_option.max_continue_free)
            {
              if (gfc_notification_std (GFC_STD_GNU) || pedantic)
                gfc_warning ("Limit of %d continuations exceeded in "
                             "statement at %C", gfc_option.max_continue_free);
            }
+
+         continue_line = gfc_linebuf_linenum (gfc_current_locus.lb);
        }
-      continue_line = gfc_linebuf_linenum (gfc_current_locus.lb);

       /* Now find where it continues. First eat any comment lines.  */
       openmp_cond_flag = skip_free_comments ();


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35882


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/35882] Miscounted continuation lines when interspersed with data
  2008-04-09  8:08 [Bug fortran/35882] New: Miscounted continuation lines when interspersed with data J dot Hogg at rl dot ac dot uk
  2008-04-09  9:06 ` [Bug fortran/35882] " burnus at gcc dot gnu dot org
  2008-04-09  9:19 ` burnus at gcc dot gnu dot org
@ 2008-04-14  0:45 ` jvdelisle at gcc dot gnu dot org
  2008-04-14  0:48 ` jvdelisle at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-04-14  0:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jvdelisle at gcc dot gnu dot org  2008-04-14 00:44 -------
Subject: Bug 35882

Author: jvdelisle
Date: Mon Apr 14 00:43:32 2008
New Revision: 134251

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134251
Log:
2008-04-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
            Tobias Burnus  <burnus@net-b.de>

        PR fortran/35882
        * options.c (gfc_init_options): Set the default maximum continuation
        lines to 255 for both free and fixed form source for warnings.
        (gfc_handle_option): Set -std=f95 fixed form max continuations to 19
and
        the -std=f95 free form max continuations to 39 for warnings.
        * scanner.c (gfc_next_char_literal): Adjust the current_line number
only
        if it is less than the current locus.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/options.c
    trunk/gcc/fortran/scanner.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35882


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/35882] Miscounted continuation lines when interspersed with data
  2008-04-09  8:08 [Bug fortran/35882] New: Miscounted continuation lines when interspersed with data J dot Hogg at rl dot ac dot uk
                   ` (2 preceding siblings ...)
  2008-04-14  0:45 ` jvdelisle at gcc dot gnu dot org
@ 2008-04-14  0:48 ` jvdelisle at gcc dot gnu dot org
  2008-04-14  1:14 ` jvdelisle at gcc dot gnu dot org
  2008-04-20 21:13 ` jvdelisle at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-04-14  0:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jvdelisle at gcc dot gnu dot org  2008-04-14 00:47 -------
Subject: Bug 35882

Author: jvdelisle
Date: Mon Apr 14 00:47:13 2008
New Revision: 134252

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134252
Log:
2008-04-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR fortran/35882
        * gfortran.dg/continuation_3.f90: Update test.
        * gfortran.dg/continuation_5.f: Update test.
        * gfortran.dg/continuation_10.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/continuation_10.f90
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/continuation_3.f90
    trunk/gcc/testsuite/gfortran.dg/continuation_5.f


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35882


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/35882] Miscounted continuation lines when interspersed with data
  2008-04-09  8:08 [Bug fortran/35882] New: Miscounted continuation lines when interspersed with data J dot Hogg at rl dot ac dot uk
                   ` (3 preceding siblings ...)
  2008-04-14  0:48 ` jvdelisle at gcc dot gnu dot org
@ 2008-04-14  1:14 ` jvdelisle at gcc dot gnu dot org
  2008-04-20 21:13 ` jvdelisle at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-04-14  1:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jvdelisle at gcc dot gnu dot org  2008-04-14 01:14 -------
Fixed on trunk and closing.  Thanks for the report.


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35882


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/35882] Miscounted continuation lines when interspersed with data
  2008-04-09  8:08 [Bug fortran/35882] New: Miscounted continuation lines when interspersed with data J dot Hogg at rl dot ac dot uk
                   ` (4 preceding siblings ...)
  2008-04-14  1:14 ` jvdelisle at gcc dot gnu dot org
@ 2008-04-20 21:13 ` jvdelisle at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-04-20 21:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jvdelisle at gcc dot gnu dot org  2008-04-20 21:12 -------
Subject: Bug 35882

Author: jvdelisle
Date: Sun Apr 20 21:11:22 2008
New Revision: 134493

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134493
Log:
2008-04-20  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR fortran/35882
        * scanner.c (skip_fixed_comments): Update continue_line when comment is
        detected. (gfc_next_char_literal): Likewise.

        PR fortran/35882
        * gfortran.dg/continuation_5.f: Add some comment lines.
        * gfortran.dg/continuation_3.f90: Add some comment lines.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/scanner.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/continuation_3.f90
    trunk/gcc/testsuite/gfortran.dg/continuation_5.f


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35882


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-04-20 21:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-09  8:08 [Bug fortran/35882] New: Miscounted continuation lines when interspersed with data J dot Hogg at rl dot ac dot uk
2008-04-09  9:06 ` [Bug fortran/35882] " burnus at gcc dot gnu dot org
2008-04-09  9:19 ` burnus at gcc dot gnu dot org
2008-04-14  0:45 ` jvdelisle at gcc dot gnu dot org
2008-04-14  0:48 ` jvdelisle at gcc dot gnu dot org
2008-04-14  1:14 ` jvdelisle at gcc dot gnu dot org
2008-04-20 21:13 ` jvdelisle at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).