authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2021-08-30 02:54:03+02:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2021-09-20 02:29:04+02:00
logc5945467acfd580cb3413250ef52f13dc412a8cf
treecd56aa35c06a65ec51a3ade3a3bbb90eb33cb8a1
parent7a5d0cdf45f861f63d89666607dc86b3a2810826

Address Spaces: Pointer and function info in @Type


11 files changed, 121 insertions(+), 48 deletions(-)

lib/std/builtin.zig+2
......@@ -235,6 +235,7 @@ pub const TypeInfo = union(enum) {
235235 is_const: bool,
236236 is_volatile: bool,
237237 alignment: comptime_int,
238 address_space: AddressSpace,
238239 child: type,
239240 is_allowzero: bool,
240241
......@@ -364,6 +365,7 @@ pub const TypeInfo = union(enum) {
364365 pub const Fn = struct {
365366 calling_convention: CallingConvention,
366367 alignment: comptime_int,
368 address_space: AddressSpace,
367369 is_generic: bool,
368370 is_var_args: bool,
369371 return_type: ?type,
lib/std/mem.zig+2
......@@ -2472,6 +2472,7 @@ fn CopyPtrAttrs(comptime source: type, comptime size: std.builtin.TypeInfo.Point
24722472 .is_volatile = info.is_volatile,
24732473 .is_allowzero = info.is_allowzero,
24742474 .alignment = info.alignment,
2475 .address_space = info.address_space,
24752476 .child = child,
24762477 .sentinel = null,
24772478 },
......@@ -2960,6 +2961,7 @@ fn AlignedSlice(comptime AttributeSource: type, comptime new_alignment: u29) typ
29602961 .is_volatile = info.is_volatile,
29612962 .is_allowzero = info.is_allowzero,
29622963 .alignment = new_alignment,
2964 .address_space = info.address_space,
29632965 .child = info.child,
29642966 .sentinel = null,
29652967 },
lib/std/meta.zig+3
......@@ -235,6 +235,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
235235 .is_const = info.is_const,
236236 .is_volatile = info.is_volatile,
237237 .alignment = info.alignment,
238 .address_space = info.address_space,
238239 .child = @Type(.{
239240 .Array = .{
240241 .len = array_info.len,
......@@ -254,6 +255,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
254255 .is_const = info.is_const,
255256 .is_volatile = info.is_volatile,
256257 .alignment = info.alignment,
258 .address_space = info.address_space,
257259 .child = info.child,
258260 .is_allowzero = info.is_allowzero,
259261 .sentinel = sentinel_val,
......@@ -271,6 +273,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
271273 .is_const = ptr_info.is_const,
272274 .is_volatile = ptr_info.is_volatile,
273275 .alignment = ptr_info.alignment,
276 .address_space = ptr_info.address_space,
274277 .child = ptr_info.child,
275278 .is_allowzero = ptr_info.is_allowzero,
276279 .sentinel = sentinel_val,
lib/std/zig/c_translation.zig+1
......@@ -325,6 +325,7 @@ pub fn FlexibleArrayType(comptime SelfType: type, ElementType: type) type {
325325 .is_const = ptr.is_const,
326326 .is_volatile = ptr.is_volatile,
327327 .alignment = @alignOf(ElementType),
328 .address_space = .generic,
328329 .child = ElementType,
329330 .is_allowzero = true,
330331 .sentinel = null,
src/Sema.zig+10-5
......@@ -6413,7 +6413,7 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr
64136413
64146414 switch (ty.zigTypeTag()) {
64156415 .Fn => {
6416 const field_values = try sema.arena.alloc(Value, 6);
6416 const field_values = try sema.arena.alloc(Value, 7);
64176417 // calling_convention: CallingConvention,
64186418 field_values[0] = try Value.Tag.enum_field_index.create(
64196419 sema.arena,
......@@ -6421,14 +6421,19 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr
64216421 );
64226422 // alignment: comptime_int,
64236423 field_values[1] = try Value.Tag.int_u64.create(sema.arena, ty.abiAlignment(target));
6424 // address_space: AddressSpace,
6425 field_values[2] = try Value.Tag.enum_field_index.create(
6426 sema.arena,
6427 @enumToInt(ty.fnAddressSpace()),
6428 );
64246429 // is_generic: bool,
6425 field_values[2] = Value.initTag(.bool_false); // TODO
6426 // is_var_args: bool,
64276430 field_values[3] = Value.initTag(.bool_false); // TODO
6431 // is_var_args: bool,
6432 field_values[4] = Value.initTag(.bool_false); // TODO
64286433 // return_type: ?type,
6429 field_values[4] = try Value.Tag.ty.create(sema.arena, ty.fnReturnType());
6434 field_values[5] = try Value.Tag.ty.create(sema.arena, ty.fnReturnType());
64306435 // args: []const FnArg,
6431 field_values[5] = Value.initTag(.null_value); // TODO
6436 field_values[6] = Value.initTag(.null_value); // TODO
64326437
64336438 return sema.addConstant(
64346439 type_info_ty,
src/stage1/all_types.hpp+8
......@@ -86,6 +86,14 @@ enum CallingConvention {
8686 CallingConventionSysV
8787};
8888
89// Stage 1 supports only the generic address space
90enum AddressSpace {
91 AddressSpaceGeneric,
92 AddressSpaceGS,
93 AddressSpaceFS,
94 AddressSpaceSS,
95};
96
8997// This one corresponds to the builtin.zig enum.
9098enum BuiltinPtrSize {
9199 BuiltinPtrSizeOne,
src/stage1/analyze.cpp+10
......@@ -1019,6 +1019,16 @@ bool calling_convention_allows_zig_types(CallingConvention cc) {
10191019 zig_unreachable();
10201020}
10211021
1022const char *address_space_name(AddressSpace as) {
1023 switch (as) {
1024 case AddressSpaceGeneric: return "generic";
1025 case AddressSpaceGS: return "gs";
1026 case AddressSpaceFS: return "fs";
1027 case AddressSpaceSS: return "ss";
1028 }
1029 zig_unreachable();
1030}
1031
10221032ZigType *get_stack_trace_type(CodeGen *g) {
10231033 if (g->stack_trace_type == nullptr) {
10241034 g->stack_trace_type = get_builtin_type(g, "StackTrace");
src/stage1/analyze.hpp+2
......@@ -242,6 +242,8 @@ Error get_primitive_type(CodeGen *g, Buf *name, ZigType **result);
242242bool calling_convention_allows_zig_types(CallingConvention cc);
243243const char *calling_convention_name(CallingConvention cc);
244244
245const char *address_space_name(AddressSpace as);
246
245247Error ATTRIBUTE_MUST_USE file_fetch(CodeGen *g, Buf *resolved_path, Buf *contents);
246248
247249void walk_function_params(CodeGen *g, ZigType *fn_type, FnWalk *fn_walk);
src/stage1/ir.cpp+78-43
......@@ -16124,7 +16124,7 @@ static Stage1AirInst *ir_analyze_instruction_optional_unwrap_ptr(IrAnalyze *ira,
1612416124
1612516125static Stage1AirInst *ir_analyze_instruction_ctz(IrAnalyze *ira, Stage1ZirInstCtz *instruction) {
1612616126 Error err;
16127
16127
1612816128 ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child);
1612916129 if (type_is_invalid(int_type))
1613016130 return ira->codegen->invalid_inst_gen;
......@@ -16166,7 +16166,7 @@ static Stage1AirInst *ir_analyze_instruction_ctz(IrAnalyze *ira, Stage1ZirInstCt
1616616166 return ira->codegen->invalid_inst_gen;
1616716167 if (val->special == ConstValSpecialUndef)
1616816168 return ir_const_undef(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_num_lit_int);
16169
16169
1617016170 if (is_vector) {
1617116171 ZigType *smallest_vec_type = get_vector_type(ira->codegen, vector_len, smallest_type);
1617216172 Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, smallest_vec_type);
......@@ -16200,7 +16200,7 @@ static Stage1AirInst *ir_analyze_instruction_ctz(IrAnalyze *ira, Stage1ZirInstCt
1620016200
1620116201static Stage1AirInst *ir_analyze_instruction_clz(IrAnalyze *ira, Stage1ZirInstClz *instruction) {
1620216202 Error err;
16203
16203
1620416204 ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child);
1620516205 if (type_is_invalid(int_type))
1620616206 return ira->codegen->invalid_inst_gen;
......@@ -16242,7 +16242,7 @@ static Stage1AirInst *ir_analyze_instruction_clz(IrAnalyze *ira, Stage1ZirInstCl
1624216242 return ira->codegen->invalid_inst_gen;
1624316243 if (val->special == ConstValSpecialUndef)
1624416244 return ir_const_undef(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_num_lit_int);
16245
16245
1624616246 if (is_vector) {
1624716247 ZigType *smallest_vec_type = get_vector_type(ira->codegen, vector_len, smallest_type);
1624816248 Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, smallest_vec_type);
......@@ -16276,7 +16276,7 @@ static Stage1AirInst *ir_analyze_instruction_clz(IrAnalyze *ira, Stage1ZirInstCl
1627616276
1627716277static Stage1AirInst *ir_analyze_instruction_pop_count(IrAnalyze *ira, Stage1ZirInstPopCount *instruction) {
1627816278 Error err;
16279
16279
1628016280 ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child);
1628116281 if (type_is_invalid(int_type))
1628216282 return ira->codegen->invalid_inst_gen;
......@@ -16318,7 +16318,7 @@ static Stage1AirInst *ir_analyze_instruction_pop_count(IrAnalyze *ira, Stage1Zir
1631816318 return ira->codegen->invalid_inst_gen;
1631916319 if (val->special == ConstValSpecialUndef)
1632016320 return ir_const_undef(ira, instruction->base.scope, instruction->base.source_node, ira->codegen->builtin_types.entry_num_lit_int);
16321
16321
1632216322 if (is_vector) {
1632316323 ZigType *smallest_vec_type = get_vector_type(ira->codegen, vector_len, smallest_type);
1632416324 Stage1AirInst *result = ir_const(ira, instruction->base.scope, instruction->base.source_node, smallest_vec_type);
......@@ -17904,7 +17904,7 @@ static ZigValue *create_ptr_like_type_info(IrAnalyze *ira, Scope *scope, AstNode
1790417904 result->special = ConstValSpecialStatic;
1790517905 result->type = type_info_pointer_type;
1790617906
17907 ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 7);
17907 ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 8);
1790817908 result->data.x_struct.fields = fields;
1790917909
1791017910 // size: Size
......@@ -17939,24 +17939,29 @@ static ZigValue *create_ptr_like_type_info(IrAnalyze *ira, Scope *scope, AstNode
1793917939 lazy_align_of->base.id = LazyValueIdAlignOf;
1794017940 lazy_align_of->target_type = ir_const_type(ira, scope, source_node, attrs_type->data.pointer.child_type);
1794117941 }
17942 // child: type
17943 ensure_field_index(result->type, "child", 4);
17942 // address_space: AddressSpace,
17943 ensure_field_index(result->type, "address_space", 4);
1794417944 fields[4]->special = ConstValSpecialStatic;
17945 fields[4]->type = ira->codegen->builtin_types.entry_type;
17946 fields[4]->data.x_type = attrs_type->data.pointer.child_type;
17947 // is_allowzero: bool
17948 ensure_field_index(result->type, "is_allowzero", 5);
17945 fields[4]->type = get_builtin_type(ira->codegen, "AddressSpace");
17946 bigint_init_unsigned(&fields[4]->data.x_enum_tag, AddressSpaceGeneric);
17947 // child: type
17948 ensure_field_index(result->type, "child", 5);
1794917949 fields[5]->special = ConstValSpecialStatic;
17950 fields[5]->type = ira->codegen->builtin_types.entry_bool;
17951 fields[5]->data.x_bool = attrs_type->data.pointer.allow_zero;
17952 // sentinel: anytype
17953 ensure_field_index(result->type, "sentinel", 6);
17950 fields[5]->type = ira->codegen->builtin_types.entry_type;
17951 fields[5]->data.x_type = attrs_type->data.pointer.child_type;
17952 // is_allowzero: bool
17953 ensure_field_index(result->type, "is_allowzero", 6);
1795417954 fields[6]->special = ConstValSpecialStatic;
17955 fields[6]->type = ira->codegen->builtin_types.entry_bool;
17956 fields[6]->data.x_bool = attrs_type->data.pointer.allow_zero;
17957 // sentinel: anytype
17958 ensure_field_index(result->type, "sentinel", 7);
17959 fields[7]->special = ConstValSpecialStatic;
1795517960 if (attrs_type->data.pointer.sentinel != nullptr) {
17956 fields[6]->type = get_optional_type(ira->codegen, attrs_type->data.pointer.child_type);
17957 set_optional_payload(fields[6], attrs_type->data.pointer.sentinel);
17961 fields[7]->type = get_optional_type(ira->codegen, attrs_type->data.pointer.child_type);
17962 set_optional_payload(fields[7], attrs_type->data.pointer.sentinel);
1795817963 } else {
17959 fields[6]->type = ira->codegen->builtin_types.entry_null;
17964 fields[7]->type = ira->codegen->builtin_types.entry_null;
1796017965 }
1796117966
1796217967 return result;
......@@ -18465,7 +18470,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
1846518470 result->special = ConstValSpecialStatic;
1846618471 result->type = ir_type_info_get_type(ira, "Fn", nullptr);
1846718472
18468 ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 6);
18473 ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 7);
1846918474 result->data.x_struct.fields = fields;
1847018475
1847118476 // calling_convention: TypeInfo.CallingConvention
......@@ -18478,30 +18483,35 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
1847818483 fields[1]->special = ConstValSpecialStatic;
1847918484 fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int;
1848018485 bigint_init_unsigned(&fields[1]->data.x_bigint, get_ptr_align(ira->codegen, type_entry));
18486 // address_space: AddressSpace
18487 ensure_field_index(result->type, "address_space", 2);
18488 fields[2]->special = ConstValSpecialStatic;
18489 fields[2]->type = get_builtin_type(ira->codegen, "AddressSpace");
18490 bigint_init_unsigned(&fields[2]->data.x_enum_tag, AddressSpaceGeneric);
1848118491 // is_generic: bool
18482 ensure_field_index(result->type, "is_generic", 2);
18492 ensure_field_index(result->type, "is_generic", 3);
1848318493 bool is_generic = type_entry->data.fn.is_generic;
18484 fields[2]->special = ConstValSpecialStatic;
18485 fields[2]->type = ira->codegen->builtin_types.entry_bool;
18486 fields[2]->data.x_bool = is_generic;
18487 // is_varargs: bool
18488 ensure_field_index(result->type, "is_var_args", 3);
18489 bool is_varargs = type_entry->data.fn.fn_type_id.is_var_args;
1849018494 fields[3]->special = ConstValSpecialStatic;
1849118495 fields[3]->type = ira->codegen->builtin_types.entry_bool;
18492 fields[3]->data.x_bool = is_varargs;
18493 // return_type: ?type
18494 ensure_field_index(result->type, "return_type", 4);
18496 fields[3]->data.x_bool = is_generic;
18497 // is_varargs: bool
18498 ensure_field_index(result->type, "is_var_args", 4);
18499 bool is_varargs = type_entry->data.fn.fn_type_id.is_var_args;
1849518500 fields[4]->special = ConstValSpecialStatic;
18496 fields[4]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type);
18501 fields[4]->type = ira->codegen->builtin_types.entry_bool;
18502 fields[4]->data.x_bool = is_varargs;
18503 // return_type: ?type
18504 ensure_field_index(result->type, "return_type", 5);
18505 fields[5]->special = ConstValSpecialStatic;
18506 fields[5]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type);
1849718507 if (type_entry->data.fn.fn_type_id.return_type == nullptr)
18498 fields[4]->data.x_optional = nullptr;
18508 fields[5]->data.x_optional = nullptr;
1849918509 else {
1850018510 ZigValue *return_type = ira->codegen->pass1_arena->create<ZigValue>();
1850118511 return_type->special = ConstValSpecialStatic;
1850218512 return_type->type = ira->codegen->builtin_types.entry_type;
1850318513 return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type;
18504 fields[4]->data.x_optional = return_type;
18514 fields[5]->data.x_optional = return_type;
1850518515 }
1850618516 // args: []TypeInfo.FnArg
1850718517 ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg", nullptr);
......@@ -18516,7 +18526,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
1851618526 fn_arg_array->data.x_array.special = ConstArraySpecialNone;
1851718527 fn_arg_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(fn_arg_count);
1851818528
18519 init_const_slice(ira->codegen, fields[5], fn_arg_array, 0, fn_arg_count, false, nullptr);
18529 init_const_slice(ira->codegen, fields[6], fn_arg_array, 0, fn_arg_count, false, nullptr);
1852018530
1852118531 for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) {
1852218532 FnTypeParamInfo *fn_param_info = &type_entry->data.fn.fn_type_id.param_info[fn_arg_index];
......@@ -18826,11 +18836,11 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
1882618836 assert(size_value->type == ir_type_info_get_type(ira, "Size", type_info_pointer_type));
1882718837 BuiltinPtrSize size_enum_index = (BuiltinPtrSize)bigint_as_u32(&size_value->data.x_enum_tag);
1882818838 PtrLen ptr_len = size_enum_index_to_ptr_len(size_enum_index);
18829 ZigType *elem_type = get_const_field_meta_type(ira, source_node, payload, "child", 4);
18839 ZigType *elem_type = get_const_field_meta_type(ira, source_node, payload, "child", 5);
1883018840 if (type_is_invalid(elem_type))
1883118841 return ira->codegen->invalid_inst_gen->value->type;
1883218842 ZigValue *sentinel;
18833 if ((err = get_const_field_sentinel(ira, scope, source_node, payload, "sentinel", 6,
18843 if ((err = get_const_field_sentinel(ira, scope, source_node, payload, "sentinel", 7,
1883418844 elem_type, &sentinel)))
1883518845 {
1883618846 return ira->codegen->invalid_inst_gen->value->type;
......@@ -18845,6 +18855,19 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
1884518855 if (alignment == nullptr)
1884618856 return ira->codegen->invalid_inst_gen->value->type;
1884718857
18858 ZigValue *as_value = get_const_field(ira, source_node, payload, "address_space", 4);
18859 if (as_value == nullptr)
18860 return ira->codegen->invalid_inst_gen->value->type;
18861 assert(as_value->special == ConstValSpecialStatic);
18862 assert(as_value->type == get_builtin_type(ira->codegen, "AddressSpace"));
18863 AddressSpace as = (AddressSpace)bigint_as_u32(&as_value->data.x_enum_tag);
18864 if (as != AddressSpaceGeneric) {
18865 ir_add_error_node(ira, source_node, buf_sprintf(
18866 "address space '%s' not available in stage 1 compiler, must be .generic",
18867 address_space_name(as)));
18868 return ira->codegen->invalid_inst_gen->value->type;
18869 }
18870
1884818871 bool is_const;
1884918872 if ((err = get_const_field_bool(ira, source_node, payload, "is_const", 1, &is_const)))
1885018873 return ira->codegen->invalid_inst_gen->value->type;
......@@ -18857,13 +18880,12 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
1885718880 }
1885818881
1885918882 bool is_allowzero;
18860 if ((err = get_const_field_bool(ira, source_node, payload, "is_allowzero", 5,
18883 if ((err = get_const_field_bool(ira, source_node, payload, "is_allowzero", 6,
1886118884 &is_allowzero)))
1886218885 {
1886318886 return ira->codegen->invalid_inst_gen->value->type;
1886418887 }
1886518888
18866
1886718889 ZigType *ptr_type = get_pointer_to_type_extra2(ira->codegen,
1886818890 elem_type,
1886918891 is_const,
......@@ -19308,9 +19330,22 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
1930819330 if (alignment == nullptr)
1930919331 return ira->codegen->invalid_inst_gen->value->type;
1931019332
19333 ZigValue *as_value = get_const_field(ira, source_node, payload, "address_space", 2);
19334 if (as_value == nullptr)
19335 return ira->codegen->invalid_inst_gen->value->type;
19336 assert(as_value->special == ConstValSpecialStatic);
19337 assert(as_value->type == get_builtin_type(ira->codegen, "AddressSpace"));
19338 AddressSpace as = (AddressSpace)bigint_as_u32(&as_value->data.x_enum_tag);
19339 if (as != AddressSpaceGeneric) {
19340 ir_add_error_node(ira, source_node, buf_sprintf(
19341 "address space '%s' not available in stage 1 compiler, must be .generic",
19342 address_space_name(as)));
19343 return ira->codegen->invalid_inst_gen->value->type;
19344 }
19345
1931119346 Error err;
1931219347 bool is_generic;
19313 if ((err = get_const_field_bool(ira, source_node, payload, "is_generic", 2, &is_generic)))
19348 if ((err = get_const_field_bool(ira, source_node, payload, "is_generic", 3, &is_generic)))
1931419349 return ira->codegen->invalid_inst_gen->value->type;
1931519350 if (is_generic) {
1931619351 ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.is_generic must be false for @Type"));
......@@ -19318,20 +19353,20 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
1931819353 }
1931919354
1932019355 bool is_var_args;
19321 if ((err = get_const_field_bool(ira, source_node, payload, "is_var_args", 3, &is_var_args)))
19356 if ((err = get_const_field_bool(ira, source_node, payload, "is_var_args", 4, &is_var_args)))
1932219357 return ira->codegen->invalid_inst_gen->value->type;
1932319358 if (is_var_args && cc != CallingConventionC) {
1932419359 ir_add_error_node(ira, source_node, buf_sprintf("varargs functions must have C calling convention"));
1932519360 return ira->codegen->invalid_inst_gen->value->type;
1932619361 }
1932719362
19328 ZigType *return_type = get_const_field_meta_type_optional(ira, source_node, payload, "return_type", 4);
19363 ZigType *return_type = get_const_field_meta_type_optional(ira, source_node, payload, "return_type", 5);
1932919364 if (return_type == nullptr) {
1933019365 ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.return_type must be non-null for @Type"));
1933119366 return ira->codegen->invalid_inst_gen->value->type;
1933219367 }
1933319368
19334 ZigValue *args_value = get_const_field(ira, source_node, payload, "args", 5);
19369 ZigValue *args_value = get_const_field(ira, source_node, payload, "args", 6);
1933519370 if (args_value == nullptr)
1933619371 return ira->codegen->invalid_inst_gen->value->type;
1933719372 assert(args_value->special == ConstValSpecialStatic);
test/behavior/type.zig+1
......@@ -137,6 +137,7 @@ test "@Type create slice with null sentinel" {
137137 .is_volatile = false,
138138 .is_allowzero = false,
139139 .alignment = 8,
140 .address_space = .generic,
140141 .child = *i32,
141142 .sentinel = null,
142143 },
test/compile_errors.zig+4
......@@ -410,6 +410,7 @@ pub fn addCases(ctx: *TestContext) !void {
410410 \\ .Fn = .{
411411 \\ .calling_convention = .Unspecified,
412412 \\ .alignment = 0,
413 \\ .address_space = 0,
413414 \\ .is_generic = true,
414415 \\ .is_var_args = false,
415416 \\ .return_type = u0,
......@@ -426,6 +427,7 @@ pub fn addCases(ctx: *TestContext) !void {
426427 \\ .Fn = .{
427428 \\ .calling_convention = .Unspecified,
428429 \\ .alignment = 0,
430 \\ .address_space = 0,
429431 \\ .is_generic = false,
430432 \\ .is_var_args = true,
431433 \\ .return_type = u0,
......@@ -442,6 +444,7 @@ pub fn addCases(ctx: *TestContext) !void {
442444 \\ .Fn = .{
443445 \\ .calling_convention = .Unspecified,
444446 \\ .alignment = 0,
447 \\ .address_space = 0,
445448 \\ .is_generic = false,
446449 \\ .is_var_args = false,
447450 \\ .return_type = null,
......@@ -711,6 +714,7 @@ pub fn addCases(ctx: *TestContext) !void {
711714 \\ .is_const = false,
712715 \\ .is_volatile = false,
713716 \\ .alignment = 1,
717 \\ .address_space = .generic,
714718 \\ .child = u8,
715719 \\ .is_allowzero = false,
716720 \\ .sentinel = 0,