aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-01-18 15:08:20 -0500
committerAndrew Kelley <superjoe30@gmail.com>2018-01-18 15:08:20 -0500
commit0b8f19fcba04cde35ca4831f37f8249d51da9432 (patch)
tree2a75676d565b2bf31ad955ce4b2b659e85ce3791
parent0aae96b5f0a592ee3e2ff3607121740042878634 (diff)
downloadzig-0b8f19fcba04cde35ca4831f37f8249d51da9432.tar.gz
zig-0b8f19fcba04cde35ca4831f37f8249d51da9432.zip
fix null debug info for 0-length array type
closes #702
-rw-r--r--src/analyze.cpp5
-rw-r--r--test/cases/var_args.zig8
2 files changed, 12 insertions, 1 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 9da8485014..1bdd8bede4 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -609,7 +609,10 @@ TypeTableEntry *get_array_type(CodeGen *g, TypeTableEntry *child_type, uint64_t
buf_resize(&entry->name, 0);
buf_appendf(&entry->name, "[%" ZIG_PRI_u64 "]%s", array_size, buf_ptr(&child_type->name));
- if (!entry->zero_bits) {
+ if (entry->zero_bits) {
+ entry->di_type = ZigLLVMCreateDebugArrayType(g->dbuilder, 0,
+ 0, child_type->di_type, 0);
+ } else {
entry->type_ref = child_type->type_ref ? LLVMArrayType(child_type->type_ref,
(unsigned int)array_size) : nullptr;
diff --git a/test/cases/var_args.zig b/test/cases/var_args.zig
index 7d16106362..aa8b210ad6 100644
--- a/test/cases/var_args.zig
+++ b/test/cases/var_args.zig
@@ -79,3 +79,11 @@ fn assertSlicePtrsEql(args: ...) {
assert(s1.ptr == s2.ptr);
}
+
+test "pass zero length array to var args param" {
+ doNothingWithFirstArg("");
+}
+
+fn doNothingWithFirstArg(args: ...) {
+ const a = args[0];
+}