summaryrefslogtreecommitdiffstats
path: root/test/Analysis/cxx-crashes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/cxx-crashes.cpp')
-rw-r--r--test/Analysis/cxx-crashes.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/Analysis/cxx-crashes.cpp b/test/Analysis/cxx-crashes.cpp
new file mode 100644
index 0000000..c9775df
--- /dev/null
+++ b/test/Analysis/cxx-crashes.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -verify %s
+
+int f1(char *dst) {
+ char *p = dst + 4;
+ char *q = dst + 3;
+ return !(q >= p);
+}
+
+long f2(char *c) {
+ return long(c) & 1;
+}
+
+bool f3() {
+ return !false;
+}
+
+void *f4(int* w) {
+ return reinterpret_cast<void*&>(w);
+}
+
+namespace {
+
+struct A { };
+struct B {
+ operator A() { return A(); }
+};
+
+A f(char *dst) {
+ B b;
+ return b;
+}
+
+}
+
+namespace {
+
+struct S {
+ void *p;
+};
+
+void *f(S* w) {
+ return &reinterpret_cast<void*&>(*w);
+}
+
+}
OpenPOWER on IntegriCloud