complex.c revision fd28a619da3dda5f9b897abbb469cf699098e965
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-old-cast -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=basic-old-cast -analyzer-constraints=range -verify %s && 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 7 8#include <stdint.h> 9 10void 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} 23