diff options
Diffstat (limited to 'test/Sema/return-stack-addr.cpp')
-rw-r--r-- | test/Sema/return-stack-addr.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/test/Sema/return-stack-addr.cpp b/test/Sema/return-stack-addr.cpp index a613b6b9b6..ce4c41bf7a 100644 --- a/test/Sema/return-stack-addr.cpp +++ b/test/Sema/return-stack-addr.cpp @@ -86,4 +86,28 @@ int z = 1; 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 |