summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/switch.c
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-08-04 00:40:48 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-08-04 00:40:48 +0000
commit077d083b4dd12538fc824d5784d455da0d86a1ea (patch)
tree2f61b833c5f5cbcece595356180381ec9ec4f050 /clang/test/Sema/switch.c
parent454b85606e434d19f6f1e56c1781d2681f50aa62 (diff)
downloadbcm5719-llvm-077d083b4dd12538fc824d5784d455da0d86a1ea.tar.gz
bcm5719-llvm-077d083b4dd12538fc824d5784d455da0d86a1ea.zip
PR11778: Fix the rejects-valid half of this bug. We still produce the same
poorly-worded warning for a case value that is not a possible value of the switched-on expression. llvm-svn: 214678
Diffstat (limited to 'clang/test/Sema/switch.c')
-rw-r--r--clang/test/Sema/switch.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/test/Sema/switch.c b/clang/test/Sema/switch.c
index 092378d48bc..7aa695d7cb9 100644
--- a/clang/test/Sema/switch.c
+++ b/clang/test/Sema/switch.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-enum -Wcovered-switch-default %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-enum -Wcovered-switch-default -triple x86_64-linux-gnu %s
void f (int z) {
while (z) {
default: z--; // expected-error {{statement not in switch}}
@@ -375,3 +375,13 @@ void switch_on_ExtendedEnum1(enum ExtendedEnum1 e) {
}
}
+void PR11778(char c, int n, long long ll) {
+ // Do not reject this; we don't have duplicate case values because we
+ // check for duplicates in the promoted type.
+ switch (c) case 1: case 257: ; // expected-warning {{overflow}}
+
+ switch (n) case 0x100000001LL: case 1: ; // expected-warning {{overflow}} expected-error {{duplicate}} expected-note {{previous}}
+ switch ((int)ll) case 0x100000001LL: case 1: ; // expected-warning {{overflow}} expected-error {{duplicate}} expected-note {{previous}}
+ switch ((long long)n) case 0x100000001LL: case 1: ;
+ switch (ll) case 0x100000001LL: case 1: ;
+}
OpenPOWER on IntegriCloud