From: Ted Kremenek Date: Sat, 6 Aug 2011 00:34:48 +0000 (+0000) Subject: [analyzer] add more buffer overflow tests to show we handle sizeof(VLA) in obstruse... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7d11c3f691674177bc7308c0fc6c82cb745bed0b;p=clang [analyzer] add more buffer overflow tests to show we handle sizeof(VLA) in obstruse ways... git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137007 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Analysis/outofbound.c b/test/Analysis/outofbound.c index 665195565d..f5a24c9068 100644 --- a/test/Analysis/outofbound.c +++ b/test/Analysis/outofbound.c @@ -72,6 +72,24 @@ void sizeof_vla(int a) { } } +void sizeof_vla_2(int a) { + if (a == 5) { + char x[a]; + int y[sizeof(x) / sizeof(char)]; + y[4] = 4; // no-warning + y[5] = 5; // expected-warning{{out-of-bound}} + } +} + +void sizeof_vla_3(int a) { + if (a == 5) { + char x[a]; + int y[sizeof(*&*&*&x)]; + y[4] = 4; // no-warning + y[5] = 5; // expected-warning{{out-of-bound}} + } +} + void alloca_region(int a) { if (a == 5) { char *x = __builtin_alloca(a);