diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-01-11 19:09:17 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-01-11 19:09:17 -0500 |
| commit | 25a670d74e16463c7a8f91c3af91f44bf52a9e27 (patch) | |
| tree | 976b0e279fe21ca7407356cdf804c5cbb49b52a2 /src | |
| parent | de9ecaf96470c9d2b9f165608a57ba03c9c0f17c (diff) | |
| download | zig-25a670d74e16463c7a8f91c3af91f44bf52a9e27.tar.gz zig-25a670d74e16463c7a8f91c3af91f44bf52a9e27.zip | |
pass more tests
Diffstat (limited to 'src')
| -rw-r--r-- | src/all_types.hpp | 1 | ||||
| -rw-r--r-- | src/ast_render.cpp | 5 | ||||
| -rw-r--r-- | src/ir.cpp | 6 | ||||
| -rw-r--r-- | src/parseh.cpp | 14 |
4 files changed, 25 insertions, 1 deletions
diff --git a/src/all_types.hpp b/src/all_types.hpp index 791ac24451..bd322d114c 100644 --- a/src/all_types.hpp +++ b/src/all_types.hpp @@ -1022,6 +1022,7 @@ struct FnTableEntry { IrExecutable analyzed_executable; size_t prealloc_bbc; AstNode **param_source_nodes; + Buf **param_names; AstNode *fn_no_inline_set_node; AstNode *fn_export_set_node; diff --git a/src/ast_render.cpp b/src/ast_render.cpp index 0ade4005bc..6fc8c31fb4 100644 --- a/src/ast_render.cpp +++ b/src/ast_render.cpp @@ -902,10 +902,13 @@ static void ast_render_tld_fn(AstRender *ar, TldFn *tld_fn) { fprintf(ar->f, "%s%s%s%sfn %s(", visib_mod_str, extern_str, coldcc_str, nakedcc_str, buf_ptr(&fn_entry->symbol_name)); for (size_t i = 0; i < fn_type_id->param_count; i += 1) { FnTypeParamInfo *param_info = &fn_type_id->param_info[i]; + if (i != 0) { + fprintf(ar->f, ", "); + } if (param_info->is_noalias) { fprintf(ar->f, "noalias "); } - fprintf(ar->f, "arg_%zu: %s", i, buf_ptr(¶m_info->type->name)); + fprintf(ar->f, "%s: %s", buf_ptr(tld_fn->fn_entry->param_names[i]), buf_ptr(¶m_info->type->name)); } if (fn_type_id->return_type->id == TypeTableEntryIdVoid) { fprintf(ar->f, ");\n"); diff --git a/src/ir.cpp b/src/ir.cpp index a7367472aa..c5d647cdca 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -8471,6 +8471,9 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source FnTableEntry *fn_entry = tld_fn->fn_entry; assert(fn_entry->type_entry); + if (fn_entry->type_entry->id == TypeTableEntryIdInvalid) + return ira->codegen->builtin_types.entry_invalid; + // TODO instead of allocating this every time, put it in the tld value and we can reference // the same one every time ConstExprValue *const_val = allocate<ConstExprValue>(1); @@ -8568,6 +8571,9 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru } else if (is_container(child_type)) { if (child_type->id == TypeTableEntryIdEnum) { ensure_complete_type(ira->codegen, child_type); + if (child_type->data.enumeration.is_invalid) + return ira->codegen->builtin_types.entry_invalid; + TypeEnumField *field = find_enum_type_field(child_type, field_name); if (field) { if (field->type_entry->id == TypeTableEntryIdVoid) { diff --git a/src/parseh.cpp b/src/parseh.cpp index dcd34d342d..ff2f9c129a 100644 --- a/src/parseh.cpp +++ b/src/parseh.cpp @@ -618,6 +618,20 @@ static void visit_fn_decl(Context *c, const FunctionDecl *fn_decl) { assert(!fn_type->data.fn.fn_type_id.is_naked); + size_t arg_count = fn_type->data.fn.fn_type_id.param_count; + fn_entry->param_names = allocate<Buf *>(arg_count); + Buf *name_buf; + for (size_t i = 0; i < arg_count; i += 1) { + const ParmVarDecl *param = fn_decl->getParamDecl(i); + const char *name = decl_name(param); + if (strlen(name) == 0) { + name_buf = buf_sprintf("arg%zu", i); + } else { + name_buf = buf_create_from_str(name); + } + fn_entry->param_names[i] = name_buf; + } + TldFn *tld_fn = allocate<TldFn>(1); parseh_init_tld(c, &tld_fn->base, TldIdFn, fn_name); tld_fn->fn_entry = fn_entry; |
