From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A69C73858421; Tue, 20 Dec 2022 20:21:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A69C73858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671567673; bh=DctjzvmffEAqDtQl5UCNaQyCzHW0Emy+ERyIJc/M45k=; h=From:To:Subject:Date:In-Reply-To:References:From; b=vid+0hZF8aPD/hC8f3Pg6ydUEVV0QNAkuqcIId8gvLRTdiGWUFKIYesYPjuo3YevJ SruU5ZVJu0Np1c3r01cl1ER/KiAaDQkjtMB9La+XQc4pEF9BYTUJY/xYdrAClLEYjD SYkdGGkHhEAwJuij2+8423AM6BaAilK0CmDsPmFI= From: "iains at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug modula2/108183] wrong code generated in the modula2 scaffold mechanism Date: Tue, 20 Dec 2022 20:21:13 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: modula2 X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: assemble-failure X-Bugzilla-Severity: normal X-Bugzilla-Who: iains at gcc dot gnu.org X-Bugzilla-Status: NEW 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: 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=3D108183 --- Comment #9 from Iain Sandoe --- So we do set _M2_termios_ctor Symbol to extern. But then here: PreAddModGcc (Sym, BuildEndFunctionDeclaration (begin, end, KeyToCharStar (GetFullSymName (Sym)), returnType, IsExternal (Sym), (* Extern relative to the main module. *) IsProcedureGccNested (Sym), (* Exported from the module where it was declared. *) IsExported (GetModuleWhereDeclared (Sym), Sym) OR IsExtern (Sym))) ; PopBinding(scope) ; "IsExternal (Sys)" returns false, because it thinks that the scope of _M2_termios_ctor is HelloMod. (lldb) p SymbolTable_GetScope(Sym) (unsigned int) $5 =3D 155 (lldb) p M2GCCDeclare_PrintSym(155) information about symbol: 155 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D sym 155 IsModule (HelloWorld) (lldb) p Sym (unsigned int) $6 =3D 6114 (lldb) p M2GCCDeclare_PrintSym(6114) information about symbol: 6114 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D sym 6114 IsProcedure (_M2_termios_ctor) scope HelloWorld:1 155 extern ctor declared in /source/test/hello.mod:1 So we create the decl assuming it exists in the TU .. which is the source of the wrong code.=