This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Help fixing parser for negative exponents to **



On May 24, 2004, at 15:17, Roger Sayle wrote:



Unfortunately, I don't have access to the official grammars for fortran95 and fortran2003, but I suspect that there's a bug in gfortran's parser for processing power expressions. Currently, we fail to parse unary minus (and unary plus) expressions immediately following an exponentiation/power operator.

       X = 2.0
       Y = X**-1.5D0
       PRINT 10, Y
10     FORMAT (F8.5)
       END

       X = 2.0
       Y = X**+1.5D0
       PRINT 10, Y
10     FORMAT (F8.5)
       END

       X = 2.0
       Y = 1.5
       Z = X**-Y
       PRINT 10, Z
10     FORMAT (F8.5)
       END


I believe these are all valid, and compile fine with g77. They might however be a "common" extension, so I thought I'd check with this list first. The examples in gfortran.fortran-torture/execute/power.f90 all use parenthesis around negative exponents.

This is a common extension as if you -pedantic with g77 you get a message.
prthgfdhgfds.f: In program `MAIN__':
prthgfdhgfds.f:3:
Z = X**-Y
1 2
Two arithmetic operators in a row at (1) and (2) -- use parentheses


And I think this is PR 13912 as the issue is the same with
multiplication also.

Thanks,
Andrew Pinski


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]