aboutsummaryrefslogtreecommitdiff
path: root/lib/ubsan/lit_tests/Misc/vla.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ubsan/lit_tests/Misc/vla.c')
-rw-r--r--lib/ubsan/lit_tests/Misc/vla.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/ubsan/lit_tests/Misc/vla.c b/lib/ubsan/lit_tests/Misc/vla.c
new file mode 100644
index 000000000000..2fa88addc0d3
--- /dev/null
+++ b/lib/ubsan/lit_tests/Misc/vla.c
@@ -0,0 +1,11 @@
+// RUN: %clang -fsanitize=vla-bound %s -O3 -o %t
+// RUN: %t 2>&1 | FileCheck %s --check-prefix=CHECK-MINUS-ONE
+// RUN: %t a 2>&1 | FileCheck %s --check-prefix=CHECK-ZERO
+// RUN: %t a b
+
+int main(int argc, char **argv) {
+ // CHECK-MINUS-ONE: vla.c:9:11: runtime error: variable length array bound evaluates to non-positive value -1
+ // CHECK-ZERO: vla.c:9:11: runtime error: variable length array bound evaluates to non-positive value 0
+ int arr[argc - 2];
+ return 0;
+}