Clang Project

clang_source_code/test/Analysis/complex.c
1// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -verify -Wno-unreachable-code -ffreestanding %s
2
3#include <stdint.h>
4
5void f1(int * p) {
6  
7  // This branch should be infeasible
8  // because __imag__ p is 0.
9  if (!p && __imag__ (intptr_t) p)
10    *p = 1; // no-warning
11
12  // If p != 0 then this branch is feasible; otherwise it is not.
13  if (__real__ (intptr_t) p)
14    *p = 1; // no-warning
15    
16  *p = 2; // expected-warning{{Dereference of null pointer}}
17}
18