blob: d253009d8b9af239d1d7f1700b63910fec72211d [file] [log] [blame]
Ted Kremenekd4e5a602009-08-06 21:43:54 +00001// 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
13union u_testA {
14 unsigned i;
15 float f;
16};
17
18float 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