public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/33269]  New: Diagnose missing "(" in  "PRINT ('a'),"
@ 2007-08-31 14:03 burnus at gcc dot gnu dot org
  2007-08-31 14:16 ` [Bug fortran/33269] " burnus at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-31 14:03 UTC (permalink / raw)
  To: gcc-bugs

The format must be '(a)' and not 'a', however, gfortran does not diagnose this
in

PRINT ('a'), 'Hello'

NAG f95:
Error: a.f90, line 1: Missing left parenthesis in format specification
ifort:
Error: First non-blank character in a character type format specifier must be a
left parenthesis.

Without the outer parenthesis, gfortran detects this:

print 'a', 'Hello'
                 1
Error: Missing leading left parenthesis in format string at (1)

[The position of the "1" could also be better.]


-- 
           Summary: Diagnose missing "(" in  "PRINT ('a'),"
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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

* [Bug fortran/33269] Diagnose missing "(" in  "PRINT ('a'),"
  2007-08-31 14:03 [Bug fortran/33269] New: Diagnose missing "(" in "PRINT ('a')," burnus at gcc dot gnu dot org
@ 2007-08-31 14:16 ` burnus at gcc dot gnu dot org
  2007-08-31 19:47 ` jvdelisle at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-31 14:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2007-08-31 14:16 -------
Actually, all of the following is affected. The last one fails before
due to PR 33268.

print ('a'), 'Hello'
write(*,('a')) 'Hello'
read (*,('f3.3')) a
read ('f3.3'), a
end


-- 


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


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

* [Bug fortran/33269] Diagnose missing "(" in  "PRINT ('a'),"
  2007-08-31 14:03 [Bug fortran/33269] New: Diagnose missing "(" in "PRINT ('a')," burnus at gcc dot gnu dot org
  2007-08-31 14:16 ` [Bug fortran/33269] " burnus at gcc dot gnu dot org
@ 2007-08-31 19:47 ` jvdelisle at gcc dot gnu dot org
  2007-08-31 20:02 ` burnus at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-08-31 19:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jvdelisle at gcc dot gnu dot org  2007-08-31 19:47 -------
gfortran does catch these at run time.

Also, the last case, read ('f3.3'), a, does give a legitimate error:

read ('f3.3'), a
     1
Error: UNIT specification at (1) must be an INTEGER expression or a CHARACTER
variable.

See PR28397.  I think this is a near duplicate.


-- 


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


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

* [Bug fortran/33269] Diagnose missing "(" in  "PRINT ('a'),"
  2007-08-31 14:03 [Bug fortran/33269] New: Diagnose missing "(" in "PRINT ('a')," burnus at gcc dot gnu dot org
  2007-08-31 14:16 ` [Bug fortran/33269] " burnus at gcc dot gnu dot org
  2007-08-31 19:47 ` jvdelisle at gcc dot gnu dot org
@ 2007-08-31 20:02 ` burnus at gcc dot gnu dot org
  2007-09-02 16:16 ` tobi at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-31 20:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from burnus at gcc dot gnu dot org  2007-08-31 20:02 -------
> gfortran does catch these at run time.

Well, at compile time is nicer ;-)

> Also, the last case, read ('f3.3'), a, does give a legitimate error:
> read ('f3.3'), a
>      1
> Error: UNIT specification at (1) must be an INTEGER expression or a CHARACTER
> variable.

No, the syntax is:
  READ format[, io-list]
and  ('f.3.3') as a constant-string expression for the format; this is similar
to  "PRINT ('f3.3'), a".
This should be distinguished from:
  READ(io-control-spec-list)
