Bug 30532 - ^Z as EOF?
Summary: ^Z as EOF?
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.2.0
Assignee: Jerry DeLisle
URL:
Keywords: rejects-valid
Depends on:
Blocks: 19292
  Show dependency treegraph
 
Reported: 2007-01-21 22:48 UTC by Thomas Koenig
Modified: 2007-01-26 17:30 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-01-23 01:48:04


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2007-01-21 22:48:58 UTC
^Z (ASCII 26) is interpreted as EOF, which is strange.
g77 accepts this.

$ cat ab.f
      print *,""
      end
$ od -t d1 -t a ab.f
0000000   32   32   32   32   32   32  112  114  105  110  116   32   42   44   34   26
         sp  sp  sp  sp  sp  sp   p   r   i   n   t  sp   *   ,   " sub
0000020   34   10   32   32   32   32   32   32  101  110  100   10
          "  nl  sp  sp  sp  sp  sp  sp   e   n   d  nl
0000034
$ gfortran ab.f
ab.f:1.14:

      print *,"
             1
Error: Unterminated character constant beginning at (1)
$ g77 ab.f
$
Comment 1 Jerry DeLisle 2007-01-22 04:52:00 UTC
See scanner.c line 1067.  This is deliberate at the moment.  The question now is, do we want to leave this alone or not?  Does the fortran standard define this in some particuloar way?  I am looking.
Comment 2 Jerry DeLisle 2007-01-22 05:07:30 UTC
My read is that within quotes, the ctrl-z character is acceptable and we should not gobble what is left after seeing one as is done now.

From F95 standard:   Additional characters may be representable in the processor, but may appear only in comments(3.3.1.1, 3.3.2.1), character constants (4.3.2.1), input/output records (9.1.1), and character string edit descriptors (10.2.1).

The following patch allows the test case in #1 to compile:

Index: scanner.c
===================================================================
--- scanner.c   (revision 121034)
+++ scanner.c   (working copy)
@@ -1064,13 +1064,6 @@ load_line (FILE *input, char **pbuf, int
       if (c == '\0')
        continue;
 
-      if (c == '\032')
-       {
-         /* Ctrl-Z ends the file.  */
-         while (fgetc (input) != EOF);
-         break;
-       }
-
       /* Check for illegal use of ampersand. See F95 Standard 3.3.1.3.  */
       if (c == '&')
        seen_ampersand = 1;
Comment 3 Thomas Koenig 2007-01-22 19:18:41 UTC
(In reply to comment #2)
scriptors (10.2.1).
> 
> The following patch allows the test case in #1 to compile:

Looks good (and I agree with the reasoning).

Will you submit the patch?

        Thomas
Comment 4 patchapp@dberlin.org 2007-01-23 03:55:30 UTC
Subject: Bug number PR30532

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-01/msg01852.html
Comment 5 Jerry DeLisle 2007-01-24 01:57:14 UTC
Subject: Bug 30532

Author: jvdelisle
Date: Wed Jan 24 01:56:55 2007
New Revision: 121099

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121099
Log:
2007-01-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/30532
	* scanner.c (load_line): Remove check fot ctrl-z and don't gobble.
	
2007-01-23  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/30481
	* match.c (gfc_match_namelist): Add check for assumed size character
	in namelist and provide error if found.


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

Comment 6 Jerry DeLisle 2007-01-24 02:03:09 UTC
Subject: Bug 30532

Author: jvdelisle
Date: Wed Jan 24 02:02:52 2007
New Revision: 121100

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121100
Log:
2007-01-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/30532
	* gfortran.dg/ctrl-z.f90:  New test.
	
2007-01-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/30481
	* gfortran.dg/namelist_assumed_char.f90:  New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/ctrl-z.f90
    trunk/gcc/testsuite/gfortran.dg/namelist_assumed_char.f90
Modified:
    trunk/gcc/testsuite/ChangeLog

Comment 7 Jerry DeLisle 2007-01-26 17:25:33 UTC
Subject: Bug 30532

Author: jvdelisle
Date: Fri Jan 26 17:25:06 2007
New Revision: 121207

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121207
Log:
2007-01-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/30532
	* scanner.c (load_line): Remove check fot ctrl-z and don't gobble.
	
2007-01-26  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/30481
	* match.c (gfc_match_namelist): Add check for assumed size character
	in namelist and provide error if found.

Modified:
    branches/gcc-4_2-branch/gcc/fortran/ChangeLog
    branches/gcc-4_2-branch/gcc/fortran/match.c
    branches/gcc-4_2-branch/gcc/fortran/scanner.c

Comment 8 Jerry DeLisle 2007-01-26 17:28:19 UTC
Subject: Bug 30532

Author: jvdelisle
Date: Fri Jan 26 17:28:07 2007
New Revision: 121208

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121208
Log:
2007-01-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/30532
	* gfortran.dg/ctrl-z.f90:  New test.
	
2007-01-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/30481
	* gfortran.dg/namelist_assumed_char.f90:  New test.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/ctrl-z.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/namelist_assumed_char.f90
Modified:
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog

Comment 9 Jerry DeLisle 2007-01-26 17:30:24 UTC
Fixed on 4.2 and 4.3