diff options
| author | David Blaikie <dblaikie@gmail.com> | 2012-01-22 02:31:55 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2012-01-22 02:31:55 +0000 |
| commit | e476f979ca2614775ea8454c10983011da68ed33 (patch) | |
| tree | 2b4671cc68776ba0d55e48192f8e586bae7c6f7a /clang/test/Sema/switch.c | |
| parent | 29e7d608807d3da5e68a6420fbbe4a757cc01a03 (diff) | |
| download | bcm5719-llvm-e476f979ca2614775ea8454c10983011da68ed33.tar.gz bcm5719-llvm-e476f979ca2614775ea8454c10983011da68ed33.zip | |
Fix -Wswitch to warn about out of bounds enum cases even when there's a default
For consistency with GCC & reasonable sanity. The FIXME suggests that the
original author was perhaps using the default check for some other purpose,
not realizing the more obvious limitation/false-negatives it creates, but this
doesn't seem to produce any regressions & fixes the included test.
llvm-svn: 148649
Diffstat (limited to 'clang/test/Sema/switch.c')
| -rw-r--r-- | clang/test/Sema/switch.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/test/Sema/switch.c b/clang/test/Sema/switch.c index 63ffed18e31..f36ecb255f9 100644 --- a/clang/test/Sema/switch.c +++ b/clang/test/Sema/switch.c @@ -297,3 +297,11 @@ int test18() { default: return 2; // expected-warning {{default is unreachable as all enumeration values are accounted for}} } } + +int test19() { + enum { A, B } a; + switch (a) { + case 7: return 1; // expected-warning {{case value not in enumerated type}} + default: return 3; + } +} |

