From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8FFFF3858C62; Wed, 3 Jan 2024 11:49:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8FFFF3858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704282549; bh=v53ioezrCmbc5sZJ7q1ohV5ws6qYCD9Nru2G0AmhCrw=; h=From:To:Subject:Date:From; b=AviYSEX1ojuMmyNdntwhmUuDrW+0QaCeCW0t/Lkd3PAtmMwhhh3cVRUb/vhpcsbew vy5uK4jLmc3aXteSUmxni/FX5wuJZZIx8giCxar7FMOnp2lX6WUfurVg3pPgXhE//l KRK1SSHSorJcRoZm/lOfPSqxnlqf68eZ9+ksYaKg= From: "acoplan at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/113215] New: gimple FE can't handle static local variable with initializer Date: Wed, 03 Jan 2024 11:49:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: acoplan 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: 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=3D113215 Bug ID: 113215 Summary: gimple FE can't handle static local variable with initializer Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: acoplan at gcc dot gnu.org Target Milestone: --- The following testcase is accepted: int __GIMPLE (ssa) f () { static int x; __BB(2): return 1; } but adding an initializer to the static variable, it gets rejected: $ cat > t.c int __GIMPLE (ssa) f () { static int x =3D 1; __BB(2): return 1; } $ gcc/xgcc -B gcc -c -fgimple t.c t.c: In function =E2=80=98f=E2=80=99: t.c:4:18: error: expected =E2=80=98;=E2=80=99 before =E2=80=98=3D=E2=80=99 = token 4 | static int x =3D 1; | ^ t.c: At top level: t.c:5:10: error: expected declaration specifiers or =E2=80=98...=E2=80=99 b= efore numeric constant 5 | __BB(2): | ^ t.c:7:1: error: expected identifier or =E2=80=98(=E2=80=99 before =E2=80=98= }=E2=80=99 token 7 | } | ^ such IL can be generated by dumping optimized GIMPLE as seen e.g. with the following testcase: $ cat t2.c int f() { static int x =3D 1; return x; } $ gcc/xgcc -B gcc -c t2.c -fdump-tree-optimized-gimple=3D- int __GIMPLE (ssa) f () { static int x =3D 1; int D_4434; int _2; __BB(2): _2 =3D x; goto __BB3; __BB(3): L0: return _2; }=