220 40118 <e08984e8-9697-44d9-a603-2af646852647@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: enumerator duplicated value attribute
Date: Fri, 7 Sep 2018 18:11:32 -0700 (PDT)
Lines: 119
Approved: news@gmane.org
Message-ID: <e08984e8-9697-44d9-a603-2af646852647@isocpp.org>
References: <CAFdMc-39pqfHATmWOA=iVNPmGDW0yqGh-jtqrxQPb9ALA=NK2A@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_474_319017980.1536369092148"
X-Trace: blaine.gmane.org 1536368969 13186 195.159.176.226 (8 Sep 2018 01:09:29 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sat, 8 Sep 2018 01:09:29 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDLZJYWNDQIMLQ6M3QCRUBG5QP7BI@isocpp.org Sat Sep 08 03:09:25 2018
Return-path: <std-proposals+bncBDLZJYWNDQIMLQ6M3QCRUBG5QP7BI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yb1-f199.google.com ([209.85.219.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDLZJYWNDQIMLQ6M3QCRUBG5QP7BI@isocpp.org>)
	id 1fyRka-0003L2-AO
	for gclcip-std-proposals@m.gmane.org; Sat, 08 Sep 2018 03:09:24 +0200
Original-Received: by mail-yb1-f199.google.com with SMTP id g139-v6sf6543653ybf.6
        for <gclcip-std-proposals@m.gmane.org>; Fri, 07 Sep 2018 18:11:34 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=BMfYGJCQZzSFdioJWkQMdLWoCrva5Y9N1AAQVGS0Q+M=;
        b=Stp2L7b/p8Z7hoDDkRnT5zvyUmUWAEZ+oUzR0y9IpSB74AlN5PLaz7hsiWo6ClHb07
         Ju7Wpu7Y696bgWsXiIl6HrKpqlxEGSY5uuSj2Mye6HyoUfDMrIZ41u/Ug0z9k05gnl2H
         jrGmN6TY8Sol2M4DbLwqyeMDVQnfWgSpC+a88Gfa9UvQDkotowg3y88H5bbiZ03CPdzm
         7G31lSkgCEsxWFxonfEJELEU7Ku5vRbn8yZYBAtP4YSj/gZH+sowadv8M32s5CzkeedY
         otIbWFM4IYT9t/13ZZNUTsXQgmqT/3nEyPr4+dNwALeXqWCCDmYfCtPaM1nJWRW0v5oj
         mRHA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=BMfYGJCQZzSFdioJWkQMdLWoCrva5Y9N1AAQVGS0Q+M=;
        b=Sc1Lb2mF6uM68FVV84E87WfZcDJC7rmOcVgg9Dqs8jwyE+k0M2GTiRzjkgHqQPDrH7
         VgX9w3wN6LOIAB7dTa3asmH82Dd47yaLo/jnMEdtq7ssjA4keCwE1l2g3xuJJeaoSIaY
         0XOwlQfEZAztKJFvJL/vWGInmrsDBH+Rf7AIQ+aHPW9MbBmOxB57G4//2ofTJVt4OYgq
         JvrR6jv3MSc4+1TQicIQbobxZ2qD0b/TPWt5ENzIrxLir4wNJS2PcHsCw/QHxY3HqfB3
         jmRMRSUNIqI/2YUvh7L08AFWLKKQpXdOZS43BGMC7gH0bdWDq8euYI3B7rRrZfbqq69K
         WkVw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=BMfYGJCQZzSFdioJWkQMdLWoCrva5Y9N1AAQVGS0Q+M=;
        b=Osp5Ok8XQjZtT3PsRsFAzHEAR2NSVoaIl2z0STLPs2xTYJnSDIh9mOGWyRRuF2zhnF
         Kb1e5SH0ND9LO+v1XuQM9nweBC4d2dg4z7klI1nRRctlJHu9U6k7986WtLgyg30s3DIL
         QBVomLC/SzH1sgx65IBzu4i7pb8GbWVe7oN8AFqhArxTP6O95ZpOqz7mCqgNI+yhneXD
         kpVmFhLilnZsh24rnAEZN9n+RWNCyFUuGMKXWNoSNnyy5K7HhOuT7g8Z1ZpJ04qxJjYs
         0pdBnShTj8/4F0+dSTaeja6pzI8xwpww4bMTr8iSYhJ44O7nRLfBR2a7UJ/QpzihL1Ox
         T0fQ==
X-Gm-Message-State: APzg51BF95YpDEFUyYys9NvJZXci9FpWngVizA+CicFZRBhVWl8/CvnO
	+juTG86Xnrq8+OEvphSzt0N7Zg==
X-Google-Smtp-Source: ANB0VdYZ06l61UPkRv3U0KvMTtu11MnKaxKTUnnYMS072r+iJCvai0XWZMsrYRmup6LO0uIYn2YU0Q==
X-Received: by 2002:a0d:e253:: with SMTP id l80-v6mr2522470ywe.78.1536369094170;
        Fri, 07 Sep 2018 18:11:34 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a25:c50a:: with SMTP id v10-v6ls205330ybe.2.gmail; Fri, 07
 Sep 2018 18:11:33 -0700 (PDT)
X-Received: by 2002:a25:3857:: with SMTP id f84-v6mr92972yba.3.1536369092784;
        Fri, 07 Sep 2018 18:11:32 -0700 (PDT)
In-Reply-To: <CAFdMc-39pqfHATmWOA=iVNPmGDW0yqGh-jtqrxQPb9ALA=NK2A@mail.gmail.com>
X-Original-Sender: arthur.j.odwyer@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:40118
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40118>

------=_Part_474_319017980.1536369092148
Content-Type: multipart/alternative; 
	boundary="----=_Part_475_1053782367.1536369092148"

------=_Part_475_1053782367.1536369092148
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Friday, September 7, 2018 at 11:55:57 AM UTC-7, Daniel Gutson wrote:
>
> Hi,
>
>    sometimes is important to prevent duplication of enumerators in the=20
> enumerations. That's why some compilers such as clang has the=20
> -Wduplicate-enum.
> However there are cases such as ranges within enums, where enumerators=20
> define a category and then are followed by the first element of the=20
> category, with the same value.
>
> enum Ranges
> {
>     CategoryX =3D 100,
>        X1 =3D CategoryX,
>        X2,
>        X3
>      CategoryY =3D 200
>        // ...
> };
>

What Chris said: this code is already acceptable to Clang.
However, if you do ever run into a situation where Clang is giving you a=20
warning that is "usually correct but I don't want to see it in this=20
particular case," there already exists markup to indicate that situation:

enum Ranges {
    CategoryX =3D 100,
    X1 =3D CategoryX,
    X2,
    X3,
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wduplicate-enum"
    DeprecatedNameX1 =3D X1,
    DeprecatedNameX2,
    DeprecatedNameX3,
#pragma clang diagnostic pop
};

Unfortunately, Clang currently has what-I-consider-a-bug in that it=20
requires you to put the pragma on the *first* occurrence of the value,=20
rather than on the *duplicate* occurrence. I've filed a bug report=20
<https://bugs.llvm.org/show_bug.cgi?id=3D38876>.

=E2=80=93Arthur

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/e08984e8-9697-44d9-a603-2af646852647%40isocpp.or=
g.

------=_Part_475_1053782367.1536369092148
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Friday, September 7, 2018 at 11:55:57 AM UTC-7, Daniel =
Gutson wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
Hi,<div><br></div><div>=C2=A0 =C2=A0sometimes is important to prevent dupli=
cation of enumerators in the enumerations. That&#39;s why some compilers su=
ch as clang has the -Wduplicate-enum.</div><div>However there are cases suc=
h as ranges within enums, where enumerators define a category and then are =
followed by the first element of the category, with the same value.</div><d=
iv><br></div><div>enum Ranges</div><div>{</div><div>=C2=A0 =C2=A0 CategoryX=
 =3D 100,</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0X1 =3D CategoryX,</div><div>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0X2,</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0X3</div=
><div>=C2=A0 =C2=A0 =C2=A0CategoryY =3D 200</div><div>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0// ...</div><div>};</div></div></blockquote><div><br></div><div>What =
Chris said: this code is already acceptable to Clang.</div><div>However, if=
 you do ever run into a situation where Clang is giving you a warning that =
is &quot;usually correct but I don&#39;t want to see it in this particular =
case,&quot; there already exists markup to indicate that situation:</div><d=
iv><br></div><div>enum Ranges {</div><div>=C2=A0 =C2=A0 CategoryX =3D 100,<=
/div><div>=C2=A0 =C2=A0 X1 =3D CategoryX,</div><div>=C2=A0 =C2=A0 X2,</div>=
<div>=C2=A0 =C2=A0 X3,</div><div>#pragma clang diagnostic push</div><div>#p=
ragma clang diagnostic ignored &quot;-Wduplicate-enum&quot;</div><div>=C2=
=A0 =C2=A0 DeprecatedNameX1 =3D X1,</div><div>=C2=A0 =C2=A0=C2=A0Deprecated=
NameX2,</div><div>=C2=A0 =C2=A0=C2=A0DeprecatedNameX3,</div><div>#pragma cl=
ang diagnostic pop</div><div>};</div><div><br></div><div>Unfortunately, Cla=
ng currently has what-I-consider-a-bug in that it requires you to put the p=
ragma on the <i>first</i> occurrence of the value, rather than on the <i>du=
plicate</i> occurrence. I&#39;ve filed <a href=3D"https://bugs.llvm.org/sho=
w_bug.cgi?id=3D38876">a bug report</a>.</div><div><br></div><div>=E2=80=93A=
rthur</div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/e08984e8-9697-44d9-a603-2af646852647%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/e08984e8-9697-44d9-a603-2af646852647=
%40isocpp.org</a>.<br />

------=_Part_475_1053782367.1536369092148--

------=_Part_474_319017980.1536369092148--

.
