Added test cases for the return-stack-address checker to test support
for the following C++ casts: static_cast, reinterpret_cast, and const_cast.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41181 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/return-stack-addr.cpp b/test/Sema/return-stack-addr.cpp
index a613b6b..ce4c41b 100644
--- a/test/Sema/return-stack-addr.cpp
+++ b/test/Sema/return-stack-addr.cpp
@@ -86,4 +86,28 @@
int* ret_global() {
return &z; // no warning.
-}
\ No newline at end of file
+}
+
+int* ret_parameter(int x) {
+ return &x; // expected-warning {{address of stack memory}}
+}
+
+
+int* ret_cpp_static_cast(short x) {
+ return static_cast<int*>(&x); // expected-warning {{address of stack memory}}
+}
+
+int* ret_cpp_reinterpret_cast(double x) {
+ return reinterpret_cast<int*>(&x); // expected-warning {{address of stack me}}
+}
+
+int* ret_cpp_reinterpret_cast_no_warning(double x) {
+ return reinterpret_cast<int*>(x); // no-warning
+}
+
+int* ret_cpp_const_cast(const x) {
+ return const_cast<int*>(&x); // expected-warning {{address of stack memory}}
+}
+
+// TODO: test case for dynamic_cast. clang does not yet have
+// support for C++ classes to write such a test case.
\ No newline at end of file