The distinction is simple: If there is no ( and an * or a label, it must be
"READ format"; if the first item after the "(" is a default-char-expression
(constant or not) and there is no "...=" (e.g. "fmt=") in there, then it is
also a "READ format" statement.

> See PR28397.  I think this is a near duplicate.

Yes and no. This PR is about things which are in principle correctly diagnosed,
but not if one surrounds it with parenthesis. The other PR is about things
which should be diagnosed but are not. They are related, but they need
different fixes.


-- 


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


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

* [Bug fortran/33269] Diagnose missing "(" in  "PRINT ('a'),"
  2007-08-31 14:03 [Bug fortran/33269] New: Diagnose missing "(" in "PRINT ('a')," burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-08-31 20:02 ` burnus at gcc dot gnu dot org
@ 2007-09-02 16:16 ` tobi at gcc dot gnu dot org
  2007-09-02 18:27 ` tobi at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tobi at gcc dot gnu dot org @ 2007-09-02 16:16 UTC (permalink / raw)
  To: gcc-bugs



-- 

tobi at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |tobi at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-09-02 16:16:05
               date|                            |


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


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

* [Bug fortran/33269] Diagnose missing "(" in  "PRINT ('a'),"
  2007-08-31 14:03 [Bug fortran/33269] New: Diagnose missing "(" in "PRINT ('a')," burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-09-02 16:16 ` tobi at gcc dot gnu dot org
@ 2007-09-02 18:27 ` tobi at gcc dot gnu dot org
  2007-09-02 18:42 ` burnus at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tobi at gcc dot gnu dot org @ 2007-09-02 18:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from tobi at gcc dot gnu dot org  2007-09-02 18:27 -------
(In reply to comment #3)
> No, the syntax is:
>   READ format[, io-list]
> and  ('f.3.3') as a constant-string expression for the format; this is similar
> to  "PRINT ('f3.3'), a".
> This should be distinguished from:
>   READ(io-control-spec-list)
> The distinction is simple: If there is no ( and an * or a label, it must be
> "READ format"; if the first item after the "(" is a default-char-expression
> (constant or not) and there is no "...=" (e.g. "fmt=") in there, then it is
> also a "READ format" statement.

This is wrong.  In "READ(20) x", 20 is not a format but a unit number. 
Additionally, we allow "READ(20), x" as an extension which makes this even more
annoying to fix.

I'll be leaving for vacation on Thursday.  Given that my first attempts at
fixing this failed, I don't think I'll be able to attend these bugs before the
end of the month.  Fortunately, they're not important issues.


-- 


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


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

* [Bug fortran/33269] Diagnose missing "(" in  "PRINT ('a'),"
  2007-08-31 14:03 [Bug fortran/33269] New: Diagnose missing "(" in "PRINT ('a')," burnus at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2007-09-02 18:27 ` tobi at gcc dot gnu dot org
@ 2007-09-02 18:42 ` burnus at gcc dot gnu dot org
  2007-09-02 18:48 ` tobi at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-02 18:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from burnus at gcc dot gnu dot org  2007-09-02 18:42 -------
(In reply to comment #4)
> > if the first item after the "(" is a default-char-expression
> > (constant or not) and there is no "...=" (e.g. "fmt=") in there, then it is
> > also a "READ format" statement.
> 
> This is wrong.  In "READ(20) x", 20 is not a format but a unit number.

I don't think that this is wrong:
I would argue that 20 is not a default-char-expression ;-)

> Additionally, we allow "READ(20), x" as an extension which makes this even
> more annoying to fix.
Agreed.

> Fortunately, they're not important issues. 
Fortunately not.


-- 


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


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

* [Bug fortran/33269] Diagnose missing "(" in  "PRINT ('a'),"
  2007-08-31 14:03 [Bug fortran/33269] New: Diagnose missing "(" in "PRINT ('a')," burnus at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2007-09-02 18:42 ` burnus at gcc dot gnu dot org
@ 2007-09-02 18:48 ` tobi at gcc dot gnu dot org
  2007-09-22 12:53 ` tobi at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tobi at gcc dot gnu dot org @ 2007-09-02 18:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from tobi at gcc dot gnu dot org  2007-09-02 18:48 -------
(In reply to comment #5)
> (In reply to comment #4)
> > > if the first item after the "(" is a default-char-expression
> > > (constant or not) and there is no "...=" (e.g. "fmt=") in there, then it is
> > > also a "READ format" statement.
> > 
> > This is wrong.  In "READ(20) x", 20 is not a format but a unit number.
> 
> I don't think that this is wrong:
> I would argue that 20 is not a default-char-expression ;-)

Sorry, you're right of course.  Unfortunately, the type can't be determined in
all cases, so this criterion doesn't work.  I tried.


-- 


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


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

* [Bug fortran/33269] Diagnose missing "(" in  "PRINT ('a'),"
  2007-08-31 14:03 [Bug fortran/33269] New: Diagnose missing "(" in "PRINT ('a')," burnus at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2007-09-02 18:48 ` tobi at gcc dot gnu dot org
@ 2007-09-22 12:53 ` tobi at gcc dot gnu dot org
  2007-09-24 21:15 ` tobi at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tobi at gcc dot gnu dot org @ 2007-09-22 12:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from tobi at gcc dot gnu dot org  2007-09-22 12:53 -------
Created an attachment (id=14244)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14244&action=view)
Unfinished patch

Here's a patch.  I won't have time for the final cosmetics for a few days to
come, so I'm posting it hereto give interested parties the chance to find a few
tests that I didn't think of.  I'm not entirely convinced that such an early
call to gfc_simplify_expr() is safe, but I haven't yet looked through the
simplification code.


-- 


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


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

* [Bug fortran/33269] Diagnose missing "(" in  "PRINT ('a'),"
  2007-08-31 14:03 [Bug fortran/33269] New: Diagnose missing "(" in "PRINT ('a')," burnus at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2007-09-22 12:53 ` tobi at gcc dot gnu dot org
@ 2007-09-24 21:15 ` tobi at gcc dot gnu dot org
  2007-09-24 21:48 ` patchapp at dberlin dot org
  2007-09-25  5:39 ` tobi at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: tobi at gcc dot gnu dot org @ 2007-09-24 21:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from tobi at gcc dot gnu dot org  2007-09-24 21:15 -------
Subject: Bug 33269

Author: tobi
Date: Mon Sep 24 21:15:00 2007
New Revision: 128732

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128732
Log:
PR fortran/33269
fortran/
* io.c (check_format_string): Move NULL and constant checks into
this function.
(check_io_constraints): Call gfc_simplify_expr() before calling
check_format_string().  Remove NULL and constant checks.
testsuite/
* gfortran.dg/fmt_error_2.f90: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/fmt_error_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/io.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/33269] Diagnose missing "(" in  "PRINT ('a'),"
  2007-08-31 14:03 [Bug fortran/33269] New: Diagnose missing "(" in "PRINT ('a')," burnus at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2007-09-24 21:15 ` tobi at gcc dot gnu dot org
@ 2007-09-24 21:48 ` patchapp at dberlin dot org
  2007-09-25  5:39 ` tobi at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: patchapp at dberlin dot org @ 2007-09-24 21:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from patchapp at dberlin dot org  2007-09-24 21:48 -------
Subject: Bug number PR33269

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-09/msg01797.html


-- 


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


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

* [Bug fortran/33269] Diagnose missing "(" in  "PRINT ('a'),"
  2007-08-31 14:03 [Bug fortran/33269] New: Diagnose missing "(" in "PRINT ('a')," burnus at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2007-09-24 21:48 ` patchapp at dberlin dot org
@ 2007-09-25  5:39 ` tobi at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: tobi at gcc dot gnu dot org @ 2007-09-25  5:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from tobi at gcc dot gnu dot org  2007-09-25 05:39 -------
Fixed.


-- 

tobi at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


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

end of thread, other threads:[~2007-09-25  5:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-31 14:03 [Bug fortran/33269] New: Diagnose missing "(" in "PRINT ('a')," burnus at gcc dot gnu dot org
2007-08-31 14:16 ` [Bug fortran/33269] " burnus at gcc dot gnu dot org
2007-08-31 19:47 ` jvdelisle at gcc dot gnu dot org
2007-08-31 20:02 ` burnus at gcc dot gnu dot org
2007-09-02 16:16 ` tobi at gcc dot gnu dot org
2007-09-02 18:27 ` tobi at gcc dot gnu dot org
2007-09-02 18:42 ` burnus at gcc dot gnu dot org
2007-09-02 18:48 ` tobi at gcc dot gnu dot org
2007-09-22 12:53 ` tobi at gcc dot gnu dot org
2007-09-24 21:15 ` tobi at gcc dot gnu dot org
2007-09-24 21:48 ` patchapp at dberlin dot org
2007-09-25  5:39 ` 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).