diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/all_types.hpp | 1 | ||||
| -rw-r--r-- | src/analyze.cpp | 4 | ||||
| -rw-r--r-- | src/codegen.cpp | 5 | ||||
| -rw-r--r-- | src/parseh.cpp | 17 |
4 files changed, 10 insertions, 17 deletions
diff --git a/src/all_types.hpp b/src/all_types.hpp index 6d6affd440..f7fd0a46a4 100644 --- a/src/all_types.hpp +++ b/src/all_types.hpp @@ -1062,6 +1062,7 @@ struct CodeGen { TypeTableEntry *entry_int[2][4]; // [signed,unsigned][8,16,32,64] TypeTableEntry *entry_c_int[CIntTypeCount]; TypeTableEntry *entry_c_long_double; + TypeTableEntry *entry_c_void; TypeTableEntry *entry_u8; TypeTableEntry *entry_u16; TypeTableEntry *entry_u32; diff --git a/src/analyze.cpp b/src/analyze.cpp index 1c23f7003d..9e0223c193 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -2320,9 +2320,9 @@ static TypeTableEntry *analyze_field_access_expr(CodeGen *g, ImportTableEntry *i bool pointer_only = false; return analyze_decl_ref(g, node, decl_node, pointer_only); } else { + const char *import_name = namespace_import->path ? buf_ptr(namespace_import->path) : "(C import)"; add_node_error(g, node, - buf_sprintf("no member named '%s' in '%s'", buf_ptr(field_name), - buf_ptr(namespace_import->path))); + buf_sprintf("no member named '%s' in '%s'", buf_ptr(field_name), import_name)); return g->builtin_types.entry_invalid; } } else { diff --git a/src/codegen.cpp b/src/codegen.cpp index 4ee6074e21..b1edd1b4f9 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3552,6 +3552,11 @@ static void define_builtin_types(CodeGen *g) { g->builtin_types.entry_i64 = get_int_type(g, true, 64); { + g->builtin_types.entry_c_void = get_typedecl_type(g, "c_void", g->builtin_types.entry_u8); + g->primitive_type_table.put(&g->builtin_types.entry_c_void->name, g->builtin_types.entry_c_void); + } + + { TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdPureError); buf_init_from_str(&entry->name, "error"); diff --git a/src/parseh.cpp b/src/parseh.cpp index 929a22c8b1..e7b2f1ea42 100644 --- a/src/parseh.cpp +++ b/src/parseh.cpp @@ -36,7 +36,6 @@ struct Context { ZigList<ErrorMsg *> *errors; bool warnings_on; VisibMod visib_mod; - TypeTableEntry *c_void_type; AstNode *root; HashMap<Buf *, TypeTableEntry *, buf_hash, buf_eql_buf> global_type_table; HashMap<Buf *, GlobalValue, buf_hash, buf_eql_buf> global_value_table; @@ -292,21 +291,9 @@ static AstNode *add_const_var_node(Context *c, Buf *name, TypeTableEntry *type_e return node; } -static TypeTableEntry *get_c_void_type(Context *c) { - if (!c->c_void_type) { - c->c_void_type = get_typedecl_type(c->codegen, "c_void", c->codegen->builtin_types.entry_u8); - add_typedef_node(c, c->c_void_type); - } - - return c->c_void_type; -} - static bool is_c_void_type(Context *c, TypeTableEntry *type_entry) { - if (!c->c_void_type) { - return false; - } while (type_entry->id == TypeTableEntryIdTypeDecl) { - if (type_entry == c->c_void_type) { + if (type_entry == c->codegen->builtin_types.entry_c_void) { return true; } type_entry = type_entry->data.type_decl.child_type; @@ -336,7 +323,7 @@ static TypeTableEntry *resolve_type_with_table(Context *c, const Type *ty, const const BuiltinType *builtin_ty = static_cast<const BuiltinType*>(ty); switch (builtin_ty->getKind()) { case BuiltinType::Void: - return get_c_void_type(c); + return c->codegen->builtin_types.entry_c_void; case BuiltinType::Bool: return c->codegen->builtin_types.entry_bool; case BuiltinType::Char_U: |
