]> granicus.if.org Git - clang/commit
Add -Wswitch-enum-redundant-default.
authorDavid Blaikie <dblaikie@gmail.com>
Sat, 21 Jan 2012 18:12:07 +0000 (18:12 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Sat, 21 Jan 2012 18:12:07 +0000 (18:12 +0000)
commit31ceb61172bca7ebc3fb90e9125864c7a29c55c0
treed605bb1e6086fadf6341cc1b65bdf886a5698bdd
parentf3c1ca6bced3f79ec6d76f1bcb05c5ae6944ce0b
Add -Wswitch-enum-redundant-default.

This warning acts as the complement to the main -Wswitch-enum warning (which
warns whenever a switch over enum without a default doesn't cover all values of
 the enum) & has been an an-doc coding convention in LLVM and Clang in my
experience. The purpose is to ensure there's never a "dead" default in a
switch-over-enum because this would hide future -Wswitch-enum errors.

The name warning has a separate flag name so it can be disabled but it's grouped
under -Wswitch-enum & is on-by-default because of this.

The existing violations of this rule in test cases have had the warning disabled
& I've added a specific test for the new behavior (many negative cases already
exist in the same test file - and none regressed - so I didn't add more).

Reviewed by Ted Kremenek ( http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120116/051690.html )

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148640 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaStmt.cpp
test/Sema/switch.c
test/Sema/warn-unreachable.c
test/SemaCXX/gnu-case-ranges.cpp
test/SemaCXX/return-noreturn.cpp