[cfe-commits] r137007 - /cfe/trunk/test/Analysis/outofbound.c

Ted Kremenek kremenek at apple.com
Fri Aug 5 17:34:48 PDT 2011


Author: kremenek
Date: Fri Aug  5 19:34:48 2011
New Revision: 137007

URL: http://llvm.org/viewvc/llvm-project?rev=137007&view=rev
Log:
[analyzer] add more buffer overflow tests to show we handle sizeof(VLA) in obstruse ways...

Modified:
    cfe/trunk/test/Analysis/outofbound.c

Modified: cfe/trunk/test/Analysis/outofbound.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/outofbound.c?rev=137007&r1=137006&r2=137007&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/outofbound.c (original)
+++ cfe/trunk/test/Analysis/outofbound.c Fri Aug  5 19:34:48 2011
@@ -72,6 +72,24 @@
   }
 }
 
+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);





More information about the cfe-commits mailing list