Re: bitwise enums

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 20, 2018 at 9:02 AM, Luc Van Oostenryck
<luc.vanoostenryck@xxxxxxxxx> wrote:
> On Tue, Feb 20, 2018 at 08:09:39AM -0800, Matthew Wilcox wrote:
>>
>> I have a feature request relating to bitwise and enums.  The following
>> does not work the way I would like it to:
>>
>> typedef __attribute__((bitwise)) enum {
>>       FOO,
>>       BAR,
>> } my_t;
>>
>> sparse complains:
>>
>> test.c:10:16: warning: incorrect type in return expression (different base types)
>> test.c:10:16:    expected restricted my_t
>> test.c:10:16:    got int

Yeah, that's garbage.

>> I think it would be appropriate for the __attribute__((bitwise)) to
>> apply not just to 'my_t' but also to 'FOO' and 'BAR'.

Definitely.

> Yes, it's reasonable and intuitive.
> It would be nice to have Al Viro's option on this, though.

I'm pretty sure Al will agree, and it's just a matter of "it's a
bug/not implemented".

>> Oh, and I'd also like sparse to permit this:
>>
>> typedef __attribute__((bitwise)) enum {
>>       FOO = 1,
>>       BAR = 2,
>>       BAZ = 4,
>>       QUUX = 8,
>>       WIBBLE = 0x10,
>> } my_t;

I agree.

I just don't have a patch to correct this behavior.

               Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux