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