https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106035
Jorge D'Elia <jde...@santafe-conicet.gov.ar> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jde...@santafe-conicet.gov. | |ar --- Comment #5 from Jorge D'Elia <jde...@santafe-conicet.gov.ar> --- Hi, The access restriction is a reason of the use IMPORT statements in the projects, since it is a very convenient and nifty way to detect any name collision between local entities and host-associated entities, and well as, in BLOCK statements, for the same purpose. However, with the test: $ cat import1.f90 module m_modulo implicit none (type, external) contains subroutine ss (ii) import, all implicit none (type, external) integer, intent (in) :: ii associate (i_loc => ii) end associate end subroutine ss end module m_modulo compiled with, (i) $ gfortran --version GNU Fortran (GCC) 12.3.1 20230508 (Red Hat 12.3.1-1) Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ gfortran -march=native -mtune=native -m64 -fall-intrinsics -fcheck=all -fimplicit-none -fmax-errors=4 -fno-finite-math-only -fPIC -pthread -std=f2018 -Wall -Waliasing -Warray-temporaries -Wcharacter-truncation -Werror -Wextra -Wimplicit-interface -Wimplicit-procedure -Wintrinsic-shadow -Wline-truncation -Wrealloc-lhs-all -Wsurprising -Wtabs -Wunused-parameter -flto -O2 -o import1.exe import1.f90 import1.f90:5:11: 5 | import, all | 1 Error: IMPORT statement at (1) only permitted in an INTERFACE body f951: all warnings being treated as errors and next compiled with (ii): $ nagfor ../import1.f90 -O3 rm: cannot remove '*.original': No such file or directory NAG Fortran Compiler Release 7.1(Hanzomon) Build 7115 Error: ../import1.f90, line 2: Syntax error detected at NONE@( Error: ../import1.f90, line 5: The IMPORT statement is only allowed in an INTERFACE body detected at IMPORT@, Error: ../import1.f90, line 5: Syntax error detected at IMPORT@, Error: ../import1.f90, line 6: Syntax error detected at NONE@( [NAG Fortran Compiler pass 1 error termination, 4 errors] Thus, the errors generated by gfortran and nagfor are consistent with the F2003 constraint: C1210 (R1209) "The IMPORT statement is allowed only in an interface-body". However, the use of IMPORT in the previus test is new in F2018, which neither gfortran nor NAG Fortran support, that is: "The IMPORT statement can appear in a contained subprogram or BLOCK construct, and can restrict access via host association; diagnosis of violation of the IMPORT restrictions is required". Thus, this example should be valid F2018 but not F2008 or earlier. For instance, one can have a unit testing framework that relies extensively on BLOCK constructs, and having the guarantee that any potential conflict (between a local block entity and an entity of the host procedure) will be flagged by the compiler (when using an IMPORT statement in each block construct) sould be a godsend.