From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8DFA5385841A; Mon, 13 Mar 2023 13:44:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8DFA5385841A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678715094; bh=RQ5VyAkQC/H4OU/v9iiifjhYCYjgpVLXxWCe2rA1Wkg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=G726EQevArRc8oxQISwh6fsxvZep59opA1U+97TsPuVR/9b2iF/8t48aqfxFC3p75 mi3MMjzWJp1bIFVVySwPoCrluzZqlkyc9L41r/P+CrlzXhSa3iW3fCRBw5loTT6cHp LEATEsAcA7Sg+byU6Gz8AXMYtrs0Rc6jrk930Y5A= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/16186] gcc should have an option to warn about enumerations with duplicate values Date: Mon, 13 Mar 2023 13:44:53 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.0.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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=3D16186 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #8 from Jakub Jelinek --- (In reply to trashyankes from comment #7) > Should be way to disable/enable this warning per `enum`? > Like: >=20 > ``` > enum [[gnu::enum_unique]] X > { > I =3D 1, > J =3D 2, > }; >=20 > enum [[gnu::enum_not_unique]] Y > { > K =3D 1, > L =3D 1, > }; >=20 > ``` No, it should warn solely if enumerator gets implicitly assigned value of s= ome other enumerator. After all, the clang wording also mentions that: element 'D' has been implicitly assigned 5 which another element has been assigned [-Wduplicate-enum] If there is =3D value for it, we should never warn, that is most likely completely intentional. Of course, we should use better wording, because we should talk about enumerators, not elements...=