Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 1 | // 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 Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 4 | // RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify %s |
Ted Kremenek | b8e26e6 | 2008-06-19 17:55:38 +0000 | [diff] [blame] | 5 | |
Ted Kremenek | 39a1884 | 2008-06-21 17:20:55 +0000 | [diff] [blame] | 6 | #include <stdint.h> |
Ted Kremenek | b8e26e6 | 2008-06-19 17:55:38 +0000 | [diff] [blame] | 7 | |
Mike Stump | fd28a61 | 2009-07-21 18:44:24 +0000 | [diff] [blame] | 8 | void f1(int * p) { |
Ted Kremenek | b8e26e6 | 2008-06-19 17:55:38 +0000 | [diff] [blame] | 9 | |
| 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 | } |