Merge pull request #11942 from Vexu/stage2-compile-errors

Move passing stage1 compile error tests to stage2
This commit is contained in:
Andrew Kelley 2022-06-30 18:39:46 -04:00 committed by GitHub
commit 1951051e3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
481 changed files with 2050 additions and 1846 deletions

View File

@ -1476,7 +1476,7 @@ fn arrayInitExprRlPtr(
return arrayInitExprRlPtrInner(gz, scope, node, base_ptr, elements);
}
var as_scope = try gz.makeCoercionScope(scope, array_ty, result_ptr);
var as_scope = try gz.makeCoercionScope(scope, array_ty, result_ptr, node);
defer as_scope.unstack();
const result = try arrayInitExprRlPtrInner(&as_scope, scope, node, as_scope.rl_ptr, elements);
@ -1697,7 +1697,7 @@ fn structInitExprRlPtr(
const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr);
_ = try gz.addUnNode(.validate_struct_init_ty, ty_inst, node);
var as_scope = try gz.makeCoercionScope(scope, ty_inst, result_ptr);
var as_scope = try gz.makeCoercionScope(scope, ty_inst, result_ptr, node);
defer as_scope.unstack();
const result = try structInitExprRlPtrInner(&as_scope, scope, node, struct_init, as_scope.rl_ptr);
@ -4464,6 +4464,7 @@ fn containerDecl(
var total_fields: usize = 0;
var decls: usize = 0;
var nonexhaustive_node: Ast.Node.Index = 0;
var nonfinal_nonexhaustive = false;
for (container_decl.ast.members) |member_node| {
const member = switch (node_tags[member_node]) {
.container_field_init => tree.containerFieldInit(member_node),
@ -4515,6 +4516,8 @@ fn containerDecl(
return astgen.failNode(member.ast.value_expr, "'_' is used to mark an enum as non-exhaustive and cannot be assigned a value", .{});
}
continue;
} else if (nonexhaustive_node != 0) {
nonfinal_nonexhaustive = true;
}
total_fields += 1;
if (member.ast.value_expr != 0) {
@ -4524,6 +4527,9 @@ fn containerDecl(
values += 1;
}
}
if (nonfinal_nonexhaustive) {
return astgen.failNode(nonexhaustive_node, "'_' field of non-exhaustive enum must be last", .{});
}
break :blk .{
.total_fields = total_fields,
.values = values,
@ -7040,7 +7046,7 @@ fn asRlPtr(
operand_node: Ast.Node.Index,
dest_type: Zir.Inst.Ref,
) InnerError!Zir.Inst.Ref {
var as_scope = try parent_gz.makeCoercionScope(scope, dest_type, result_ptr);
var as_scope = try parent_gz.makeCoercionScope(scope, dest_type, result_ptr, src_node);
defer as_scope.unstack();
const result = try reachableExpr(&as_scope, &as_scope.base, .{ .block_ptr = &as_scope }, operand_node, src_node);
@ -9897,13 +9903,14 @@ const GenZir = struct {
scope: *Scope,
dest_type: Zir.Inst.Ref,
result_ptr: Zir.Inst.Ref,
src_node: Ast.Node.Index,
) !GenZir {
// Detect whether this expr() call goes into rvalue() to store the result into the
// result location. If it does, elide the coerce_result_ptr instruction
// as well as the store instruction, instead passing the result as an rvalue.
var as_scope = parent_gz.makeSubBlock(scope);
errdefer as_scope.unstack();
as_scope.rl_ptr = try as_scope.addBin(.coerce_result_ptr, dest_type, result_ptr);
as_scope.rl_ptr = try as_scope.addPlNode(.coerce_result_ptr, src_node, Zir.Inst.Bin{ .lhs = dest_type, .rhs = result_ptr });
// `rl_ty_inst` needs to be set in case the stores to `rl_ptr` are eliminated.
as_scope.rl_ty_inst = dest_type;

View File

@ -503,6 +503,8 @@ pub const Decl = struct {
alive: bool,
/// Whether the Decl is a `usingnamespace` declaration.
is_usingnamespace: bool,
/// If true `name` is already fully qualified.
name_fully_qualified: bool = false,
/// Represents the position of the code in the output file.
/// This is populated regardless of semantic analysis and code generation.
@ -686,6 +688,9 @@ pub const Decl = struct {
pub fn renderFullyQualifiedName(decl: Decl, mod: *Module, writer: anytype) !void {
const unqualified_name = mem.sliceTo(decl.name, 0);
if (decl.name_fully_qualified) {
return writer.writeAll(unqualified_name);
}
return decl.src_namespace.renderFullyQualifiedName(mod, unqualified_name, writer);
}

File diff suppressed because it is too large Load Diff

View File

@ -409,11 +409,11 @@ pub fn print(
}
return writer.writeAll(" }");
},
.float_16 => return writer.print("{}", .{val.castTag(.float_16).?.data}),
.float_32 => return writer.print("{}", .{val.castTag(.float_32).?.data}),
.float_64 => return writer.print("{}", .{val.castTag(.float_64).?.data}),
.float_80 => return writer.print("{}", .{val.castTag(.float_80).?.data}),
.float_128 => return writer.print("{}", .{val.castTag(.float_128).?.data}),
.float_16 => return writer.print("{d}", .{val.castTag(.float_16).?.data}),
.float_32 => return writer.print("{d}", .{val.castTag(.float_32).?.data}),
.float_64 => return writer.print("{d}", .{val.castTag(.float_64).?.data}),
.float_80 => return writer.print("{d}", .{@floatCast(f64, val.castTag(.float_80).?.data)}),
.float_128 => return writer.print("{d}", .{@floatCast(f64, val.castTag(.float_128).?.data)}),
.@"error" => return writer.print("error.{s}", .{val.castTag(.@"error").?.data.name}),
.eu_payload => {
val = val.castTag(.eu_payload).?.data;

View File

@ -308,7 +308,7 @@ pub const Inst = struct {
cmp_neq,
/// Coerces a result location pointer to a new element type. It is evaluated "backwards"-
/// as type coercion from the new element type to the old element type.
/// Uses the `bin` union field.
/// Uses the `pl_node` union field. Payload is `Bin`.
/// LHS is destination element type, RHS is result pointer.
coerce_result_ptr,
/// Conditional branch. Splits control flow based on a boolean condition value.
@ -1603,7 +1603,7 @@ pub const Inst = struct {
.cmp_gte = .pl_node,
.cmp_gt = .pl_node,
.cmp_neq = .pl_node,
.coerce_result_ptr = .bin,
.coerce_result_ptr = .pl_node,
.condbr = .pl_node,
.condbr_inline = .pl_node,
.@"try" = .pl_node,

View File

@ -7634,33 +7634,31 @@ pub const FuncGen = struct {
fn airTagName(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
if (self.liveness.isUnused(inst)) return null;
var arena_allocator = std.heap.ArenaAllocator.init(self.gpa);
defer arena_allocator.deinit();
const arena = arena_allocator.allocator();
const un_op = self.air.instructions.items(.data)[inst].un_op;
const operand = try self.resolveInst(un_op);
const enum_ty = self.air.typeOf(un_op);
const mod = self.dg.module;
const llvm_fn_name = try std.fmt.allocPrintZ(arena, "__zig_tag_name_{s}", .{
try mod.declPtr(enum_ty.getOwnerDecl()).getFullyQualifiedName(mod),
});
const llvm_fn = try self.getEnumTagNameFunction(enum_ty, llvm_fn_name);
const llvm_fn = try self.getEnumTagNameFunction(enum_ty);
const params = [_]*const llvm.Value{operand};
return self.builder.buildCall(llvm_fn, &params, params.len, .Fast, .Auto, "");
}
fn getEnumTagNameFunction(
self: *FuncGen,
enum_ty: Type,
llvm_fn_name: [:0]const u8,
) !*const llvm.Value {
fn getEnumTagNameFunction(self: *FuncGen, enum_ty: Type) !*const llvm.Value {
const enum_decl = enum_ty.getOwnerDecl();
// TODO: detect when the type changes and re-emit this function.
if (self.dg.object.llvm_module.getNamedFunction(llvm_fn_name)) |llvm_fn| {
return llvm_fn;
}
const gop = try self.dg.object.decl_map.getOrPut(self.dg.gpa, enum_decl);
if (gop.found_existing) return gop.value_ptr.*;
errdefer assert(self.dg.object.decl_map.remove(enum_decl));
var arena_allocator = std.heap.ArenaAllocator.init(self.gpa);
defer arena_allocator.deinit();
const arena = arena_allocator.allocator();
const mod = self.dg.module;
const llvm_fn_name = try std.fmt.allocPrintZ(arena, "__zig_tag_name_{s}", .{
try mod.declPtr(enum_decl).getFullyQualifiedName(mod),
});
const slice_ty = Type.initTag(.const_slice_u8_sentinel_0);
const llvm_ret_ty = try self.dg.lowerType(slice_ty);
@ -7677,6 +7675,7 @@ pub const FuncGen = struct {
fn_val.setLinkage(.Internal);
fn_val.setFunctionCallConv(.Fast);
self.dg.addCommonFnAttributes(fn_val);
gop.value_ptr.* = fn_val;
const prev_block = self.builder.getInsertBlock();
const prev_debug_location = self.builder.getCurrentDebugLocation2();

View File

@ -144,7 +144,6 @@ const Writer = struct {
switch (tag) {
.array_type,
.as,
.coerce_result_ptr,
.elem_ptr,
.elem_val,
.store,
@ -355,6 +354,7 @@ const Writer = struct {
.minimum,
.elem_ptr_node,
.elem_val_node,
.coerce_result_ptr,
=> try self.writePlNodeBin(stream, inst),
.elem_ptr_imm => try self.writeElemPtrImm(stream, inst),

View File

@ -1107,3 +1107,24 @@ test "enum literal in array literal" {
try expect(array[0] == .one);
try expect(array[1] == .two);
}
test "tag name functions are unique" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
{
const E = enum { a, b };
var b = E.a;
var a = @tagName(b);
_ = a;
}
{
const E = enum { a, b, c, d, e, f };
var b = E.a;
var a = @tagName(b);
_ = a;
}
}

View File

@ -2,4 +2,4 @@ pub export fn main() noreturn {}
// error
//
// :1:32: error: expected noreturn, found void
// :1:32: error: expected type 'noreturn', found 'void'

View File

@ -5,5 +5,6 @@ pub fn main() void {
// error
// output_mode=Exe
// backend=stage2
//
// :2:9: error: variable of type '@TypeOf(null)' must be const or comptime

View File

@ -0,0 +1,13 @@
export fn entry() void {
const U = union { A: u32, B: u64 };
var u = U{ .A = 42 };
var ok = u == .A;
_ = ok;
}
// error
// backend=stage2
// target=native
//
// :4:14: error: comparison of union and enum literal is only valid for tagged union types
// :2:15: note: union 'tmp.entry.U' is not a tagged union

View File

@ -9,8 +9,8 @@ export fn f2(x: V(4, u32)) V(4, u32) {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:12: error: negation of type 'u32'
// tmp.zig:8:12: error: negation of type 'u32'
// :3:12: error: negation of type 'u32'
// :8:12: error: negation of type '@Vector(4, u32)'

View File

@ -4,7 +4,7 @@ fn foo() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:28: error: '.*' cannot be followed by '*'. Are you missing a space?
// :2:28: error: '.*' cannot be followed by '*'. Are you missing a space?

View File

@ -4,8 +4,8 @@ test "Crash" {
}
// error
// backend=stage1
// backend=stage2
// target=native
// is_test=1
//
// tmp.zig:1:11: error: use of undeclared identifier 'B'
// :1:11: error: use of undeclared identifier 'B'

View File

@ -0,0 +1,12 @@
const Foo = error{A};
comptime {
const z = Foo.Bar;
_ = z;
}
// error
// backend=stage2
// target=native
//
// :3:18: error: no error named 'Bar' in 'error{A}'
// :1:13: note: error set declared here

View File

@ -0,0 +1,10 @@
comptime {
var a: i64 = undefined;
a += a;
}
// error
// backend=stage2
// target=native
//
// :3:10: error: use of undefined value here causes undefined behavior

View File

@ -0,0 +1,10 @@
comptime {
var a: i64 = undefined;
_ = a + a;
}
// error
// backend=stage2
// target=native
//
// :3:13: error: use of undefined value here causes undefined behavior

View File

@ -6,7 +6,8 @@ fn add(a: u16, b: u16) u16 {
export fn entry() usize { return @sizeOf(@TypeOf(y)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:14: error: operation caused overflow
// :3:14: error: overflow of integer type 'u16' with value '65540'
// :1:14: note: called from here

View File

@ -6,7 +6,7 @@ const x = Foo {.field = 1} + Foo {.field = 2};
export fn entry() usize { return @sizeOf(@TypeOf(x)); }
// error
// backend=stage1
// backend=llvm
// target=native
//
// tmp.zig:4:28: error: invalid operands to binary expression: 'Foo' and 'Foo'
// :4:28: error: invalid operands to binary expression: 'Struct' and 'Struct'

View File

@ -0,0 +1,10 @@
const x = 3;
const y = &x;
fn foo() *const i32 { return y; }
export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
// error
// backend=stage2
// target=native
//
// :3:30: error: expected type '*const i32', found '*const comptime_int'

View File

@ -3,7 +3,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:19: error: expected pointer or slice, found 'u32'
// :2:19: error: expected pointer type, found 'u32'

View File

@ -8,7 +8,7 @@ export fn entry1() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:7: error: expected ',' after field
// :3:7: error: expected ',' after field

View File

@ -13,9 +13,9 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:5:13: error: ambiguous reference
// tmp.zig:7:9: note: declared here
// tmp.zig:1:1: note: also declared here
// :5:13: error: ambiguous reference
// :7:9: note: declared here
// :1:1: note: also declared here

View File

@ -8,4 +8,4 @@ pub fn main() void {
// backend=stage2,llvm
// target=x86_64-linux,x86_64-macos
//
// :3:21: error: expected *anyopaque, found ?usize
// :3:21: error: expected type '*anyopaque', found '?usize'

View File

@ -0,0 +1,9 @@
export fn f() void {
i[i] = i[i];
}
// error
// backend=stage2
// target=native
//
// :2:5: error: use of undeclared identifier 'i'

View File

@ -5,7 +5,7 @@ const a = derp ++ "foo";
export fn entry() usize { return @sizeOf(@TypeOf(a)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:11: error: expected array, found 'usize'
// :3:11: error: expected indexable; found 'usize'

View File

@ -11,7 +11,7 @@ fn doSomeAsm() void {
}
// error
// backend=stage1
// backend=llvm
// target=native
//
// tmp.zig:6:5: error: unable to evaluate constant expression
// :6:5: error: unable to evaluate constant expression

View File

@ -0,0 +1,12 @@
export fn entry() void {
var a = &b;
_ = a;
}
fn b() callconv(.Inline) void { }
// error
// backend=stage2
// target=native
//
// :2:9: error: variable of type '*const fn() callconv(.Inline) void' must be const or comptime
// :2:9: note: function has inline calling convention

View File

@ -3,7 +3,7 @@ const a: *u8 = null;
export fn entry() usize { return @sizeOf(@TypeOf(a)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:1:16: error: expected type '*u8', found '@Type(.Null)'
// :1:16: error: expected type '*u8', found '@TypeOf(null)'

View File

@ -4,7 +4,7 @@ export fn f() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:13: error: cannot assign to constant
// :3:13: error: cannot assign to constant

View File

@ -4,7 +4,7 @@ export fn f() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:13: error: cannot assign to constant
// :3:13: error: cannot assign to constant

View File

@ -7,7 +7,7 @@ export fn derp() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:6:15: error: cannot assign to constant
// :6:15: error: cannot assign to constant

View File

@ -4,7 +4,7 @@ export fn f() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:9: error: cannot assign to constant
// :3:9: error: cannot assign to constant

View File

@ -4,7 +4,7 @@ export fn foo() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:24: error: integer value 753664 cannot be coerced to type 'u16'
// :2:24: error: type 'u16' cannot represent integer value '753664'

View File

@ -0,0 +1,11 @@
export fn f() void {
const a = return;
_ = a;
}
// error
// backend=stage2
// target=native
//
// :2:5: error: unreachable code
// :2:15: note: control flow is diverted here

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:30: error: @atomicStore atomic ordering must not be Acquire or AcqRel
// :3:31: error: @atomicStore atomic ordering must not be Acquire or AcqRel

View File

@ -5,7 +5,7 @@ export fn f() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:4:81: error: failure atomic ordering must be no stricter than success
// :4:81: error: failure atomic ordering must be no stricter than success

View File

@ -5,7 +5,7 @@ export fn f() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:4:58: error: success atomic ordering must be Monotonic or stricter
// :4:58: error: success atomic ordering must be Monotonic or stricter

View File

@ -0,0 +1,9 @@
export fn entry() void {
@fence(.Monotonic);
}
// error
// backend=stage2
// target=native
//
// :2:13: error: atomic ordering must be Acquire or stricter

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:30: error: @atomicRmw with bool only allowed with .Xchg
// :3:31: error: @atomicRmw with bool only allowed with .Xchg

View File

@ -10,7 +10,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:9:27: error: @atomicRmw with enum only allowed with .Xchg
// :9:28: error: @atomicRmw with enum only allowed with .Xchg

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:29: error: @atomicRmw with float only allowed with .Xchg, .Add and .Sub
// :3:30: error: @atomicRmw with float only allowed with .Xchg, .Add, and .Sub

View File

@ -5,7 +5,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:9: error: expected type 'error{Hi}', found '@Type(.EnumLiteral)'
// :3:10: error: expected type 'error{Hi}', found '@TypeOf(.enum_literal)'

View File

@ -0,0 +1,14 @@
fn SimpleList(comptime L: usize) type {
var T = u8;
return struct {
array: [L]T,
};
}
// error
// backend=stage2
// target=native
//
// :4:19: error: mutable 'T' not accessible from here
// :2:9: note: declared mutable here
// :3:12: note: crosses namespace boundary here

View File

@ -4,7 +4,7 @@ comptime {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:16: error: 17-bit float unsupported
// :3:9: error: 17-bit float unsupported

View File

@ -8,7 +8,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:6:15: error: negation of type 'anyerror!u32'
// :6:15: error: negation of type 'anyerror!u32'

View File

@ -0,0 +1,12 @@
export fn entry(a: bool, b: bool) i32 {
if (a && b) {
return 1234;
}
return 5678;
}
// error
// backend=stage2
// target=native
//
// :2:11: error: ambiguous use of '&&'; use 'and' for logical AND, or change whitespace to ' & &' for bitwise AND

View File

@ -0,0 +1,13 @@
export fn entry(a: bool, b: bool) i32 {
if (a || b) {
return 1234;
}
return 5678;
}
// error
// backend=stage2
// target=native
//
// :2:9: error: expected error set type, found 'bool'
// :2:11: note: '||' merges error sets; 'or' performs boolean OR

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:30: error: expected type '[*]const bool', found 'bool'
// :2:30: error: expected type '[*]const bool', found 'bool'

View File

@ -5,7 +5,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:23: error: expected type '[]u32', found '*const u32'
// :3:22: error: expected type '[]u32', found '*const u32'

View File

@ -11,7 +11,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:8:5: error: use of undeclared identifier 'bogus'
// :8:5: error: use of undeclared identifier 'bogus'

View File

@ -0,0 +1,7 @@
const bogus = @import("bogus-does-not-exist.zig",);
// error
// backend=stage2
// target=native
//
// :1:23: error: unable to load '${DIR}bogus-does-not-exist.zig': FileNotFound

View File

@ -0,0 +1,11 @@
export fn entry() void {
const c = 4;
var v = @splat(4, c);
_ = v;
}
// error
// backend=stage2
// target=native
//
// :3:23: error: expected integer, float, bool, or pointer for the vector element type; found 'comptime_int'

View File

@ -0,0 +1,35 @@
export fn entry1() void {
@call(.{}, foo, {});
}
export fn entry2() void {
comptime @call(.{ .modifier = .never_inline }, foo, .{});
}
export fn entry3() void {
comptime @call(.{ .modifier = .never_tail }, foo, .{});
}
export fn entry4() void {
@call(.{ .modifier = .never_inline }, bar, .{});
}
export fn entry5(c: bool) void {
var baz = if (c) &baz1 else &baz2;
@call(.{ .modifier = .compile_time }, baz, .{});
}
pub export fn entry() void {
var call_me: *const fn () void = undefined;
@call(.{ .modifier = .always_inline }, call_me, .{});
}
fn foo() void {}
fn bar() callconv(.Inline) void {}
fn baz1() void {}
fn baz2() void {}
// error
// backend=stage2
// target=native
//
// :2:21: error: expected a tuple, found 'void'
// :5:21: error: unable to perform 'never_inline' call at compile-time
// :8:21: error: unable to perform 'never_tail' call at compile-time
// :11:5: error: no-inline call of inline function
// :15:43: error: modifier 'compile_time' requires a comptime-known function
// :19:44: error: modifier 'always_inline' requires a comptime-known function

View File

@ -6,8 +6,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
// is_test=1
//
// tmp.zig:2:18: error: invalid operands to binary expression: 'error{A}' and 'error{B}'
// :2:18: error: invalid operands to binary bitwise expression: 'ErrorSet' and 'ErrorSet'

View File

@ -5,7 +5,7 @@ var block_aligned_stuff: usize = (4 + TINY_QUANTUM_SIZE) & ~(TINY_QUANTUM_SIZE -
export fn entry() usize { return @sizeOf(@TypeOf(block_aligned_stuff)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:60: error: unable to perform binary not operation on type 'comptime_int'
// :3:60: error: unable to perform binary not operation on type 'comptime_int'

View File

@ -0,0 +1,10 @@
export fn entry(byte: u8) void {
var oops = @bitCast(u7, byte);
_ = oops;
}
// error
// backend=stage2
// target=native
//
// :2:29: error: @bitCast size mismatch: destination type 'u7' has 7 bits but source type 'u8' has 8 bits

View File

@ -0,0 +1,10 @@
export fn entry() void {
var foo = (@bitCast(u8, @as(f32, 1.0)) == 0xf);
_ = foo;
}
// error
// backend=stage2
// target=native
//
// :2:29: error: @bitCast size mismatch: destination type 'u8' has 8 bits but source type 'f32' has 32 bits

View File

@ -0,0 +1,10 @@
export fn entry() void {
const x = &@as(u8, 1) << 10;
_ = x;
}
// error
// backend=stage2
// target=native
//
// :2:15: error: bit shifting operation expected integer type, found '*const u8'

View File

@ -0,0 +1,11 @@
var self = "aoeu";
fn f(m: []const u8) void {
m.copy(u8, self[0..], m);
}
export fn entry() usize { return @sizeOf(@TypeOf(&f)); }
// error
// backend=stage2
// target=native
//
// :3:6: error: type '[]const u8' has no field or member function named 'copy'

View File

@ -3,7 +3,7 @@ const x = if (undefined) true else false;
export fn entry() usize { return @sizeOf(@TypeOf(x)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:1:15: error: use of undefined value here causes undefined behavior
// :1:15: error: use of undefined value here causes undefined behavior

View File

@ -17,8 +17,8 @@ export fn entry1() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:12:14: error: cannot assign to constant
// tmp.zig:16:14: error: cannot assign to constant
// :12:14: error: cannot assign to constant
// :16:14: error: cannot assign to constant

View File

@ -4,7 +4,7 @@ export fn entry() void {
pub extern fn foo(format: *const u8, ...) void;
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:16: error: expected type '*const u8', found '[5:0]u8'
// :2:8: error: expected type '*const u8', found '[5:0]u8'

View File

@ -8,8 +8,8 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:6:20: error: enum 'Foo' has no field named 'c'
// tmp.zig:1:13: note: 'Foo' declared here
// :6:21: error: enum 'tmp.Foo' has no field named 'c'
// :1:13: note: enum declared here

View File

@ -0,0 +1,10 @@
export fn entry() void {
const x = @as(usize, -10);
_ = x;
}
// error
// backend=stage2
// target=native
//
// :2:26: error: type 'usize' cannot represent integer value '-10'

View File

@ -10,8 +10,8 @@ export fn entry1() void {
}
// error
// backend=stage1
// backend=llvm
// target=native
//
// tmp.zig:3:22: error: attempt to cast negative value to unsigned integer
// tmp.zig:8:27: error: cannot cast negative value -1 to unsigned integer type 'u32'
// :3:36: error: type 'u32' cannot represent integer value '-1'
// :8:27: error: type 'u32' cannot represent integer value '-1'

View File

@ -0,0 +1,13 @@
fn f() i32 {
return @as(i32, return 1);
}
export fn entry() void { _ = f(); }
// error
// backend=stage2
// target=native
//
// :2:12: error: unreachable code
// :2:21: note: control flow is diverted here
// :2:5: error: unreachable code
// :2:12: note: control flow is diverted here

View File

@ -12,10 +12,10 @@ fn bar(x: *const u3) u3 {
return x.*;
}
export fn entry() usize { return @sizeOf(@TypeOf(foo)); }
export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:8:26: error: expected type '*const u3', found '*align(:3:1) const u3'
// :8:15: error: expected type '*const u3', found '*align(0:3:1) const u3'

View File

@ -3,7 +3,7 @@ export fn a(value: u32) bool {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:22: error: comparison operators cannot be chained
// :2:22: error: comparison operators cannot be chained

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:22: error: expected bool, integer, enum or pointer type, found 'f32'
// :3:22: error: expected bool, integer, enum, or pointer type; found 'f32'

View File

@ -0,0 +1,12 @@
fn func() bogus {}
fn func() bogus {}
export fn entry() usize { return @sizeOf(@TypeOf(func)); }
// error
// backend=stage2
// target=native
//
// :2:1: error: redeclaration of 'func'
// :1:1: note: other declaration here
// :1:11: error: use of undeclared identifier 'bogus'
// :2:11: error: use of undeclared identifier 'bogus'

View File

@ -8,9 +8,8 @@ export fn entry() void {
fn foo() void {}
// error
// backend=stage1
// backend=stage2
// target=native
// is_test=1
//
// tmp.zig:4:9: error: suspend inside nosuspend block
// tmp.zig:2:5: note: nosuspend block here
// :4:9: error: suspend inside nosuspend block
// :2:5: note: nosuspend block here

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:12: error: comparison of '*i32' with null
// :3:12: error: comparison of '*i32' with null

View File

@ -0,0 +1,9 @@
export fn entry() void {
if (2 == undefined) {}
}
// error
// backend=stage2
// target=native
//
// :2:11: error: use of undefined value here causes undefined behavior

View File

@ -36,12 +36,12 @@ comptime {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:5:11: error: use of undefined value here causes undefined behavior
// tmp.zig:11:11: error: use of undefined value here causes undefined behavior
// tmp.zig:17:11: error: use of undefined value here causes undefined behavior
// tmp.zig:23:11: error: use of undefined value here causes undefined behavior
// tmp.zig:29:11: error: use of undefined value here causes undefined behavior
// tmp.zig:35:11: error: use of undefined value here causes undefined behavior
// :5:11: error: use of undefined value here causes undefined behavior
// :11:11: error: use of undefined value here causes undefined behavior
// :17:11: error: use of undefined value here causes undefined behavior
// :23:11: error: use of undefined value here causes undefined behavior
// :29:11: error: use of undefined value here causes undefined behavior
// :35:11: error: use of undefined value here causes undefined behavior

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:25: error: operator not allowed for type 'anyerror!i32'
// :3:25: error: operator == not allowed for type 'anyerror!i32'

View File

@ -8,7 +8,7 @@ export fn entry() i32 {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:1:13: error: aoeu
// :1:13: error: aoeu

View File

@ -10,7 +10,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:14: error: use of undeclared identifier 'crap'
// :2:14: error: use of undeclared identifier 'crap'

View File

@ -8,7 +8,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:11: error: use of undeclared identifier 'SymbolThatDoesNotExist'
// :2:11: error: use of undeclared identifier 'SymbolThatDoesNotExist'

View File

@ -3,7 +3,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:5: error: found compile log statement
// :2:5: error: found compile log statement

View File

@ -8,7 +8,8 @@ fn inner(comptime n: usize) void {
}
// error
// backend=stage1
// backend=llvm
// target=native
//
// tmp.zig:7:39: error: found compile log statement
// :7:39: error: found compile log statement
// :7:39: note: also here

View File

@ -0,0 +1,18 @@
const Letter = enum { A, B, C };
const Value = union(Letter) {
A: i32,
B,
C,
};
export fn entry() void {
var x: Value = Letter.A;
_ = x;
}
// error
// backend=stage2
// target=native
//
// :8:26: error: coercion from enum 'tmp.Letter' to union 'tmp.Value' must initialize 'i32' field 'A'
// :3:5: note: field 'A' declared here
// :2:15: note: union declared here

View File

@ -4,7 +4,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:41: error: non-zero length slice of undefined pointer
// :2:41: error: non-zero length slice of undefined pointer

View File

@ -7,7 +7,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:5: error: comptime field without default initialization value
// :2:5: error: comptime field without default initialization value

View File

@ -6,9 +6,8 @@ comptime {
}
// error
// backend=stage1
// backend=stage2
// target=native
// is_test=1
//
// tmp.zig:4:15: error: operation caused overflow
// tmp.zig:4:15: note: when computing vector element at index 2
// :4:15: error: overflow of vector type '@Vector(4, u8)' with value '.{ 6, 8, 256, 12 }'
// :4:15: note: when computing vector element at index '2'

View File

@ -0,0 +1,9 @@
export fn f() void {
(const a = 0);
}
// error
// backend=stage2
// target=native
//
// :2:6: error: expected expression, found 'const'

View File

@ -4,7 +4,7 @@ const a = zero{1};
export fn entry() usize { return @sizeOf(@TypeOf(a)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:2:11: error: expected type 'type', found 'i32'
// :2:15: error: expected type 'type', found 'i32'

View File

@ -0,0 +1,15 @@
export fn foo() void {
comptime var i = 0;
while (i < 5) : (i += 1) {
bar();
}
}
fn bar() void { }
// error
// backend=stage2
// target=native
//
// :3:24: error: cannot store to comptime variable in non-inline loop
// :3:5: note: non-inline loop here

View File

@ -16,9 +16,9 @@ comptime {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:9:5: error: declarations are not allowed between container fields
// tmp.zig:5:5: note: field before declarations here
// tmp.zig:12:5: note: field after declarations here
// :9:5: error: declarations are not allowed between container fields
// :5:5: note: field before declarations here
// :12:5: note: field after declarations here

View File

@ -0,0 +1,12 @@
const u8 = u16;
export fn entry() void {
const a: u8 = 300;
_ = a;
}
// error
// backend=stage2
// target=native
//
// :1:7: error: name shadows primitive 'u8'
// :1:7: note: consider using @"u8" to disambiguate

View File

@ -0,0 +1,13 @@
export fn a() void {
x += 1;
}
export fn b() void {
x += 1;
}
// error
// backend=stage2
// target=native
//
// :2:5: error: use of undeclared identifier 'x'
// :5:5: error: use of undeclared identifier 'x'

View File

@ -7,7 +7,7 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:5:29: error: expected type '*anyopaque', found '**u32'
// :5:28: error: expected type '*anyopaque', found '**u32'

View File

@ -16,8 +16,8 @@ comptime {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:5:9: error: duplicate switch value
// tmp.zig:13:9: error: duplicate switch value
// :5:9: error: duplicate switch value
// :13:9: error: duplicate switch value

View File

@ -8,8 +8,8 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:5: error: duplicate error set field 'Bar'
// tmp.zig:2:5: note: previous declaration here
// :3:5: error: duplicate error set field 'Bar'
// :2:5: note: previous declaration here

View File

@ -14,7 +14,8 @@ export fn f() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:11:9: error: duplicate field
// :11:10: error: duplicate field
// :8:10: note: other field here

View File

@ -8,8 +8,9 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:5: error: duplicate struct field: 'Bar'
// tmp.zig:2:5: note: other field here
// :3:5: error: duplicate struct field: 'Bar'
// :2:5: note: other field here
// :1:13: note: struct declared here

View File

@ -8,8 +8,9 @@ export fn entry() void {
}
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:3:5: error: duplicate union field: 'Bar'
// tmp.zig:2:5: note: other field here
// :3:5: error: duplicate union field: 'Bar'
// :2:5: note: other field here
// :1:13: note: union declared here

View File

@ -3,7 +3,7 @@ const resource = @embedFile("bogus.txt",);
export fn entry() usize { return @sizeOf(@TypeOf(resource)); }
// error
// backend=stage1
// backend=stage2
// target=native
//
// tmp.zig:1:29: error: unable to find '
// :1:29: error: unable to open 'bogus.txt': FileNotFound

View File

@ -0,0 +1,9 @@
export fn a() void {
for(undefined) |x|;
}
// error
// backend=stage2
// target=native
//
// :2:23: error: expected block or assignment, found ';'

View File

@ -0,0 +1,9 @@
export fn a() void {
if(true);
}
// error
// backend=stage2
// target=native
//
// :2:13: error: expected block or assignment, found ';'

Some files were not shown because too many files have changed in this diff Show More