blob: 8e089d500002c1a1c04a16b741db5993700571e7 [file] [log] [blame]
Ted Kremeneke1cea752009-07-06 21:58:46 +00001// RUN: clang-cc -analyze -checker-cfref --analyzer-store=basic --verify -fblocks %s &&
Ted Kremenekc037eac2009-07-10 00:41:58 +00002// RUN: clang-cc -analyze -checker-cfref --analyzer-store=basic-old-cast --verify -fblocks %s
Ted Kremenek2dabd422009-01-22 18:53:15 +00003
4//---------------------------------------------------------------------------
5// Test case 'checkaccess_union' differs for region store and basic store.
6// The basic store doesn't reason about compound literals, so the code
7// below won't fire an "uninitialized value" warning.
8//---------------------------------------------------------------------------
9
10// PR 2948 (testcase; crash on VisitLValue for union types)
11// http://llvm.org/bugs/show_bug.cgi?id=2948
12
13void checkaccess_union() {
14 int ret = 0, status;
15 if (((((__extension__ (((union { // no-warning
16 __typeof (status) __in; int __i;}
17 )
18 {
19 .__in = (status)}
20 ).__i))) & 0xff00) >> 8) == 1)
21 ret = 1;
22}
Ted Kremenek54ca9b12009-07-13 21:55:12 +000023
24// BasicStore handles this case incorrectly because it doesn't reason about
25// the value pointed to by 'x' and thus creates different symbolic values
26// at the declarations of 'a' and 'b' respectively. See the companion test
27// in 'misc-ps-region-store.m'.
28void test_trivial_symbolic_comparison_pointer_parameter(int *x) {
29 int a = *x;
30 int b = *x;
31 if (a != b) {
32 int *p = 0;
33 *p = 0xDEADBEEF; // expected-warning{{null}}
34 }
35}
36