Re: [RFC, C] add warning for unpromoted bit-field uses

2014-11-10 Thread Joseph Myers
On Sun, 9 Nov 2014, Sandra Loosemore wrote: > Hrmmm. In C, sp->a has type "3-bit unsigned integer" which is promoted to int > by the integral promotions since all values are representable as int. sp->c > has type "5-bit unsigned integer" which is likewise promoted to int. In C++, > sp->a has t

Re: [RFC, C] add warning for unpromoted bit-field uses

2014-11-10 Thread Joseph Myers
On Sat, 8 Nov 2014, Sandra Loosemore wrote: > I thought that the point at which integral promotions are applied would be a > good place to catch this, as it excludes places where bit-fields are already > being converted by assignment or explicit cast. I think we also want to Formally of course t

Re: [RFC, C] add warning for unpromoted bit-field uses

2014-11-09 Thread Sandra Loosemore
On 11/09/2014 02:28 AM, Manuel López-Ibáñez wrote: We had a request from a customer to add a warning to the C front end to diagnose cases where bit-fields larger than an int are used in shift expressions; confusingly, the operation is done in the precision of the bit-field size rather than its de

Re: [RFC, C] add warning for unpromoted bit-field uses

2014-11-09 Thread Manuel López-Ibáñez
> We had a request from a customer to add a warning to the C front end to > diagnose cases where bit-fields larger than an int are used in shift > expressions; confusingly, the operation is done in the precision of the > bit-field size rather than its declared type. This is a symptom of a larger >

Re: [RFC, C] add warning for unpromoted bit-field uses

2014-11-09 Thread Marc Glisse
On Sat, 8 Nov 2014, Sandra Loosemore wrote: + warning_at (EXPR_LOCATION (exp), OPT_Wbitfield_conversion, + "suggest casting bit-field to its declared type"); I think it would be nice to print this declared type. It can be done directly in this message, or by adding a not

[RFC, C] add warning for unpromoted bit-field uses

2014-11-08 Thread Sandra Loosemore
We had a request from a customer to add a warning to the C front end to diagnose cases where bit-fields larger than an int are used in shift expressions; confusingly, the operation is done in the precision of the bit-field size rather than its declared type. This is a symptom of a larger probl