blob: c118a61455afcac0a030f2421a4ef688ec4796e9 [file] [log] [blame]
Argyrios Kyrtzidisc4d2c902011-02-28 19:49:42 +00001// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -analyzer-constraints=basic -verify -Wno-unreachable-code -ffreestanding %s
2// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -analyzer-constraints=range -verify -Wno-unreachable-code -ffreestanding %s
Ted Kremenekb8e26e62008-06-19 17:55:38 +00003
Ted Kremenek39a18842008-06-21 17:20:55 +00004#include <stdint.h>
Ted Kremenekb8e26e62008-06-19 17:55:38 +00005
Mike Stumpfd28a612009-07-21 18:44:24 +00006void f1(int * p) {
Ted Kremenekb8e26e62008-06-19 17:55:38 +00007
8 // This branch should be infeasible
9 // because __imag__ p is 0.
10 if (!p && __imag__ (intptr_t) p)
11 *p = 1; // no-warning
12
13 // If p != 0 then this branch is feasible; otherwise it is not.
14 if (__real__ (intptr_t) p)
15 *p = 1; // no-warning
16
17 *p = 2; // expected-warning{{Dereference of null pointer}}
18}