]> granicus.if.org Git - clang/commitdiff
Add test case for PR 8646.
authorTed Kremenek <kremenek@apple.com>
Fri, 11 Feb 2011 20:13:27 +0000 (20:13 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 11 Feb 2011 20:13:27 +0000 (20:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125401 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis/misc-ps.m

index 029ca70d28bfe289524264fbdef2dcfc2ccb2c5c..f00228466f713e489f5bb3705f89db55d3d3a094 100644 (file)
@@ -822,7 +822,7 @@ struct trie {
 
 struct kwset {
   struct trie *trie;
-  unsigned char delta[10];
+  unsigned char y[10];
   struct trie* next[10];
   int d;
 };
@@ -837,9 +837,9 @@ void f(kwset_t *kws, char const *p, char const *q) {
   register char const *end = p;
   register char const *lim = q;
   register int d = 1;
-  register unsigned char const *delta = kws->delta;
+  register unsigned char const *y = kws->y;
 
-  d = delta[c = (end+=d)[-1]]; // no-warning
+  d = y[c = (end+=d)[-1]]; // no-warning
   trie = next[c];
 }
 
@@ -1212,3 +1212,24 @@ void pr8619(int a, int b, int c) {
 }
 
 
+// PR 8646 - crash in the analyzer when handling unions.
+union pr8648_union {
+        signed long long pr8648_union_field;
+};
+void pr8648() {
+  long long y;
+  union pr8648_union x = { .pr8648_union_field = 0LL };
+  y = x.pr8648_union_field;
+  
+  union pr8648_union z;
+  z = (union pr8648_union) { .pr8648_union_field = 0LL };
+
+  union pr8648_union w;
+  w = ({ (union pr8648_union) { .pr8648_union_field = 0LL }; }); 
+
+  // crash, no assignment
+  (void) ({ (union pr8648_union) { .pr8648_union_field = 0LL }; }).pr8648_union_field;
+
+  // crash with assignment
+  y = ({ (union pr8648_union) { .pr8648_union_field = 0LL }; }).pr8648_union_field;
+}