| author | |
| committer | |
| log | c3362c1cb63ff8d8e79a16c76a574bbbd488967c |
| tree | 47e5c4e90947056a5b5c3e42c87cad1d664dd443 |
| parent | 87970920c493de2f2d4606dfef92bb847e07105f |
all tests passing3 files changed, 11 insertions(+), 15 deletions(-)
src/analyze.cpp+7-3| ... | ... | @@ -1180,7 +1180,8 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c |
| 1180 | 1180 | } |
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | fn_type_id.return_type = analyze_type_expr(g, child_scope, fn_proto->return_type); | |
| 1183 | fn_type_id.return_type = (fn_proto->return_type == nullptr) ? | |
| 1184 | g->builtin_types.entry_void : analyze_type_expr(g, child_scope, fn_proto->return_type); | |
| 1184 | 1185 | |
| 1185 | 1186 | switch (fn_type_id.return_type->id) { |
| 1186 | 1187 | case TypeTableEntryIdInvalid: |
| ... | ... | @@ -2056,7 +2057,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { |
| 2056 | 2057 | for (size_t i = 0; i < fn_proto->params.length; i += 1) { |
| 2057 | 2058 | AstNode *param_node = fn_proto->params.at(i); |
| 2058 | 2059 | assert(param_node->type == NodeTypeParamDecl); |
| 2059 | if (buf_len(param_node->data.param_decl.name) == 0) { | |
| 2060 | if (param_node->data.param_decl.name == nullptr) { | |
| 2060 | 2061 | add_node_error(g, param_node, buf_sprintf("missing parameter name")); |
| 2061 | 2062 | } |
| 2062 | 2063 | } |
| ... | ... | @@ -2268,7 +2269,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) { |
| 2268 | 2269 | { |
| 2269 | 2270 | // if the name is missing, we immediately announce an error |
| 2270 | 2271 | Buf *fn_name = node->data.fn_proto.name; |
| 2271 | if (buf_len(fn_name) == 0) { | |
| 2272 | if (fn_name == nullptr) { | |
| 2272 | 2273 | add_node_error(g, node, buf_sprintf("missing function name")); |
| 2273 | 2274 | break; |
| 2274 | 2275 | } |
| ... | ... | @@ -2950,6 +2951,9 @@ void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entry, Vari |
| 2950 | 2951 | } else { |
| 2951 | 2952 | param_name = buf_sprintf("arg%" ZIG_PRI_usize "", i); |
| 2952 | 2953 | } |
| 2954 | if (param_name == nullptr) { | |
| 2955 | continue; | |
| 2956 | } | |
| 2953 | 2957 | |
| 2954 | 2958 | TypeTableEntry *param_type = param_info->type; |
| 2955 | 2959 | bool is_noalias = param_info->is_noalias; |
src/ir.cpp+1-1| ... | ... | @@ -6116,7 +6116,7 @@ static IrInstruction *ir_gen_fn_proto(IrBuilder *irb, Scope *parent_scope, AstNo |
| 6116 | 6116 | |
| 6117 | 6117 | IrInstruction *return_type; |
| 6118 | 6118 | if (node->data.fn_proto.return_type == nullptr) { |
| 6119 | return_type = ir_build_const_void(irb, parent_scope, node); | |
| 6119 | return_type = ir_build_const_type(irb, parent_scope, node, irb->codegen->builtin_types.entry_void); | |
| 6120 | 6120 | } else { |
| 6121 | 6121 | return_type = ir_gen_node(irb, node->data.fn_proto.return_type, parent_scope); |
| 6122 | 6122 | if (return_type == irb->codegen->invalid_instruction) |
src/parseh.cpp+3-11| ... | ... | @@ -1620,9 +1620,7 @@ static void visit_fn_decl(Context *c, const FunctionDecl *fn_decl) { |
| 1620 | 1620 | return; |
| 1621 | 1621 | } |
| 1622 | 1622 | |
| 1623 | const FunctionProtoType *fn_proto_ty = (const FunctionProtoType *) fn_decl->getType().getTypePtr(); | |
| 1624 | size_t arg_count = fn_proto_ty->getNumParams(); | |
| 1625 | for (size_t i = 0; i < arg_count; i += 1) { | |
| 1623 | for (size_t i = 0; i < proto_node->data.fn_proto.params.length; i += 1) { | |
| 1626 | 1624 | AstNode *param_node = proto_node->data.fn_proto.params.at(i); |
| 1627 | 1625 | const ParmVarDecl *param = fn_decl->getParamDecl(i); |
| 1628 | 1626 | const char *name = decl_name(param); |
| ... | ... | @@ -2036,13 +2034,7 @@ static bool decl_visitor(void *context, const Decl *decl) { |
| 2036 | 2034 | } |
| 2037 | 2035 | |
| 2038 | 2036 | static bool name_exists(Context *c, Buf *name) { |
| 2039 | if (get_global(c, name)) { | |
| 2040 | return true; | |
| 2041 | } | |
| 2042 | if (c->macro_table.maybe_get(name)) { | |
| 2043 | return true; | |
| 2044 | } | |
| 2045 | return false; | |
| 2037 | return get_global(c, name) != nullptr; | |
| 2046 | 2038 | } |
| 2047 | 2039 | |
| 2048 | 2040 | static void render_aliases(Context *c) { |
| ... | ... | @@ -2162,7 +2154,7 @@ static void process_symbol_macros(Context *c) { |
| 2162 | 2154 | |
| 2163 | 2155 | // Check if this macro aliases another top level declaration |
| 2164 | 2156 | AstNode *existing_node = get_global(c, ms.value); |
| 2165 | if (!existing_node) | |
| 2157 | if (!existing_node || name_exists(c, ms.name)) | |
| 2166 | 2158 | continue; |
| 2167 | 2159 | |
| 2168 | 2160 | // If a macro aliases a global variable which is a function pointer, we conclude that |