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