From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9C1C53858C00; Tue, 11 Jul 2023 18:13:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C1C53858C00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689099200; bh=oRCb6RRD6F5AYzYRW8cO0FfJYAWwoZH3JfF83oc02CM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WmetZxoUaHPLOMh+BYSbIK7HcwlYLnXjOzXq5A+7W5PHdH52FeuPLbied1ZwmVdXf rMJ58zG0lfIC41br83o0QeeGfao3M79hc+yHCPihpxq0Q7FsJO3TFw3DqAeJ5X+DZs W1gxz9YqrywOSEJO0ZgZoOj3RUb7n4GZVtFFD+p4= From: "admin@tho-otto.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug modula2/110126] Variables are reported as unused when only referenced by ASM statements Date: Tue, 11 Jul 2023 18:13:19 +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.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: admin@tho-otto.de X-Bugzilla-Status: REOPENED 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_status resolution 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=3D110126 Thorsten Otto changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED |--- --- Comment #14 from Thorsten Otto --- And another problem i just encountered. In the following example: DEFINITION MODULE foo; PROCEDURE ConWS(str: ARRAY OF CHAR); END foo. IMPLEMENTATION MODULE foo; FROM SYSTEM IMPORT ADR, CARDINAL16, CARDINAL32, INTEGER16, ADDRESS, INTEGER32, WORD; FROM StrIO IMPORT WriteString, WriteLn; TYPE strtmp =3D ARRAY [0..255] OF CHAR; PROCEDURE str0(VAR dst: strtmp; src: ARRAY OF CHAR); VAR i, len: CARDINAL; BEGIN len :=3D HIGH(dst); FOR i :=3D 0 TO len DO dst[i] :=3D src[i]; END; END str0; PROCEDURE trap_1_wl(n: INTEGER16; a: ADDRESS): [ INTEGER32 ]; VAR retvalue: INTEGER32; BEGIN ASM VOLATILE("move.l %2,-(%%sp); move.w %1,-(%%sp); trap #1; addq.l #6,%%sp; move.l %%d0,%0" : "=3Dr"(retvalue) : "g"(n), "r"(a) : "memory" ); RETURN retvalue END trap_1_wl; PROCEDURE ConWS(str: ARRAY OF CHAR); VAR s: strtmp; BEGIN str0(s, str); trap_1_wl(9, ADR(s)); END ConWS; END foo. The call to str0 (in reality supposed to ensure the string is 0-terminated; just simplified for the example) is now completely eliminated. The assembler statement is of course only for m68k, but it can even be triggered for other targets when just producing assembler output. It does not happen when replacing the call to trap_1_wl eg. by WriteString.=