xref: /minix3/external/bsd/llvm/dist/clang/test/Analysis/ptr-arith.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s
2*f4a2713aSLionel Sambuc // expected-no-diagnostics
3*f4a2713aSLionel Sambuc struct X {
4*f4a2713aSLionel Sambuc   int *p;
5*f4a2713aSLionel Sambuc   int zero;
fooX6*f4a2713aSLionel Sambuc   void foo () {
7*f4a2713aSLionel Sambuc     reset(p - 1);
8*f4a2713aSLionel Sambuc   }
resetX9*f4a2713aSLionel Sambuc   void reset(int *in) {
10*f4a2713aSLionel Sambuc     while (in != p) // Loop must be entered.
11*f4a2713aSLionel Sambuc       zero = 1;
12*f4a2713aSLionel Sambuc   }
13*f4a2713aSLionel Sambuc };
14*f4a2713aSLionel Sambuc 
test(int * in)15*f4a2713aSLionel Sambuc int test (int *in) {
16*f4a2713aSLionel Sambuc   X littleX;
17*f4a2713aSLionel Sambuc   littleX.zero = 0;
18*f4a2713aSLionel Sambuc   littleX.p = in;
19*f4a2713aSLionel Sambuc   littleX.foo();
20*f4a2713aSLionel Sambuc   return 5/littleX.zero; // no-warning
21*f4a2713aSLionel Sambuc }
22*f4a2713aSLionel Sambuc 
23