Hi, here's another problem, this time with "legacy f90" code: program gfcbug17 ! gfortran cannot parse this complex constant: complex, parameter :: c0 = (- 0.5, -0.5) print *, c0 end program gfcbug17 I get: In file gfcbug17.f90:3 complex, parameter :: c0 = (- 0.5, -0.5) 1 Error: Expected a right parenthesis in expression at (1) Apparently the space between the "-" and 0.5 lets the parser choke. Can the parsing rules be relaxed to accept the above form? Cheers, -ha
Confirmed, IFC accepts the code.
I'm not sure if this suffices, will try tomorrow: Index: primary.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/fortran/primary.c,v retrieving revision 1.13 diff -u -p -r1.13 primary.c --- primary.c 7 Oct 2004 15:12:01 -0000 1.13 +++ primary.c 11 Oct 2004 22:46:36 -0000 @@ -1028,6 +1028,13 @@ match_const_complex_part (gfc_expr ** re for (;; c = gfc_next_char (), count++) { + if (c == ' ') + { + if (seen_dp || seen_digits) + break; + continue; + } + if (c == '.') { if (seen_dp)
No, that's not sufficient. mpfr_set_str apparently doesn't like spaces in constants.
The patch here http://gcc.gnu.org/ml/fortran/2004-12/msg00265.html fiexes the problem.
(In reply to comment #4) > fiexes the problem. s/fiexes/fixes/
Technically illagal, so removing rejects-valid keyword. IFC is not a particularly good judge of whether code is legal ;-)
Paul, the code is legal! Both NAG and Lahey compile the code without warning or error. Apparently, IFC also compiles the code. I just sent you a new patch to fix the bug.
I started a thread on c.l.f. The title is "whitespace in signed real literal constants. So far, it appears that the code is indeed standard conforming.
A new path is available. http://gcc.gnu.org/ml/fortran/2005-01/msg00243.html
Subject: Bug 17941 CVSROOT: /cvs/gcc Module name: gcc Changes by: pbrook@gcc.gnu.org 2005-01-23 22:29:41 Modified files: gcc/fortran : ChangeLog arith.c primary.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gfortran.dg: complex_int_1.f90 real_const_1.f real_const_2.f90 Log message: 2004-01-23 Paul Brook <paul@codesourcery.com> Steven G. Kargl <kargls@comcast.net> PR fortran/17941 * arith.c (gfc_convert_real): Remove sign handling. * primary.c (match_digits): Allow whitespace after initial sign. (match_real_const): Handle signs here. Allow whitespace after initial sign. Remove dead code. (match_const_complex_part): Remove. (match_complex_part): Use match_{real,integer}_const. (match_complex_constant): Cross-promote integer types. testsuite/ * gfortran.dg/real_const_1.f: New test. * gfortran.dg/real_const_2.f90: New test. * gfortran.dg/complex_int_1.f90: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.312&r2=1.313 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/arith.c.diff?cvsroot=gcc&r1=1.20&r2=1.21 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/primary.c.diff?cvsroot=gcc&r1=1.17&r2=1.18 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4927&r2=1.4928 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/complex_int_1.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/real_const_1.f.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/real_const_2.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed.