summaryrefslogtreecommitdiff
path: root/test/Analysis/ptr-arith.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2013-12-22 00:07:40 +0000
committerDimitry Andric <dim@FreeBSD.org>2013-12-22 00:07:40 +0000
commitbfef399519ca9b8a4b4c6b563253bad7e0eeffe0 (patch)
treedf8df0b0067b381eab470a3b8f28d14a552a6340 /test/Analysis/ptr-arith.cpp
parent6a0372513edbc473b538d2f724efac50405d6fef (diff)
Diffstat (limited to 'test/Analysis/ptr-arith.cpp')
-rw-r--r--test/Analysis/ptr-arith.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/Analysis/ptr-arith.cpp b/test/Analysis/ptr-arith.cpp
new file mode 100644
index 000000000000..5f0951857b13
--- /dev/null
+++ b/test/Analysis/ptr-arith.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s
+// expected-no-diagnostics
+struct X {
+ int *p;
+ int zero;
+ void foo () {
+ reset(p - 1);
+ }
+ void reset(int *in) {
+ while (in != p) // Loop must be entered.
+ zero = 1;
+ }
+};
+
+int test (int *in) {
+ X littleX;
+ littleX.zero = 0;
+ littleX.p = in;
+ littleX.foo();
+ return 5/littleX.zero; // no-warning
+}
+