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