-fcatch-undefined-behavior: catch a VLA bound which evalutes to a non-positive value.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165583 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGen/catch-undef-behavior.c b/test/CodeGen/catch-undef-behavior.c
index 2fe61ea..e8b5cbc 100644
--- a/test/CodeGen/catch-undef-behavior.c
+++ b/test/CodeGen/catch-undef-behavior.c
@@ -15,6 +15,7 @@
 
 // CHECK: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} @[[STRUCT_S]], i64 4, i8 3 }
 // CHECK: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }
+// CHECK: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }
 
 // PR6805
 // CHECK: @foo
@@ -130,3 +131,13 @@
   // CHECK-NOT: unreachable
   // CHECK: ret i32
 }
+
+// CHECK: @vla_bound
+void vla_bound(int n) {
+  // CHECK:      icmp sgt i32 %[[PARAM:.*]], 0
+  //
+  // CHECK:      %[[ARG:.*]] = zext i32 %[[PARAM]] to i64
+  // CHECK-NEXT: call void @__ubsan_handle_vla_bound_not_positive(i8* bitcast ({{.*}} @[[LINE_900]] to i8*), i64 %[[ARG]]) noreturn nounwind
+#line 900
+  int arr[n * 3];
+}