mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 07:32:44 +00:00
parent
8794ce6f79
commit
56b52dd0a3
10
src/ir.cpp
10
src/ir.cpp
@ -21934,7 +21934,17 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP
|
||||
return ira->codegen->invalid_inst_gen;
|
||||
}
|
||||
safety_check_on = false;
|
||||
} else if (array_type->id == ZigTypeIdVector) {
|
||||
uint64_t vector_len = array_type->data.vector.len;
|
||||
if (index >= vector_len) {
|
||||
ir_add_error_node(ira, elem_ptr_instruction->base.base.source_node,
|
||||
buf_sprintf("index %" ZIG_PRI_u64 " outside vector of size %" ZIG_PRI_u64,
|
||||
index, vector_len));
|
||||
return ira->codegen->invalid_inst_gen;
|
||||
}
|
||||
safety_check_on = false;
|
||||
}
|
||||
|
||||
if (array_type->id == ZigTypeIdVector) {
|
||||
ZigType *elem_type = array_type->data.vector.elem_type;
|
||||
uint32_t host_vec_len = array_type->data.vector.len;
|
||||
|
@ -2,6 +2,14 @@ const tests = @import("tests.zig");
|
||||
const std = @import("std");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add("slice sentinel mismatch",
|
||||
\\export fn entry() void {
|
||||
\\ const x = @import("std").meta.Vector(3, f32){ 25, 75, 5, 0 };
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:2:62: error: index 3 outside vector of size 3",
|
||||
});
|
||||
|
||||
cases.add("slice sentinel mismatch",
|
||||
\\export fn entry() void {
|
||||
\\ const y: [:1]const u8 = &[_:2]u8{ 1, 2 };
|
||||
@ -7548,7 +7556,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
});
|
||||
|
||||
cases.add( // fixed bug #2032
|
||||
"compile diagnostic string for top level decl type",
|
||||
"compile diagnostic string for top level decl type",
|
||||
\\export fn entry() void {
|
||||
\\ var foo: u32 = @This(){};
|
||||
\\}
|
||||
|
Loading…
Reference in New Issue
Block a user