]> granicus.if.org Git - clang/commitdiff
[analyzer] add more buffer overflow tests to show we handle sizeof(VLA) in obstruse...
authorTed Kremenek <kremenek@apple.com>
Sat, 6 Aug 2011 00:34:48 +0000 (00:34 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 6 Aug 2011 00:34:48 +0000 (00:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137007 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis/outofbound.c

index 665195565d30b1fced8ffdcd75f7a3d11fbd547a..f5a24c90683a0d76a9192a872e810984297d7fa6 100644 (file)
@@ -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);