Daniel Dunbar | a45cf5b | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -verify %s && |
Ted Kremenek | f665579 | 2009-07-10 00:41:58 +0000 | [diff] [blame] | 2 | // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic-old-cast -analyzer-constraints=basic -verify %s && |
Daniel Dunbar | a45cf5b | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 3 | // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range -verify %s && |
Ted Kremenek | f665579 | 2009-07-10 00:41:58 +0000 | [diff] [blame] | 4 | // RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic-old-cast -analyzer-constraints=range -verify %s && |
Daniel Dunbar | a45cf5b | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 5 | // 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 Kremenek | 46c82ab | 2008-06-19 17:55:38 +0000 | [diff] [blame] | 7 | |
Ted Kremenek | 68d2368 | 2008-06-21 17:20:55 +0000 | [diff] [blame] | 8 | #include <stdint.h> |
Ted Kremenek | 46c82ab | 2008-06-19 17:55:38 +0000 | [diff] [blame] | 9 | |
| 10 | int 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 | } |