Ted Kremenek | d4e5a60 | 2009-08-06 21:43:54 +0000 | [diff] [blame^] | 1 | // RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=range %s -verify |
| 2 | |
| 3 | //===-- unions-region.m ---------------------------------------------------===// |
| 4 | // |
| 5 | // This file tests the analyzer's reasoning about unions. |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // When using RegionStore, this test case previously had a false positive |
| 10 | // of a 'pass-by-value argument is uninitialized' warning at the call to |
| 11 | // 'testA_aux'. |
| 12 | |
| 13 | union u_testA { |
| 14 | unsigned i; |
| 15 | float f; |
| 16 | }; |
| 17 | |
| 18 | float testA(float f) { |
| 19 | int testA_aux(unsigned x); |
| 20 | int testA_aux_2(union u_testA z); |
| 21 | |
| 22 | union u_testA swap; |
| 23 | swap.f = f; |
| 24 | |
| 25 | if (testA_aux(swap.i)) // no-warning |
| 26 | swap.i = ((swap.i & 0xffff0000) >> 16) | ((swap.i & 0x0000fffff) << 16); |
| 27 | |
| 28 | testA_aux_2(swap); // no-warning |
| 29 | |
| 30 | return swap.f; |
| 31 | } |
| 32 | |