From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B0F543858D35; Fri, 24 Mar 2023 14:14:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0F543858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679667248; bh=vOgnAqWkz0mlIo8AATa7NXwfUIf1gfndyrNOBYr4Lww=; h=From:To:Subject:Date:In-Reply-To:References:From; b=H628pZmQYT898Ir6U44vtWZ8/naSgghlGjBhwOUjrjrxuvTvFxEI5qqKpKwHTEz3X yQOx02C+ZbUMivO3Z5xhbOv27uRZE8a6OosoYSer9aBonn0RARmztdjjdzo9eXJqLl KKgsCH/Nv+LoYyQTZsRTpLuqZf3mEGIrUJuT8GtQ= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/109275] Bad error messages for interfaces describing surrounding program unit Date: Fri, 24 Mar 2023 14:14:08 +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: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 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=3D109275 kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kargl at gcc dot gnu.org --- Comment #1 from kargl at gcc dot gnu.org --- (In reply to Raoul Hidalgo Charman from comment #0) > The following example, where an interface is defined for the surrounding > program unit fails to compile: >=20 > function foo(arg1) result(res) >=20 > interface foo > function foo(arg1) > integer*2 foo(3) > integer*8 arg1 > end function foo > end interface >=20 > integer*2 res(3) > integer*8 arg1 > res =3D (/1,2,int(arg1,4)/) > end function >=20 > Giving the error: >=20 > recursive-interface.f:4:8: >=20 > 4 | function foo(arg1) > | 1 > Error: Procedure pointer result =E2=80=98foo=E2=80=99 at (1) is missing t= he pointer attribute >=20 > Given you can use this function with that interface, this appears to be an > incorrect warning. It's not a warning. It is an error. And, yes it seems wrong. >=20 > While I don't see any reason why a correctly defined interface would not = be > allowed, especially if it's not even used and result is used to disambigu= ate > the symbol, other compilers do fail to compile and complain about using an > interface with the same name as the surrounding program unit. XLF complai= ned > for normal interfaces, while Sun Studio just complains for generic interf= ace. >=20 > GFortrans error message should at least be more informative, explicitly > saying it's not allowed if this is the case. >=20 > I came across this issue because a library had an include with many > interfaces, and was then trying to use some of those interfaces in the > definitions of those program units. It seems to be invalid Fortran. From Fortran 2018 C1501 (R1501) An interface-block in a subprogram shall not contain an interface-body for a procedure defined by that subprogram. It seems gfortran is missing a check for C1501.=