From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0BF653858C62; Fri, 2 Jun 2023 17:51:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0BF653858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685728278; bh=fFeslxvSNNb+xuEePLfksHU6TKEhOAxC4GQVwROvj0E=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lyMtT5oMfB88KLueotxAUDWUvTlJMa1CoW3BwWBemKr3HZLCoRCRGhNDEnQDvj4Nl YA3Q5lcvrDE3upsF64ZAPAgDVk5ZI3SShLvDDFrZbb+3CCBFKnSiL+lgabD2Ei5hyu wDV8IJ7wQ/HcEA2wX+y9fBRfGCkWZ+Om1Ayn7ix0= From: "jdelia@santafe-conicet.gov.ar" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/106035] F2018 allows an IMPORT statement within the BLOCK construct. Date: Fri, 02 Jun 2023 17:51:17 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: jdelia@santafe-conicet.gov.ar X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106035 Jorge D'Elia changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jdelia@santafe-conicet.gov. | |ar --- Comment #5 from Jorge D'Elia --- 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 =3D> 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=3Dnative -mtune=3Dnative -m64 -fall-intrinsics -fcheck=3D= all -fimplicit-none -fmax-errors=3D4 -fno-finite-math-only -fPIC -pthread -std= =3Df2018 -Wall -Waliasing -Warray-temporaries -Wcharacter-truncation -Werror -Wextra -Wimplicit-interface -Wimplicit-procedure -Wintrinsic-shadow -Wline-truncat= ion -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 F= 2003 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 neith= er 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"= .=20 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 (bet= ween 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.=