Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // 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 Kremenek | b8e26e6 | 2008-06-19 17:55:38 +0000 | [diff] [blame] | 6 | |
Ted Kremenek | 39a1884 | 2008-06-21 17:20:55 +0000 | [diff] [blame] | 7 | #include <stdint.h> |
Ted Kremenek | b8e26e6 | 2008-06-19 17:55:38 +0000 | [diff] [blame] | 8 | |
| 9 | int 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 | } |