parent
7634e67ba5
commit
a7a8c433d0
|
@ -29079,6 +29079,12 @@ static IrInstGen *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstSrcPtrTy
|
||||||
lazy_ptr_type->base.id = LazyValueIdPtrType;
|
lazy_ptr_type->base.id = LazyValueIdPtrType;
|
||||||
|
|
||||||
if (instruction->sentinel != nullptr) {
|
if (instruction->sentinel != nullptr) {
|
||||||
|
if (instruction->ptr_len != PtrLenUnknown) {
|
||||||
|
ir_add_error(ira, &instruction->base.base,
|
||||||
|
buf_sprintf("sentinels are only allowed on unknown-length pointers"));
|
||||||
|
return ira->codegen->invalid_inst_gen;
|
||||||
|
}
|
||||||
|
|
||||||
lazy_ptr_type->sentinel = instruction->sentinel->child;
|
lazy_ptr_type->sentinel = instruction->sentinel->child;
|
||||||
if (ir_resolve_const(ira, lazy_ptr_type->sentinel, LazyOk) == nullptr)
|
if (ir_resolve_const(ira, lazy_ptr_type->sentinel, LazyOk) == nullptr)
|
||||||
return ira->codegen->invalid_inst_gen;
|
return ira->codegen->invalid_inst_gen;
|
||||||
|
|
|
@ -2,6 +2,14 @@ const tests = @import("tests.zig");
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||||
|
cases.add("invalid pointer syntax",
|
||||||
|
\\export fn foo() void {
|
||||||
|
\\ var guid: *:0 const u8 = undefined;
|
||||||
|
\\}
|
||||||
|
, &[_][]const u8{
|
||||||
|
"tmp.zig:2:15: error: sentinels are only allowed on unknown-length pointers",
|
||||||
|
});
|
||||||
|
|
||||||
cases.add("declaration between fields",
|
cases.add("declaration between fields",
|
||||||
\\const S = struct {
|
\\const S = struct {
|
||||||
\\ const foo = 2;
|
\\ const foo = 2;
|
||||||
|
|
Loading…
Reference in New Issue