complex.c revision 65d39251ff57b8e33cf6d3a7fcc6aa1c6f8cdc68
1// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify -Wno-unreachable-code -ffreestanding %s
2// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify -Wno-unreachable-code -ffreestanding %s
3// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify -Wno-unreachable-code -ffreestanding %s
4// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify -Wno-unreachable-code -ffreestanding %s
5
6#include <stdint.h>
7
8void f1(int * p) {
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}
21