This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug fortran/80666] character length parameter fails if declaration order incorrect


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80666

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
The change in behavior is likely due to revision r238904 (pr71730). 

Note that compiling the first test in comment 0 with -std=f95 before this
revision gives

% /opt/gcc/gcc7p-238848p2/bin/gfortran pr80666.f90 -std=f95
pr80666.f90:3:13:

   character*(keylen), intent(in) :: key
             1
Error: GNU Extension: Symbol 'keylen' is used before it is typed at (1)
pr80666.f90:1:29:

 subroutine test_arg_order(key,keylen)
                             1
Error: Symbol 'key' at (1) has no IMPLICIT type

> Just try to write standard conforming code if possible.

Seconded (this is a very easy case), since the revision r238904 fixes an ICE at
the expense of a GNU extension, I don't think it is worth putting any effort to
restore the extension -> closing this PR as WONTFIX.

> On the other hand, the main misunderstanding here I think is what defines
> the order of the definition of subroutine parameters. Is it the parameter
> list in the subroutine statement or is it the individual type declarations
> that follow it? It seems most logical in my eyes if the parameter list
> is the one that defines order of parameter definitions but I might be wrong.
> Is this defined in the fortran specification at all? 

(1) PARAMETER has a very precise definition in Fortran and AFAICT this
definition (named constants) does not match your use in the above quotation.
Are you meaning dummy arguments?

(2) If yes, there is no correlation between the order the dummy arguments and
the individual type declarations. The order of type declarations is only a
matter of coding style, provided they follow the rule "define before using".

Final note: while looking at the DATA statement, I stumbled on the following

5.6.7 DATA statement

...

3 A variable that appears in a DATA statement and has not been typed
  previously may appear in a subsequent type declaration only if that
  declaration confirms the implicit typing. An array name, array section,
  or array element that appears in a DATA statement shall have had its array
  properties established by a previous specification statement.

Thus the rule "define before using" has at least one exception.

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