blob: f29fc70c49442ea8d409e4bc8d74f4cd5c034842 [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -analyze -checker-simple -analyzer-store=basic -analyzer-constraints=basic -verify %s &&
2// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -verify %s &&
3// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range -verify %s &&
4// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify %s &&
5// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify %s
Ted Kremenekb8e26e62008-06-19 17:55:38 +00006
Ted Kremenek39a18842008-06-21 17:20:55 +00007#include <stdint.h>
Ted Kremenekb8e26e62008-06-19 17:55:38 +00008
9int f1(int * p) {
10
11 // This branch should be infeasible
12 // because __imag__ p is 0.
13 if (!p && __imag__ (intptr_t) p)
14 *p = 1; // no-warning
15
16 // If p != 0 then this branch is feasible; otherwise it is not.
17 if (__real__ (intptr_t) p)
18 *p = 1; // no-warning
19
20 *p = 2; // expected-warning{{Dereference of null pointer}}
21}