aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorVexu <git@vexu.eu>2020-07-11 12:08:29 +0300
committerAndrew Kelley <andrew@ziglang.org>2020-07-13 00:29:53 +0000
commitdff1ac1089dd8a7cae5c167bdb4e6269c9b84bb6 (patch)
treeca2a2c57fcc9d948954ba346256f8e8b22139242 /src/ir.cpp
parentef17af1270155e803a77955c9f37175dd09c43d4 (diff)
downloadzig-dff1ac1089dd8a7cae5c167bdb4e6269c9b84bb6.tar.gz
zig-dff1ac1089dd8a7cae5c167bdb4e6269c9b84bb6.zip
check for invalid sentinel when creating pointer with `@Type`
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 6447db8c71..dc380b4389 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -25915,6 +25915,11 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
{
return ira->codegen->invalid_inst_gen->value->type;
}
+ if (sentinel != nullptr && (size_enum_index == BuiltinPtrSizeOne || size_enum_index == BuiltinPtrSizeC)) {
+ ir_add_error(ira, source_instr,
+ buf_sprintf("sentinels are only allowed on slices and unknown-length pointers"));
+ return ira->codegen->invalid_inst_gen->value->type;
+ }
BigInt *bi = get_const_field_lit_int(ira, source_instr->source_node, payload, "alignment", 3);
if (bi == nullptr)
return ira->codegen->invalid_inst_gen->value->type;
@@ -25948,7 +25953,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
0, // host_int_bytes
is_allowzero,
VECTOR_INDEX_NONE, nullptr, sentinel);
- if (size_enum_index != 2)
+ if (size_enum_index != BuiltinPtrSizeSlice)
return ptr_type;
return get_slice_type(ira->codegen, ptr_type);
}