[debuginfo-tests] r299668 - Add a testcase for variable-length arrays.

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 6 10:40:31 PDT 2017


Author: adrian
Date: Thu Apr  6 12:40:31 2017
New Revision: 299668

URL: http://llvm.org/viewvc/llvm-project?rev=299668&view=rev
Log:
Add a testcase for variable-length arrays.

VLAs are special-cased in the frontend. This testcase ensures that the
contract between clang and llvm won't be accidentally broken by future
refactorings.

Added:
    debuginfo-tests/trunk/vla.c

Added: debuginfo-tests/trunk/vla.c
URL: http://llvm.org/viewvc/llvm-project/debuginfo-tests/trunk/vla.c?rev=299668&view=auto
==============================================================================
--- debuginfo-tests/trunk/vla.c (added)
+++ debuginfo-tests/trunk/vla.c Thu Apr  6 12:40:31 2017
@@ -0,0 +1,24 @@
+// This test case verifies the debug location for variable-length arrays.
+// RUN: %clang %target_itanium_abi_host_triple -O0 -g %s -c -o %t.o
+// RUN: %clang %target_itanium_abi_host_triple %t.o -o %t.out
+// RUN: %test_debuginfo %s %t.out 
+//
+// DEBUGGER: break 18
+// DEBUGGER: r
+// DEBUGGER: p vla[0]
+// CHECK: 23
+// DEBUGGER: p vla[1]
+// CHECK: 22
+
+void init_vla(int size) {
+  int i;
+  int vla[size];
+  for (i = 0; i < size; i++)
+    vla[i] = size-i;
+  vla[0] = size; // line 18
+}
+
+int main(int argc, const char **argv) {
+  init_vla(23);
+  return 0;
+}




More information about the llvm-commits mailing list