Bug 29403 - [4.1 only] print ('(a)') not working, print '(a) works
Summary: [4.1 only] print ('(a)') not working, print '(a) works
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.1.2
Assignee: kargls
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2006-10-09 16:32 UTC by tobias.burnus
Modified: 2006-10-16 19:18 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-10-14 04:48:52


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tobias.burnus 2006-10-09 16:32:40 UTC
From http://gcc.gnu.org/ml/fortran/2006-10/msg00274.html

gfortran shows:

print ('(z20.8)'), i
      1
Error: Syntax error in PRINT statement at (1)

The (optional) parentheses are allow (see below) and it works in ifort, NAG f95 and g95.

From Fortran 2003 standard Section 9.5 and 9.5.1.1:

R911  write-stmt   is  WRITE (io-control-spec-list) [output-item list]
R912  print-stmt   is  PRINT format[, output-item-list]

where "format" is:

R914  format       is  default-char-expr
                   or  label
                   or  *

Note that "default-char-expr" is:
R726 default-char-expr is expr
C707 (R726) default-char-expr shall be of type default character.

If one goes through all the "expr", "level-5-expr", ... one ends up at

R701 primary is constant
 [...]
 or ( expr )

In other words: A default-char-expr may have parentheses around.
Comment 1 kargls 2006-10-14 04:48:52 UTC
I may have a patch for this.
Comment 2 kargls 2006-10-16 00:51:58 UTC
Subject: Bug 29403

Author: kargl
Date: Mon Oct 16 00:51:46 2006
New Revision: 117764

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117764
Log:
2006-10-15  Steven G. Kargl  <kargl@gcc.gnu.org>

    PR fortran/29403
    * io.c (match_io):  Check for a default-char-expr for PRINT format.


Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/io.c

Comment 3 kargls 2006-10-16 00:54:11 UTC
Subject: Bug 29403

Author: kargl
Date: Mon Oct 16 00:54:01 2006
New Revision: 117765

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117765
Log:
2006-10-15  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/29403
        * gfortran.dg/print_1.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/print_1.f90
Modified:
    trunk/gcc/testsuite/ChangeLog

Comment 4 kargls 2006-10-16 16:58:21 UTC
Fixed on trunk.  Testing for 4.1.
Comment 5 kargls 2006-10-16 18:37:48 UTC
Subject: Bug 29403

Author: kargl
Date: Mon Oct 16 18:37:39 2006
New Revision: 117789

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117789
Log:
2006-10-15  Steven G. Kargl  <kargl@gcc.gnu.org>
 
    PR fortran/29403
    * io.c (match_io):  Check for a default-char-expr for PRINT format.

	* gfortran.dg/print_1.f90: New test.


Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/print_1.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/io.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 6 kargls 2006-10-16 19:18:08 UTC
Fixed on 4.1, now.