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