]> granicus.if.org Git - clang/commit
Add -Wduplicate-enum warning. Clang will emit this warning when an implicitly
authorRichard Trieu <rtrieu@google.com>
Thu, 30 Aug 2012 20:32:24 +0000 (20:32 +0000)
committerRichard Trieu <rtrieu@google.com>
Thu, 30 Aug 2012 20:32:24 +0000 (20:32 +0000)
commit9f6419f96d6cad3f7bd39f444cfc784ccbbdcd65
treea5bd2198988baecaaddd4861c9c67b80af89be88
parentd295970adc93ed4035d18df23673c2a72d124cc8
Add -Wduplicate-enum warning.  Clang will emit this warning when an implicitly
initiated enum constant has the same value as another enum constant.

For instance:
enum test { A, B, C = -1, D, E = 1 };
Clang will warn that:
 A and D both have value 0
 B and E both have value 1

A few exceptions are made to keep the noise down.  Enum constants which are
initialized to another enum constant, or an enum constant plus or minus 1 will
not trigger this warning.  Also, anonymous enums are not checked.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162938 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDecl.cpp
test/Sema/warn-duplicate-enum.c [new file with mode: 0644]