diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-01-22 12:12:36 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-01-22 12:12:36 -0500 |
| commit | 97b2ac598b91194c09a96c9ed86e4f9b266d019c (patch) | |
| tree | f8ddd18aaf3a52981f3a97faeac8ef7bd20e6908 /src/codegen.cpp | |
| parent | 7e674d6761c057985003694f98861f589b6cf313 (diff) | |
| parent | c522699f28c1df806865c527a7a68a875e606527 (diff) | |
| download | zig-97b2ac598b91194c09a96c9ed86e4f9b266d019c.tar.gz zig-97b2ac598b91194c09a96c9ed86e4f9b266d019c.zip | |
Merge remote-tracking branch 'origin/master' into llvm10
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index cb7bbaec45..a5d4c6d500 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3356,7 +3356,7 @@ static LLVMValueRef ir_render_int_to_enum(CodeGen *g, IrExecutable *executable, LLVMValueRef tag_int_value = gen_widen_or_shorten(g, ir_want_runtime_safety(g, &instruction->base), instruction->target->value->type, tag_int_type, target_val); - if (ir_want_runtime_safety(g, &instruction->base) && wanted_type->data.enumeration.layout != ContainerLayoutExtern) { + if (ir_want_runtime_safety(g, &instruction->base) && !wanted_type->data.enumeration.non_exhaustive) { LLVMBasicBlockRef bad_value_block = LLVMAppendBasicBlock(g->cur_fn_val, "BadValue"); LLVMBasicBlockRef ok_value_block = LLVMAppendBasicBlock(g->cur_fn_val, "OkValue"); size_t field_count = wanted_type->data.enumeration.src_field_count; @@ -5065,6 +5065,11 @@ static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, IrExecutable *executable { ZigType *enum_type = instruction->target->value->type; assert(enum_type->id == ZigTypeIdEnum); + if (enum_type->data.enumeration.non_exhaustive) { + add_node_error(g, instruction->base.source_node, + buf_sprintf("TODO @tagName on non-exhaustive enum https://github.com/ziglang/zig/issues/3991")); + codegen_report_errors_and_exit(g); + } LLVMValueRef enum_name_function = get_enum_tag_name_function(g, enum_type); @@ -8299,6 +8304,7 @@ static void define_builtin_fns(CodeGen *g) { create_builtin_fn(g, BuiltinFnIdFrameSize, "frameSize", 1); create_builtin_fn(g, BuiltinFnIdAs, "as", 2); create_builtin_fn(g, BuiltinFnIdCall, "call", 3); + create_builtin_fn(g, BuiltinFnIdBitSizeof, "bitSizeOf", 1); } static const char *bool_to_str(bool b) { |
