summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/asan/TestCases/Windows/wrong_downcast_on_stack.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-08-05 16:48:12 +0000
committerNico Weber <nicolasweber@gmx.de>2019-08-05 16:48:12 +0000
commit673dc3d4a0b0fbb3b9b34ae2ecbfa522627fe582 (patch)
tree93e9f9c3508af096ba717ef85186950135b4c225 /compiler-rt/test/asan/TestCases/Windows/wrong_downcast_on_stack.cpp
parenta96cfee98a22e262367868f343b599c2312149b7 (diff)
downloadbcm5719-llvm-673dc3d4a0b0fbb3b9b34ae2ecbfa522627fe582.tar.gz
bcm5719-llvm-673dc3d4a0b0fbb3b9b34ae2ecbfa522627fe582.zip
compiler-rt: Rename cc files below test/asan to cpp
See r367803 and similar other changes. llvm-svn: 367887
Diffstat (limited to 'compiler-rt/test/asan/TestCases/Windows/wrong_downcast_on_stack.cpp')
-rw-r--r--compiler-rt/test/asan/TestCases/Windows/wrong_downcast_on_stack.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/compiler-rt/test/asan/TestCases/Windows/wrong_downcast_on_stack.cpp b/compiler-rt/test/asan/TestCases/Windows/wrong_downcast_on_stack.cpp
new file mode 100644
index 00000000000..267775e4689
--- /dev/null
+++ b/compiler-rt/test/asan/TestCases/Windows/wrong_downcast_on_stack.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cl_asan -Od %s -Fe%t
+// RUN: not %run %t 2>&1 | FileCheck %s
+
+class Parent {
+ public:
+ int field;
+};
+
+class Child : public Parent {
+ public:
+ int extra_field;
+};
+
+int main(void) {
+ Parent p;
+ Child *c = (Child*)&p; // Intentional error here!
+ c->extra_field = 42;
+// CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
+// CHECK: WRITE of size 4 at [[ADDR]] thread T0
+// CHECK-NEXT: {{#0 0x[0-9a-f]* in main .*wrong_downcast_on_stack.cpp}}:[[@LINE-3]]
+// CHECK: [[ADDR]] is located in stack of thread T0 at offset [[OFFSET:[0-9]+]] in frame
+// CHECK-NEXT: {{#0 0x[0-9a-f]* in main }}
+// CHECK: 'p'{{.*}} <== Memory access at offset [[OFFSET]] overflows this variable
+ return 0;
+}
+
OpenPOWER on IntegriCloud