authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-12-24 11:28:10+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-01-02 18:53:20+01:00
log271fc6a2479a1c5f2f914c1c40a848bf1b9d70d8
treec0e748428933f8755639b1cb4addf40d027348f3
parent563d9ebfe597b313b265a5a30296c081fe35d87a

Catch more errors during the type resolution phase

Returning the uninitialized/stale error condition made the compiler turn a blind eye to some problems.

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

src/analyze.cpp+5-4
......@@ -2180,7 +2180,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) {
21802180 ZigType *field_type = resolve_struct_field_type(g, field);
21812181 if (field_type == nullptr) {
21822182 struct_type->data.structure.resolve_status = ResolveStatusInvalid;
2183 return err;
2183 return ErrorSemanticAnalyzeFail;
21842184 }
21852185 if ((err = type_resolve(g, field->type_entry, ResolveStatusSizeKnown))) {
21862186 struct_type->data.structure.resolve_status = ResolveStatusInvalid;
......@@ -2270,7 +2270,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) {
22702270 ZigType *field_type = resolve_struct_field_type(g, field);
22712271 if (field_type == nullptr) {
22722272 struct_type->data.structure.resolve_status = ResolveStatusInvalid;
2273 return err;
2273 return ErrorSemanticAnalyzeFail;
22742274 }
22752275
22762276 if ((err = type_resolve(g, field_type, ResolveStatusSizeKnown))) {
......@@ -2340,7 +2340,7 @@ static Error resolve_union_alignment(CodeGen *g, ZigType *union_type) {
23402340 &field->align))
23412341 {
23422342 union_type->data.unionation.resolve_status = ResolveStatusInvalid;
2343 return err;
2343 return ErrorSemanticAnalyzeFail;
23442344 }
23452345 add_node_error(g, field->decl_node,
23462346 buf_create_from_str("TODO implement field alignment syntax for unions. https://github.com/ziglang/zig/issues/3125"));
......@@ -2467,6 +2467,7 @@ static Error resolve_union_type(CodeGen *g, ZigType *union_type) {
24672467 union_type->data.unionation.resolve_status = ResolveStatusInvalid;
24682468 return ErrorSemanticAnalyzeFail;
24692469 }
2470
24702471 if (is_packed) {
24712472 if ((err = emit_error_unless_type_allowed_in_packed_union(g, field_type, union_field->decl_node))) {
24722473 union_type->data.unionation.resolve_status = ResolveStatusInvalid;
......@@ -2925,7 +2926,7 @@ static Error resolve_struct_alignment(CodeGen *g, ZigType *struct_type) {
29252926 &field->align))
29262927 {
29272928 struct_type->data.structure.resolve_status = ResolveStatusInvalid;
2928 return err;
2929 return ErrorSemanticAnalyzeFail;
29292930 }
29302931 } else if (packed) {
29312932 field->align = 1;
src/codegen.cpp+9-2
......@@ -290,10 +290,16 @@ static LLVMCallConv get_llvm_cc(CodeGen *g, CallingConvention cc) {
290290 case CallingConventionFastcall:
291291 if (g->zig_target->arch == ZigLLVM_x86)
292292 return LLVMX86FastcallCallConv;
293 return LLVMFastCallConv;
293 return LLVMCCallConv;
294294 case CallingConventionVectorcall:
295295 if (g->zig_target->arch == ZigLLVM_x86)
296296 return LLVMX86VectorCallCallConv;
297 // XXX Enable this when the C API exports this enum member too
298#if 0
299 if (target_is_arm(g->zig_target) &&
300 target_arch_pointer_bit_width(g->zig_target->arch) == 64)
301 return LLVMAARCH64VectorCallCallConv;
302#endif
297303 return LLVMCCallConv;
298304 case CallingConventionAsync:
299305 return LLVMFastCallConv;
......@@ -310,7 +316,8 @@ static LLVMCallConv get_llvm_cc(CodeGen *g, CallingConvention cc) {
310316 return LLVMARMAAPCSVFPCallConv;
311317 return LLVMCCallConv;
312318 case CallingConventionInterrupt:
313 if (g->zig_target->arch == ZigLLVM_x86 || g->zig_target->arch == ZigLLVM_x86_64)
319 if (g->zig_target->arch == ZigLLVM_x86 ||
320 g->zig_target->arch == ZigLLVM_x86_64)
314321 return LLVMX86INTRCallConv;
315322 if (g->zig_target->arch == ZigLLVM_avr)
316323 return LLVMAVRINTRCallConv;