r183084 - Properly consider the range of enum for range comparisons in C mode

Eli Friedman eli.friedman at gmail.com
Fri Jun 7 11:04:24 PDT 2013


(Resending because I forgot to CC cfe-commits.)

On Fri, Jun 7, 2013 at 11:02 AM, Eli Friedman <eli.friedman at gmail.com>wrote:

> On Sun, Jun 2, 2013 at 1:11 AM, David Majnemer <david.majnemer at gmail.com>wrote:
>
>> Author: majnemer
>> Date: Sun Jun  2 03:11:22 2013
>> New Revision: 183084
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=183084&view=rev
>> Log:
>> Properly consider the range of enum for range comparisons in C mode
>>
>> In some cases, clang applies the C++ rules for computing the range of a
>> value when said value is an enum.
>>
>> Instead, apply C semantics when in C mode.
>>
>>
> With this patch, the following code triggers a -Wsign-conversion warning:
>
> enum X { a, b, c };
>
> int f() {
>
>   enum X x = b;
>
>   return x;
> }
>
> The warning is technically correct, but it doesn't seem appropriate.  It's
> not obvious what the right approach is to address this issue.  Do you have
> any suggestions?
>
> -Eli
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130607/297fea45/attachment.html>


More information about the cfe-commits mailing list