public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/19101] New: missing & in character continuation not caught
@ 2004-12-21  9:42 Thomas dot Koenig at online dot de
  2004-12-21 18:49 ` [Bug fortran/19101] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Thomas dot Koenig at online dot de @ 2004-12-21  9:42 UTC (permalink / raw)
  To: gcc-bugs

The following code is erroneous because
there's a & missing in the continuation
line:

$ cat char-cont-wrong.f90
program main
  character (len=40) c
  c = "Hello, &
       world!"
  print *,c
end program main
$ gfortran char-cont-wrong.f90
$ ./a.out
 Hello,        world!

I think a diagnostic is needed for this case.

-- 
           Summary: missing & in character continuation not caught
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Thomas dot Koenig at online dot de
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug fortran/19101] missing & in character continuation not caught
  2004-12-21  9:42 [Bug fortran/19101] New: missing & in character continuation not caught Thomas dot Koenig at online dot de
@ 2004-12-21 18:49 ` pinskia at gcc dot gnu dot org
  2004-12-25  0:41 ` eedelman at acclab dot helsinki dot fi
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-21 18:49 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, diagnostic


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


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

* [Bug fortran/19101] missing & in character continuation not caught
  2004-12-21  9:42 [Bug fortran/19101] New: missing & in character continuation not caught Thomas dot Koenig at online dot de
  2004-12-21 18:49 ` [Bug fortran/19101] " pinskia at gcc dot gnu dot org
@ 2004-12-25  0:41 ` eedelman at acclab dot helsinki dot fi
  2004-12-25  9:31 ` Thomas dot Koenig at online dot de
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: eedelman at acclab dot helsinki dot fi @ 2004-12-25  0:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From eedelman at acclab dot helsinki dot fi  2004-12-25 00:41 -------
I think the result given by gfortran is correct.  Quote from "Fortran 95
handbook" by Adams, Brainerd et al., section 3.3.1.1

"""
To continue a character constant so that the continued line is indented, an
ampersand must be used as the first character of the continued line, as in:

NAME = "Mary K. W&
       &illiams"

In this case, the first nonblank character on the next line [...] must be an
ampersand because Williams is split between lines; _otherwise_ [emphasis mine]
the blanks at the beginning of the second line will be included as part of the
character constant
"""

If I understand this correctly, the & is not needed if you do want the blanks at
the beginning of the line included in the character constant (In your example
you probably do not want that, but how is the compiler supposed to know?).

On the other hand, it seems that the intel compiler wants the & anyway:

$ ifort -e95 char-cont-wrong.f90
fortcom: Warning: char-cont-wrong.f90, line 4: Missing ampersand in continued
character constant
       world!"
-------^

so perhaps I'm wrong.

-- 


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


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

* [Bug fortran/19101] missing & in character continuation not caught
  2004-12-21  9:42 [Bug fortran/19101] New: missing & in character continuation not caught Thomas dot Koenig at online dot de
  2004-12-21 18:49 ` [Bug fortran/19101] " pinskia at gcc dot gnu dot org
  2004-12-25  0:41 ` eedelman at acclab dot helsinki dot fi
@ 2004-12-25  9:31 ` Thomas dot Koenig at online dot de
  2004-12-27 21:41 ` tobi at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Thomas dot Koenig at online dot de @ 2004-12-25  9:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From Thomas dot Koenig at online dot de  2004-12-25 09:31 -------
(In reply to comment #1)

The latest version of the F95 draft standard (isn't the world
of coypyrighted standards wonderful?) states

# If a character context is to be continued, the "&" shall be
# the last nonblank character on the line and shall not be
# followed by a commentary.  An "&" shall be the first nonblank
# character on the next line that is not a comment line and the
# statement continues with the next character following the "&".

-- 


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


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

* [Bug fortran/19101] missing & in character continuation not caught
  2004-12-21  9:42 [Bug fortran/19101] New: missing & in character continuation not caught Thomas dot Koenig at online dot de
                   ` (2 preceding siblings ...)
  2004-12-25  9:31 ` Thomas dot Koenig at online dot de
@ 2004-12-27 21:41 ` tobi at gcc dot gnu dot org
  2004-12-27 21:47 ` tobi at gcc dot gnu dot org
  2004-12-28 19:19 ` tobi at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-12-27 21:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2004-12-27 21:41 -------
That's weird.  I wrote some of this originally, and I was sure that this has to
be interpreted in the way Erik quotes it. I double-checked the F95 and F2K
standards and they both agree with Thomas, but I have a book which I use as a
quick reference of the F90 standard which claims otherwise.  Maybe F90 was
different.

Confirmed nonetheless.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-12-27 21:41:42
               date|                            |


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


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

* [Bug fortran/19101] missing & in character continuation not caught
  2004-12-21  9:42 [Bug fortran/19101] New: missing & in character continuation not caught Thomas dot Koenig at online dot de
                   ` (3 preceding siblings ...)
  2004-12-27 21:41 ` tobi at gcc dot gnu dot org
@ 2004-12-27 21:47 ` tobi at gcc dot gnu dot org
  2004-12-28 19:19 ` tobi at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-12-27 21:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2004-12-27 21:47 -------
Actually, my misleading reference is by the same authors the same as Erik's,
it's the "Fortran 90 Handbook". Looks like they got it wrong.

I think I have a fix, it wasn't too hard :-)

-- 


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


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

* [Bug fortran/19101] missing & in character continuation not caught
  2004-12-21  9:42 [Bug fortran/19101] New: missing & in character continuation not caught Thomas dot Koenig at online dot de
                   ` (4 preceding siblings ...)
  2004-12-27 21:47 ` tobi at gcc dot gnu dot org
@ 2004-12-28 19:19 ` tobi at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-12-28 19:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2004-12-28 19:19 -------
I have a fix which issues the same error twice.

Unfortunately, continuation lines are eaten in the scanner, and there is no real
support for emitting errors from the scanner, as the same line may be rescanned
several times until one of the statement matchers succeeds.  I think the right
line of attack will be to modify the matcher for character literal strings to
deal with the continuation, and to issue the error from there, returning
MATCH_ERROR.

I'll look into doing this.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tobi at gcc dot gnu dot org


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


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

end of thread, other threads:[~2004-12-28 19:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-21  9:42 [Bug fortran/19101] New: missing & in character continuation not caught Thomas dot Koenig at online dot de
2004-12-21 18:49 ` [Bug fortran/19101] " pinskia at gcc dot gnu dot org
2004-12-25  0:41 ` eedelman at acclab dot helsinki dot fi
2004-12-25  9:31 ` Thomas dot Koenig at online dot de
2004-12-27 21:41 ` tobi at gcc dot gnu dot org
2004-12-27 21:47 ` tobi at gcc dot gnu dot org
2004-12-28 19:19 ` tobi 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).