authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-25 21:28:16-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-25 21:28:16-04:00
log720302a6407e954ffccf65f38ad40b47868627ce
tree959b2b287fad50c77b5a5bbee121d2dd1fad5796
parenta7f31581850fe2811bc5114459a8d193dd48b42a
signaturelock-open Commit is signed but in an unrecognized format.

fix resolution detection of pointer types


2 files changed, 30 insertions(+), 6 deletions(-)

src/analyze.cpp+14-1
......@@ -289,13 +289,26 @@ bool type_is_resolved(ZigType *type_entry, ResolveStatus status) {
289289 }
290290 case ZigTypeIdOpaque:
291291 return status < ResolveStatusSizeKnown;
292 case ZigTypeIdPointer:
293 switch (status) {
294 case ResolveStatusInvalid:
295 zig_unreachable();
296 case ResolveStatusUnstarted:
297 return true;
298 case ResolveStatusZeroBitsKnown:
299 case ResolveStatusAlignmentKnown:
300 case ResolveStatusSizeKnown:
301 return type_entry->abi_size != SIZE_MAX;
302 case ResolveStatusLLVMFwdDecl:
303 case ResolveStatusLLVMFull:
304 return type_entry->llvm_type != nullptr;
305 }
292306 case ZigTypeIdMetaType:
293307 case ZigTypeIdVoid:
294308 case ZigTypeIdBool:
295309 case ZigTypeIdUnreachable:
296310 case ZigTypeIdInt:
297311 case ZigTypeIdFloat:
298 case ZigTypeIdPointer:
299312 case ZigTypeIdArray:
300313 case ZigTypeIdComptimeFloat:
301314 case ZigTypeIdComptimeInt:
src/ir.cpp+16-5
......@@ -23338,6 +23338,12 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_
2333823338
2333923339 IrInstruction *casted_ptr = ir_build_ptr_cast_gen(ira, source_instr, dest_type, ptr, safety_check_on);
2334023340
23341 if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown)))
23342 return ira->codegen->invalid_instruction;
23343
23344 if ((err = type_resolve(ira->codegen, src_type, ResolveStatusZeroBitsKnown)))
23345 return ira->codegen->invalid_instruction;
23346
2334123347 if (type_has_bits(dest_type) && !type_has_bits(src_type)) {
2334223348 ErrorMsg *msg = ir_add_error(ira, source_instr,
2334323349 buf_sprintf("'%s' and '%s' do not have the same in-memory representation",
......@@ -25435,6 +25441,7 @@ bool ir_has_side_effects(IrInstruction *instruction) {
2543525441static ZigType *ir_resolve_lazy_fn_type(CodeGen *codegen, IrExecutable *exec, AstNode *source_node,
2543625442 LazyValueFnType *lazy_fn_type)
2543725443{
25444 Error err;
2543825445 AstNode *proto_node = lazy_fn_type->proto_node;
2543925446
2544025447 FnTypeId fn_type_id = {0};
......@@ -25482,11 +25489,15 @@ static ZigType *ir_resolve_lazy_fn_type(CodeGen *codegen, IrExecutable *exec, As
2548225489 case ReqCompTimeNo:
2548325490 break;
2548425491 }
25485 if (!type_has_bits(param_type) && !calling_convention_allows_zig_types(fn_type_id.cc)) {
25486 exec_add_error_node(codegen, exec, source_node,
25487 buf_sprintf("parameter of type '%s' has 0 bits; not allowed in function with calling convention '%s'",
25488 buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc)));
25489 return nullptr;
25492 if (!calling_convention_allows_zig_types(fn_type_id.cc)) {
25493 if ((err = type_resolve(codegen, param_type, ResolveStatusZeroBitsKnown)))
25494 return nullptr;
25495 if (!type_has_bits(param_type)) {
25496 exec_add_error_node(codegen, exec, source_node,
25497 buf_sprintf("parameter of type '%s' has 0 bits; not allowed in function with calling convention '%s'",
25498 buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc)));
25499 return nullptr;
25500 }
2549025501 }
2549125502 param_info->type = param_type;
2549225503 }