[cfe-commits] r41181 - /cfe/trunk/test/Sema/return-stack-addr.cpp

Ted Kremenek kremenek at apple.com
Mon Aug 20 09:28:06 PDT 2007


Author: kremenek
Date: Mon Aug 20 11:28:05 2007
New Revision: 41181

URL: http://llvm.org/viewvc/llvm-project?rev=41181&view=rev
Log:
Added test cases for the return-stack-address checker to test support
for the following C++ casts: static_cast, reinterpret_cast, and const_cast.

Modified:
    cfe/trunk/test/Sema/return-stack-addr.cpp

Modified: cfe/trunk/test/Sema/return-stack-addr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/return-stack-addr.cpp?rev=41181&r1=41180&r2=41181&view=diff

==============================================================================
--- cfe/trunk/test/Sema/return-stack-addr.cpp (original)
+++ cfe/trunk/test/Sema/return-stack-addr.cpp Mon Aug 20 11:28:05 2007
@@ -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





More information about the cfe-commits mailing list