diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-08-06 00:34:48 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-08-06 00:34:48 +0000 |
commit | 7765dda06a9e9bfe3397e591e7d85c6b711657b4 (patch) | |
tree | 31b8c3f42ca0a88642645f120f26b5123be75342 /clang/test | |
parent | 84a1ca52807a4fd79dd1b43aa3700514638b0c65 (diff) | |
download | bcm5719-llvm-7765dda06a9e9bfe3397e591e7d85c6b711657b4.tar.gz bcm5719-llvm-7765dda06a9e9bfe3397e591e7d85c6b711657b4.zip |
[analyzer] add more buffer overflow tests to show we handle sizeof(VLA) in obstruse ways...
llvm-svn: 137007
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/Analysis/outofbound.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/test/Analysis/outofbound.c b/clang/test/Analysis/outofbound.c index 665195565d3..f5a24c90683 100644 --- a/clang/test/Analysis/outofbound.c +++ b/clang/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); |