summaryrefslogtreecommitdiffstats
path: root/test/Analysis/reinterpret-cast.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/reinterpret-cast.cpp')
-rw-r--r--test/Analysis/reinterpret-cast.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/Analysis/reinterpret-cast.cpp b/test/Analysis/reinterpret-cast.cpp
new file mode 100644
index 0000000..73f2e2d
--- /dev/null
+++ b/test/Analysis/reinterpret-cast.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=inlining -verify %s
+
+void clang_analyzer_eval(bool);
+
+typedef struct Opaque *Data;
+struct IntWrapper {
+ int x;
+};
+
+struct Child : public IntWrapper {
+ void set() { x = 42; }
+};
+
+void test(Data data) {
+ Child *wrapper = reinterpret_cast<Child*>(data);
+ // Don't crash when upcasting here.
+ // We don't actually know if 'data' is a Child.
+ wrapper->set();
+ clang_analyzer_eval(wrapper->x == 42); // expected-warning{{TRUE}}
+}
OpenPOWER on IntegriCloud