]> granicus.if.org Git - clang/commitdiff
Include test case for <rdar://problem/5880430>.
authorTed Kremenek <kremenek@apple.com>
Thu, 9 Sep 2010 00:40:43 +0000 (00:40 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 9 Sep 2010 00:40:43 +0000 (00:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113458 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis/misc-ps.m

index 4fbaa49c11682348e6f5b3c0277df9a105637f78..206eb513710e6dddae0a454622b1cdfce1e134ab 100644 (file)
@@ -1068,3 +1068,30 @@ void pr8050(struct PR8050 **arg)
     *arg = malloc(1);
 }
 
+// <rdar://problem/5880430> Switch on enum should not consider default case live
+//  if all enum values are covered
+enum Cases { C1, C2, C3, C4 };
+void test_enum_cases(enum Cases C) {
+  switch (C) {
+  case C1:
+  case C2:
+  case C4:
+  case C3:
+    return;
+  }
+  int *p = 0;
+  *p = 0xDEADBEEF; // no-warning
+}
+
+void test_enum_cases_positive(enum Cases C) {
+  switch (C) { // expected-warning{{enumeration value 'C4' not handled in switch}}
+  case C1:
+  case C2:
+  case C3:
+    return;
+  }
+  int *p = 0;
+  *p = 0xDEADBEEF; // expected-warning{{Dereference of null pointer}}
+}
+
+