From: Ted Kremenek Date: Fri, 11 Feb 2011 20:13:27 +0000 (+0000) Subject: Add test case for PR 8646. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ac518ecd5204116eb976c8d77ccf2dd2c7352148;p=clang Add test case for PR 8646. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125401 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 029ca70d28..f00228466f 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -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; +}