! F95: 14.1.2.1: ! "A common block name in a scoping unit also may be the name of any local ! entity other than a named constant, intrinsic procedure, or a local variable ! that is also an external function in a function subprogram." ! ! F2003: 16.2.1 ! "A name that identifies a common block in a scoping unit shall not be used ! to identify a constant or an intrinsic procedure in that scoping unit. If ! a local identifier is also the name of a common block, the appearance of ! that name in any context other than as a common block name in a COMMON ! or SAVE statement is an appearance of the local identifier." Currently, valid Fortran 2003 programs are therefore rejected. The check happens very early in the match.c's gfc_match_common ("Symbol '%s' at %C is already an external symbol that is not COMMON").
Created attachment 13792 [details] Test case I believe the attached program is valid in Fortran 2003 (modulo typos; as no compiler accepts it, I cannot test it).
With two minor modifications to the code (in main, call func(), not res(); in func1() call modFunc(), not mod), one gets: $> gfortran-svn -v gcc version 4.6.0 20100509 (experimental) (GCC) $> gfortran-svn -Wall -W -std=f95 pr32515.f90 pr32515.f90:24.16: common /bar/ r2 ! F95: Error also a global procedure 1 Error: Symbol 'bar' at (1) is already an external symbol that is not COMMON pr32515.f90:25.16: common /mod/ r3 ! F95: Error also a global procedure 1 Error: Symbol 'mod' at (1) is already an external symbol that is not COMMON pr32515.f90:23.16: common /res/ r1 ! F95: Error also a global procedure 1 Error: Fortran 2003: COMMON block 'res' at (1) that is also a function result $> gfortran-svn -Wall -W -std=f2003 pr32515.f90 pr32515.f90:24.16: common /bar/ r2 ! F95: Error also a global procedure 1 Error: Symbol 'bar' at (1) is already an external symbol that is not COMMON pr32515.f90:25.16: common /mod/ r3 ! F95: Error also a global procedure 1 Error: Symbol 'mod' at (1) is already an external symbol that is not COMMON I think, that's ok, Closing. Please reopen if I misread something.
If I understand correctly, an external symbol can be used for a common block name in f2003. Thus, there should be no error with -std=f2003.
I think Mikael Morin is incorrect here. nagfor and ifort reject the test case, e.g. ifort: A name that identifies a global entity is used to identify another global entity in the same program. nagfor: Error: pr_32515.f90, line 31: COMMON block BAR is also a global procedure So I think this should be closed.