[PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-10-26 Thread Mehdi AMINI via cfe-commits
mehdi_amini reopened this revision. mehdi_amini added a comment. This revision is now accepted and ready to land. Reopen: this hasn't been committed yet apparently. @sashab : are you still interested in moving this forward? https://reviews.llvm.org/D24289

[PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-11-10 Thread Sasha Bermeister via cfe-commits
sashab added a comment. Sorry, had this discussion elsewhere (https://bugs.chromium.org/p/chromium/issues/detail?id=648462). I'm uncertain at this point. There is currently a bug in GCC that means enums with an explicit underlying type (or enum classes, although the latter is to be fixed) are

[PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-11-10 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment. > So when this modification tells the developer to add 'unsigned' to their > enum, they are subsequently causing a warning to occur in GCC. > > I have commented on the bug on GCC for this > (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51242#c28), but it looks > un

[PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-11-15 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment. In https://reviews.llvm.org/D24289#592592, @mehdi_amini wrote: > > So when this modification tells the developer to add 'unsigned' to their > > enum, they are subsequently causing a warning to occur in GCC. > > > > I have commented on the bug on GCC for this > >

[PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-11-16 Thread Reid Kleckner via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL287177: Add warning when assigning enums to bitfields without an explicit unsigned… (authored by rnk). Changed prior to commit: https://reviews.llvm.org/D24289?vs=70760&id=78281#toc Repository: rL LL

[PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-11-16 Thread Richard Smith via cfe-commits
rsmith added a comment. This is causing warnings to fire for headers shared between C and C++, where the "give the enum an unsigned underlying type" advice doesn't work, and where the code in question will never be built for the MS ABI. It seems really hard to justify this being on by default.

[PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-11-16 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment. What is the correct solution for MSVC in C? (If any) Repository: rL LLVM https://reviews.llvm.org/D24289 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commi

[PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-11-17 Thread Reid Kleckner via cfe-commits
rnk added a comment. In https://reviews.llvm.org/D24289#598169, @rsmith wrote: > This is causing warnings to fire for headers shared between C and C++, where > the "give the enum an unsigned underlying type" advice doesn't work, and > where the code in question will never be built for the MS AB

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-08 Thread Reid Kleckner via cfe-commits
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. lgtm Comment at: lib/Sema/SemaChecking.cpp:7841 @@ +7840,3 @@ +if (S.getLangOpts().CPlusPlus11 && +!BitfieldEnumDecl->getIntegerTypeSourceInfo() && +BitfieldEnum

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-08 Thread Nico Weber via cfe-commits
thakis added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2962 @@ -2959,1 +2961,3 @@ + "the enum %0 an unsigned underlying type">, + InGroup>, DefaultIgnore; def warn_attribute_packed_for_bitfield : Warning< Hm, isn't the more safe de

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-08 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2962 @@ -2959,1 +2961,3 @@ + "the enum %0 an unsigned underlying type">, + InGroup>, DefaultIgnore; def warn_attribute_packed_for_bitfield : Warning< thakis

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-08 Thread Reid Kleckner via cfe-commits
rnk added a comment. I was thinking of suggesting to put it under -Wextra, but -Wall is fine too. I still don't think it should be on by default. I think there are a lot of Unix-only projects out there that aren't concerned with MSVC compatibility, and a warning about how things with in the Mic

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-08 Thread Sasha Bermeister via cfe-commits
sashab updated this revision to Diff 70760. sashab marked an inline comment as done. sashab added a comment. Thanks for your feedback everyone; left the flag as DefaultIgnore but added it to -Wall. Keep in mind I am planning on adding two additional warnings after this, namely "%0 is too small t

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-11-16 Thread Nico Weber via cfe-commits
I'm a bit surprised that this landed, given that gcc bug. I can see the motivation for the gcc bug: If you say your enum is going to need underlying 8 bits, then warning that your bitfield where you store it is smaller _is_ surprising. I'm not sure if landing this while gcc still behaves the way i

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-11-16 Thread Richard Smith via cfe-commits
On 16 November 2016 at 18:38, Nico Weber via cfe-commits < cfe-commits@lists.llvm.org> wrote: > I'm a bit surprised that this landed, given that gcc bug. I can see the > motivation for the gcc bug: If you say your enum is going to need > underlying 8 bits, then warning that your bitfield where you

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-11-17 Thread Richard Smith via cfe-commits
On 17 Nov 2016 8:56 am, "Reid Kleckner" wrote: rnk added a comment. In https://reviews.llvm.org/D24289#598169, @rsmith wrote: > This is causing warnings to fire for headers shared between C and C++, where the "give the enum an unsigned underlying type" advice doesn't work, and where the code in

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-11-17 Thread Arthur O'Dwyer via cfe-commits
On Thu, Nov 17, 2016 at 9:52 AM, Richard Smith via cfe-commits < cfe-commits@lists.llvm.org> wrote: > On 17 Nov 2016 8:56 am, "Reid Kleckner" wrote: >> In https://reviews.llvm.org/D24289#598169, @rsmith wrote: >>> This is causing warnings to fire for headers shared between C and C++, >>> where the

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-11-17 Thread Sasha Bermeister via cfe-commits
Although I agree with your philosophical discussion and suggestions, the reality is that MSVC's behavior is not a bug and compilers are free to interpret enum bitfields with no explicit underlying type in any way they want (see spec reference in GCC bug link), with a signed interpretation being a v

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-11-17 Thread Arthur O'Dwyer via cfe-commits
On Thu, Nov 17, 2016 at 2:14 PM, Sasha Bermeister wrote: > Although I agree with your philosophical discussion and suggestions, the > reality is that MSVC's behavior is not a bug and compilers are free to > interpret enum bitfields with no explicit underlying type in any way they > want (see spec

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-11-20 Thread Sasha Bermeister via cfe-commits
Thanks for the great explanation, I agree with this advice. I'm going to investigate writing a new patch to do this. On Fri, Nov 18, 2016 at 1:59 PM, Arthur O'Dwyer wrote: > On Thu, Nov 17, 2016 at 2:14 PM, Sasha Bermeister > wrote: > >> Although I agree with your philosophical discussion and s

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-14 Thread Sasha Bermeister via cfe-commits
sashab added a comment. Pinging for another LGTM since I have added it to -Wall and added a portability comment to the error message :) https://reviews.llvm.org/D24289 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cg

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-15 Thread Nico Weber via cfe-commits
thakis added a comment. Works for me if rnk likes it :-) (We could bikeshed on if this should be one of the -Wmicrosoft warnings, but the warning can't be both in -Wall and -Wmicrosoft, so let's don't). I do have a question about the test (the first commit below): Comment at:

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-15 Thread Reid Kleckner via cfe-commits
rnk added a comment. In https://reviews.llvm.org/D24289#543874, @thakis wrote: > Works for me if rnk likes it :-) Yep, looks good. > (We could bikeshed on if this should be one of the -Wmicrosoft warnings, but > the warning can't be both in -Wall and -Wmicrosoft, so let's don't). I also don

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-15 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision. aaron.ballman added a reviewer: aaron.ballman. aaron.ballman added a comment. LGTM as well, thank you! https://reviews.llvm.org/D24289 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.or

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-16 Thread Sasha Bermeister via cfe-commits
sashab added a comment. Thanks all! :) Comment at: test/SemaCXX/warn-msvc-enum-bitfield.cpp:12 @@ +11,3 @@ + + s.e2 = E2; + s.f2 = F2; thakis wrote: > Shouldn't this be the version that warns? The assignment with E1 assigns 0 > which is portable, but this ass

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-16 Thread Sasha Bermeister via cfe-commits
sashab marked an inline comment as done. sashab added a comment. https://reviews.llvm.org/D24289 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-16 Thread Sasha Bermeister via cfe-commits
sashab closed this revision. sashab added a comment. Is this how I commit this? Hopefully this lands... :-) https://reviews.llvm.org/D24289 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-co

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-16 Thread Nico Weber via cfe-commits
thakis added inline comments. Comment at: test/SemaCXX/warn-msvc-enum-bitfield.cpp:12 @@ +11,3 @@ + + s.e2 = E2; + s.f2 = F2; sashab wrote: > thakis wrote: > > Shouldn't this be the version that warns? The assignment with E1 assigns 0 > > which is portable, but