Catch more errors during the type resolution phase

Returning the uninitialized/stale error condition made the compiler turn
a blind eye to some problems.
master
LemonBoy 2019-12-24 11:28:10 +01:00
parent 563d9ebfe5
commit 271fc6a247
2 changed files with 14 additions and 6 deletions

View File

@ -2180,7 +2180,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) {
ZigType *field_type = resolve_struct_field_type(g, field);
if (field_type == nullptr) {
struct_type->data.structure.resolve_status = ResolveStatusInvalid;
return err;
return ErrorSemanticAnalyzeFail;
}
if ((err = type_resolve(g, field->type_entry, ResolveStatusSizeKnown))) {
struct_type->data.structure.resolve_status = ResolveStatusInvalid;
@ -2270,7 +2270,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) {
ZigType *field_type = resolve_struct_field_type(g, field);
if (field_type == nullptr) {
struct_type->data.structure.resolve_status = ResolveStatusInvalid;
return err;
return ErrorSemanticAnalyzeFail;
}
if ((err = type_resolve(g, field_type, ResolveStatusSizeKnown))) {
@ -2340,7 +2340,7 @@ static Error resolve_union_alignment(CodeGen *g, ZigType *union_type) {
&field->align))
{
union_type->data.unionation.resolve_status = ResolveStatusInvalid;
return err;
return ErrorSemanticAnalyzeFail;
}
add_node_error(g, field->decl_node,
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) {
union_type->data.unionation.resolve_status = ResolveStatusInvalid;
return ErrorSemanticAnalyzeFail;
}
if (is_packed) {
if ((err = emit_error_unless_type_allowed_in_packed_union(g, field_type, union_field->decl_node))) {
union_type->data.unionation.resolve_status = ResolveStatusInvalid;
@ -2925,7 +2926,7 @@ static Error resolve_struct_alignment(CodeGen *g, ZigType *struct_type) {
&field->align))
{
struct_type->data.structure.resolve_status = ResolveStatusInvalid;
return err;
return ErrorSemanticAnalyzeFail;
}
} else if (packed) {
field->align = 1;

View File

@ -290,10 +290,16 @@ static LLVMCallConv get_llvm_cc(CodeGen *g, CallingConvention cc) {
case CallingConventionFastcall:
if (g->zig_target->arch == ZigLLVM_x86)
return LLVMX86FastcallCallConv;
return LLVMFastCallConv;
return LLVMCCallConv;
case CallingConventionVectorcall:
if (g->zig_target->arch == ZigLLVM_x86)
return LLVMX86VectorCallCallConv;
// XXX Enable this when the C API exports this enum member too
#if 0
if (target_is_arm(g->zig_target) &&
target_arch_pointer_bit_width(g->zig_target->arch) == 64)
return LLVMAARCH64VectorCallCallConv;
#endif
return LLVMCCallConv;
case CallingConventionAsync:
return LLVMFastCallConv;
@ -310,7 +316,8 @@ static LLVMCallConv get_llvm_cc(CodeGen *g, CallingConvention cc) {
return LLVMARMAAPCSVFPCallConv;
return LLVMCCallConv;
case CallingConventionInterrupt:
if (g->zig_target->arch == ZigLLVM_x86 || g->zig_target->arch == ZigLLVM_x86_64)
if (g->zig_target->arch == ZigLLVM_x86 ||
g->zig_target->arch == ZigLLVM_x86_64)
return LLVMX86INTRCallConv;
if (g->zig_target->arch == ZigLLVM_avr)
return LLVMAVRINTRCallConv;