complex.c revision 9457a800f1fea4db4bb595c77de277609913b1b3
1// RUN: clang -analyze -checker-simple -analyzer-store=basic -analyzer-constraints=basic -verify %s && 2// RUN: clang -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -verify %s && 3// RUN: clang -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range -verify %s && 4// RUN: clang -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify %s && 5// RUN: clang -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify %s 6 7#include <stdint.h> 8 9int 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} 22