]> granicus.if.org Git - clang/commitdiff
Add 'alloca' test case for return-of-stack-address checker.
authorTed Kremenek <kremenek@apple.com>
Sun, 2 Nov 2008 00:37:31 +0000 (00:37 +0000)
committerTed Kremenek <kremenek@apple.com>
Sun, 2 Nov 2008 00:37:31 +0000 (00:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58554 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis/stack-addr-ps.c

index bc046cd7135907fd0f839ab823d0e7c8096b3218..2173cac0c45285a2a49ae469ed898d2931438e0f 100644 (file)
@@ -1,5 +1,7 @@
 // RUN: clang -checker-simple -verify %s
 
+#include <stdlib.h>
+
 int* f1() {
   int x = 0;
   return &x; // expected-warning{{Address of stack memory associated with local variable 'x' returned.}} expected-warning{{address of stack memory associated with local variable 'x' returned}}
@@ -33,3 +35,8 @@ void* compound_literal(int x, int y) {
   return p; // expected-warning{{Address of stack memory}}
 }
 
+void* alloca_test() {
+  void* p = alloca(10);
+  return p; // expected-warning{{Address of stack memory}}
+}
+