From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7C91B38493DE; Fri, 24 Mar 2023 12:24:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7C91B38493DE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679660683; bh=kB2RWCEZ4lE6D3jaudoeMR9WuIo65J6IGCWIG6DrBAE=; h=From:To:Subject:Date:From; b=EnfOj1hTDopB3AZUHIK+SDTnxRlVG7DCb2QLvSdRhuRnti09EkA9qd9PMmFj3jdPX Ucc49DhvllN6BOnllX+wJx+jUJz6jaEoQhQ3gQwHizYXgxN0v0M7qaXoBCy7aM2puq 9wmVfvbZbfh0nkSd0jUZ/PA6JbrSU8pEW3pvnQ/o= From: "rhidalgochar at bloomberg dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/109275] New: Bad error messages for interfaces describing surrounding program unit Date: Fri, 24 Mar 2023 12:24:43 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: rhidalgochar at bloomberg dot net 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 Bug ID: 109275 Summary: Bad error messages for interfaces describing surrounding program unit Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: rhidalgochar at bloomberg dot net Target Milestone: --- The following example, where an interface is defined for the surrounding program unit fails to compile: function foo(arg1) result(res) interface foo function foo(arg1) integer*2 foo(3) integer*8 arg1 end function foo end interface integer*2 res(3) integer*8 arg1 res =3D (/1,2,int(arg1,4)/) end function Giving the error: recursive-interface.f:4:8: 4 | function foo(arg1) | 1 Error: Procedure pointer result =E2=80=98foo=E2=80=99 at (1) is missing the= pointer attribute Given you can use this function with that interface, this appears to be an incorrect warning. It gives even stranger warnings if you follow its advice and add the pointer attribute to foo in the interface (i.e. integer*2, pointer :: foo(3)): recursive-interface.f:4:8: 4 | function foo(arg1) | 1 Error: Array pointer =E2=80=98ppr@=E2=80=99 at (1) must have a deferred sha= pe or assumed rank recursive-interface.f:1:6: 1 | function foo(arg1) result(res) | 1 Error: Array pointer =E2=80=98foo=E2=80=99 at (1) must have a deferred shap= e or assumed rank It appears that "ppr@" is some internal return variable that should not be getting exposed. Following this advice further and making foo assumed shape (foo(:)) it goes back to complaining about it not having the pointer attrib= ute even though it does. 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 disambiguate the symbol, other compilers do fail to compile and complain about using an interface with the same name as the surrounding program unit. XLF complained for normal interfaces, while Sun Studio just complains for generic interfac= e. GFortrans error message should at least be more informative, explicitly say= ing it's not allowed if this is the case. I came across this issue because a library had an include with many interfa= ces, and was then trying to use some of those interfaces in the definitions of t= hose program units.=