blob: 6f850695cecebae61e09cda801a025f4a7856cd9 [file] [log] [blame]
Daniel Dunbara45cf5b2009-03-24 02:24:46 +00001// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -verify %s &&
Ted Kremenekf6655792009-07-10 00:41:58 +00002// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic-old-cast -analyzer-constraints=basic -verify %s &&
Daniel Dunbara45cf5b2009-03-24 02:24:46 +00003// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range -verify %s &&
Ted Kremenekf6655792009-07-10 00:41:58 +00004// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic-old-cast -analyzer-constraints=range -verify %s &&
Daniel Dunbara45cf5b2009-03-24 02:24:46 +00005// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify %s &&
6// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify %s
Ted Kremenek46c82ab2008-06-19 17:55:38 +00007
Ted Kremenek68d23682008-06-21 17:20:55 +00008#include <stdint.h>
Ted Kremenek46c82ab2008-06-19 17:55:38 +00009
10int f1(int * p) {
11
12 // This branch should be infeasible
13 // because __imag__ p is 0.
14 if (!p && __imag__ (intptr_t) p)
15 *p = 1; // no-warning
16
17 // If p != 0 then this branch is feasible; otherwise it is not.
18 if (__real__ (intptr_t) p)
19 *p = 1; // no-warning
20
21 *p = 2; // expected-warning{{Dereference of null pointer}}
22}