[PATCH, Fortran] Extension: Support legacy PARAMETER statements with -std=legacy (or -fdec?)

Steve Kargl sgk@troutmask.apl.washington.edu
Wed Nov 2 20:26:00 GMT 2016


On Wed, Nov 02, 2016 at 12:38:51PM -0700, Jerry DeLisle wrote:
> On 11/02/2016 08:47 AM, Fritz Reese wrote:
> >
> > Another quirk of legacy compilers is their syntax for PARAMETER
> > statements. Such statements are similar to standard PARAMETER
> > statements but lack parentheses following the PARAMETER keyword. There
> > is a good reason the standard doesn't support this - because the
> > statement becomes ambiguous with assignment statements in fixed form.
> > Consider the following:
> >
> >         parameter pi = 3.14d0
> >
> > In fixed form, spaces are ignored so in standard Fortran the above
> > looks like an assignment to the variable "parameterpi". In legacy
> > compilers, the above is instead interpreted as
> >
> >         parameter (pi = 3.14d0)
> >
> > which of course declares the variable 'pi' to be a parameter with the
> > value 3.14.

Well, for old code, 'parameter pi = 3.14d0' would never
be parsed as parameterpi because F66 and F77 restricted
tokens to 6 or fewer characters (F77 page 2-1).  Now, 
for modern Fortran, I do agree an ambiguity for fixed-form
source code exists.  A 'name' in F95 is permitted to be
up to 31 characters.

> How does the behavior compare to G77 current behavior. Often we
> use -std=legacy to maintain compatibility with G77, so we do not
> want to break anything there, though I realize we can not be perfect
> in all cases.

Good question.  But, I think -std=legacy has grown to mean
"de facto" standard Fortran from pre-F90 era.

I planned to look over this patch later tonight, but if you
beat me to it a review I won't complain (never would Fritz :-).

-- 
Steve



More information about the Fortran mailing list