From: Ted Kremenek Date: Sun, 2 Nov 2008 00:37:31 +0000 (+0000) Subject: Add 'alloca' test case for return-of-stack-address checker. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c979a9b066d998d73fb3a5ae293b7bbf78576e47;p=clang Add 'alloca' test case for return-of-stack-address checker. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58554 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Analysis/stack-addr-ps.c b/test/Analysis/stack-addr-ps.c index bc046cd713..2173cac0c4 100644 --- a/test/Analysis/stack-addr-ps.c +++ b/test/Analysis/stack-addr-ps.c @@ -1,5 +1,7 @@ // RUN: clang -checker-simple -verify %s +#include + 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}} +} +