From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CC5843858D1E; Thu, 28 Mar 2024 15:46:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC5843858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711640801; bh=1/NDyPmwWDMeYWgYm32VsRaJzo0BJZkGOxsRxcoB0sY=; h=From:To:Subject:Date:From; b=vZgg6L2I0rMASx0heNxhM39Vw9P/OfxY2QPaHBSYfIy/cTeNHE1rHF6nZhIF4k0PC 6saXUBQlGWCd4pHMZkJUBzIgdZGyuNGhUe8MpYLUl6tTdo64+Sb5OulP8kVgce/Lgz 74ug3rfwPDH+3HxhHYKlxUjFlr/Bdpa1KY3AyUwA= From: "gaius at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug modula2/114520] New: Incorrect ordering of import/export statements cause confusing error messages Date: Thu, 28 Mar 2024 15:46:41 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: modula2 X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gaius at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: gaius 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=3D114520 Bug ID: 114520 Summary: Incorrect ordering of import/export statements cause confusing error messages Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: modula2 Assignee: gaius at gcc dot gnu.org Reporter: gaius at gcc dot gnu.org Target Milestone: --- As reported on the gm2 mailing list: $ cat localmodule2.mod MODULE localmodule2 ; FROM libc IMPORT printf ; PROCEDURE mult2 (n: CARDINAL) : CARDINAL ; BEGIN RETURN 2*n END mult2 ; MODULE local ; EXPORT mysqr ; IMPORT mult2 ; PROCEDURE mysqr (n: CARDINAL) : CARDINAL ; BEGIN RETURN mult2 (n) * mult2 (n) END mysqr ; END local ; VAR d: CARDINAL ; BEGIN d :=3D mysqr (3) ; printf ("sqr (3 * 2) =3D %d\n", d) END localmodule2. $ gm2 localmodule2.mod=20 localmodule2.mod:13:10: warning: In inner module =E2=80=98local=E2=80=99: s= yntax warning, =E2=80=98END=E2=80=99 missing=20 13 | IMPORT mult2 ; | ^~~~~ localmodule2.mod:20:11: warning: In program module =E2=80=98localmodule2=E2= =80=99: syntax warning, =E2=80=98.=E2=80=99 missing=20 20 | END local ; | ^ localmodule2.mod:1:8: error: module name at beginning =E2=80=98localmodule2= =E2=80=99 does not match the name at end =E2=80=98local=E2=80=99 1 | MODULE localmodule2 ; | ^~~~~~~~~~~~ localmodule2.mod:10:8: error: In inner module =E2=80=98local=E2=80=99: modu= le name at beginning =E2=80=98local=E2=80=99 does not match the name at end =E2=80=98mult2=E2=80= =99 10 | MODULE local ; | ^~~~~ localmodule2.mod:13:3: error: syntax error, found =E2=80=98IMPORT=E2=80=99 13 | IMPORT mult2 ; | ^~~~~~ localmodule2.mod:13:10: error: module name at end =E2=80=98mult2=E2=80=99 d= oes not match the name at beginning =E2=80=98local=E2=80=99 13 | IMPORT mult2 ; | ^~~~~ localmodule2.mod:20:5: error: In program module =E2=80=98localmodule2=E2=80= =99: module name at end =E2=80=98local=E2=80=99 does not match the name at beginning =E2=80=98l= ocalmodule2=E2=80=99 20 | END local ; | ^~~~~ localmodule2.mod:20:11: error: syntax error, found =E2=80=98;=E2=80=99 20 | END local ; | ^ localmodule2.mod:28:1: error: no scope active: compilation failed The user level fix is to switch the IMPORT and EXPORT statement lines. However the compiler should generate a more meaningful error message.=