[cfe-commits] [Patch] -Wduplicate-enum which fixes PR6343

Richard Trieu rtrieu at google.com
Wed Jul 18 16:46:01 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=6343

Warn on enum elements that are assigned values already in use.  This is
based on the misconception that elements not given a value will be given
the next smallest, unused value.  Instead, elements are assigned 1 more
than the previous value.  Some example code this warning will catch:

enum { A, B, C, Aref = A, count };
Both B and count will have value 1.

enum { A, B, C, D = -1, E, F };
A = E = 0
B = F = 1

This warning found one such issue in LLVM that was fixed in r160465.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120718/82636ae9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: duplicate-enum.patch
Type: application/octet-stream
Size: 3903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120718/82636ae9/attachment.obj>


More information about the cfe-commits mailing list