The following is illegal: $ cat print.f90 program main character*80 line print (line,'(A)'), 'hello' end program main $ cat print.f90 program main character*80 line print (line,'(A)'), 'hello' end program main $ gfortran print.f90 $ gfortran -std=f95 print.f90 $ gfortran -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../gcc-4.1/configure --prefix=/home/ig25 --enable-languages=c,f95 : (reconfigured) ../gcc-4.1/configure --prefix=/home/ig25 --enable-languages=c,f95 Thread model: posix gcc version 4.1.0 20050726 (experimental)
g77 groks this: $ cat prt.f program main character*80 line print (line,'(A)'), 'hello' end $ g77 prt.f prt.f: In program `main': prt.f:3: print (line,'(A)'), 'hello' ^ Real part of complex constant at (^) must be a real or integer constant -- otherwise use CMPLX() or COMPLEX() in place of () prt.f:3: print (line,'(A)'), 'hello' ^ Imaginary part of complex constant at (^) must be a real or integer constant -- otherwise use CMPLX() or COMPLEX() in place of ()
This patch looks as if it could do the job: Index: io.c =================================================================== --- io.c (revision 113958) +++ io.c (working copy) @@ -2424,6 +2424,12 @@ dt->io_unit = default_unit (k); goto get_io_list; } + else + { + /* print (*,*) is invalid. */ + if (gfc_match_char ('(')) + goto syntax; + } /* Match a control list */ if (match_dt_element (k, dt) == MATCH_YES)
The previous patch was bogus. This one actually works: Index: io.c =================================================================== --- io.c (revision 113958) +++ io.c (working copy) @@ -2424,6 +2424,12 @@ dt->io_unit = default_unit (k); goto get_io_list; } + else + { + /* print (*,*) is invalid. */ + if (k == M_PRINT) + goto syntax; + } /* Match a control list */ if (match_dt_element (k, dt) == MATCH_YES)
Subject: Bug number PR23151 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/2006-05/msg01323.html
Subject: Bug 23151 Author: tkoenig Date: Fri May 26 19:53:18 2006 New Revision: 114138 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114138 Log: 2006-05-26 Thomas Koenig <Thomas.Koenig@online.de> PR fortran/23151 * io.c (match_io): print (1,*) is an error. 2006-05-26 Thomas Koenig <Thomas.Koenig@online.de> PR fortran/23151 * gfortran.dg/inquire_9.f90: Fix illegal print syntax. * gfortran.dg/print_parentheses_1.f: New test. * gfortran.dg/print_parentheses_2.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/print_parentheses_1.f trunk/gcc/testsuite/gfortran.dg/print_parentheses_2.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/io.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/inquire_9.f90
Subject: Bug 23151 Author: tkoenig Date: Wed May 31 20:50:34 2006 New Revision: 114281 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114281 Log: 2006-05-31 Thomas Koenig <Thomas.Koenig@online.de> PR fortran/23151 Backport from mainline. * io.c (match_io): print (1,*) is an error. 2006-05-31 Thomas Koenig <Thomas.Koenig@online.de> PR fortran/23151 Backport from mainline. * gfortran.dg/inquire_9.f90: Fix illegal print syntax. * gfortran.dg/print_parentheses_1.f: New test. * gfortran.dg/print_parentheses_2.f90: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/print_parentheses_1.f branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/print_parentheses_2.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 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/inquire_9.f90
Fixed on trunk and 4.1. Closing.