erichkeane wrote:

> > One thing I REALLY hate about our pattern of using bitfields for enums, is 
> > that it becomes pretty trivial to add an entry to an enum and forget to 
> > increase the size of the bitfield. I think such a attribute could cause a 
> > diagnostic of `bitfield says it holds an ENUM type, but can't store all the 
> > values`, which would be INCREDIBLY valuable (not that I'm pushing that this 
> > patch IMPLEMENT that, but more that I'm saying such a name COULD do that, 
> > and probably should as well).
> > So in conclusion, I don't mind the name, but also prefer something more 
> > general.
> 
> Couldn't we add a warning for that in general? Seems like a pretty useful one 
> to me.

Not without SOME sort of psychic-level analysis from Sema.  Without some level 
of mapping of "I mean for this to hold the values of this Enum", we don't have 
the information to do so.  We cannot take advantage of assignments (though a 
similar warning DOES exist in the 'range' checking) since it might be intended 
that the field does some level of 'conversion' between enums.

https://github.com/llvm/llvm-project/pull/69104
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to