diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-08-06 21:43:54 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-08-06 21:43:54 +0000 |
commit | d4e5a606c9c64e24c05e5f4610796087e911fb9c (patch) | |
tree | fd0c4cbe1d96b37cbc059684d11f0d51fd2af036 /test/Analysis/unions-region.m | |
parent | 470c2a9ab6807be8a695e583a41b20ed69082260 (diff) |
Fix a couple false positive "uninitialized value" warnings with RegionStore
involving reasoning about unions (which we don't handle yet).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78342 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/unions-region.m')
-rw-r--r-- | test/Analysis/unions-region.m | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/Analysis/unions-region.m b/test/Analysis/unions-region.m new file mode 100644 index 0000000000..d253009d8b --- /dev/null +++ b/test/Analysis/unions-region.m @@ -0,0 +1,32 @@ +// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=range %s -verify + +//===-- unions-region.m ---------------------------------------------------===// +// +// This file tests the analyzer's reasoning about unions. +// +//===----------------------------------------------------------------------===// + +// When using RegionStore, this test case previously had a false positive +// of a 'pass-by-value argument is uninitialized' warning at the call to +// 'testA_aux'. + +union u_testA { + unsigned i; + float f; +}; + +float testA(float f) { + int testA_aux(unsigned x); + int testA_aux_2(union u_testA z); + + union u_testA swap; + swap.f = f; + + if (testA_aux(swap.i)) // no-warning + swap.i = ((swap.i & 0xffff0000) >> 16) | ((swap.i & 0x0000fffff) << 16); + + testA_aux_2(swap); // no-warning + + return swap.f; +} + |