summaryrefslogtreecommitdiff
path: root/debuginfo-tests
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2017-04-06 17:40:31 +0000
committerAdrian Prantl <aprantl@apple.com>2017-04-06 17:40:31 +0000
commit441c193ba9e531f0fc02f8a23737dbefff07a70a (patch)
treeb76f0f3e7ea0626b27f3752d753353cb7d791961 /debuginfo-tests
parentc123446185ecb7c171ee1601b8124f6dc26a7c15 (diff)
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.
Diffstat (limited to 'debuginfo-tests')
-rw-r--r--debuginfo-tests/vla.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/debuginfo-tests/vla.c b/debuginfo-tests/vla.c
new file mode 100644
index 00000000000..9c8e2771533
--- /dev/null
+++ b/debuginfo-tests/vla.c
@@ -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;
+}