From 5457cec8da2715c77f1ffb677b9398bb60c73152 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Fri, 14 Apr 2023 04:02:18 +0200 Subject: [PATCH] update to latest zig: add c_char type (#1124) * update to latest zig: add c_char type * Bump version, add c_char to isTypeIdent --- build.zig | 2 +- src/analysis.zig | 1 + src/stage2/AstGen.zig | 4 ++++ src/stage2/Zir.zig | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 36caf9a..ad2f096 100644 --- a/build.zig +++ b/build.zig @@ -7,7 +7,7 @@ const zls_version = std.builtin.Version{ .major = 0, .minor = 11, .patch = 0 }; pub fn build(b: *std.build.Builder) !void { comptime { const current_zig = builtin.zig_version; - const min_zig = std.SemanticVersion.parse("0.11.0-dev.2558+d3a237a98") catch unreachable; // zig build changes - "remove-legacy-build-api" https://github.com/ziglang/zig/pull/15234 + const min_zig = std.SemanticVersion.parse("0.11.0-dev.2571+31738de28") catch unreachable; // add c_char - https://github.com/ziglang/zig/pull/15263 if (current_zig.order(min_zig) == .lt) { @compileError(std.fmt.comptimePrint("Your Zig version v{} does not meet the minimum build requirement of v{}", .{ current_zig, min_zig })); } diff --git a/src/analysis.zig b/src/analysis.zig index 853d733..d6557a5 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -653,6 +653,7 @@ pub fn isTypeIdent(text: []const u8) bool { .{"type"}, .{"anyerror"}, .{"comptime_int"}, .{"comptime_float"}, .{"anyframe"}, .{"anytype"}, + .{"c_char"} }); if (PrimitiveTypes.has(text)) return true; diff --git a/src/stage2/AstGen.zig b/src/stage2/AstGen.zig index a71fdc1..8a53e68 100644 --- a/src/stage2/AstGen.zig +++ b/src/stage2/AstGen.zig @@ -9025,6 +9025,7 @@ const primitive_instrs = std.ComptimeStringMap(Zir.Inst.Ref, .{ .{ "c_long", .c_long_type }, .{ "c_longdouble", .c_longdouble_type }, .{ "c_longlong", .c_longlong_type }, + .{ "c_char", .c_char_type }, .{ "c_short", .c_short_type }, .{ "c_uint", .c_uint_type }, .{ "c_ulong", .c_ulong_type }, @@ -9773,6 +9774,7 @@ fn nodeImpliesMoreThanOnePossibleValue(tree: *const Ast, start_node: Ast.Node.In .c_long_type, .c_longdouble_type, .c_longlong_type, + .c_char_type, .c_short_type, .c_uint_type, .c_ulong_type, @@ -10018,6 +10020,7 @@ fn nodeImpliesComptimeOnly(tree: *const Ast, start_node: Ast.Node.Index) bool { .c_long_type, .c_longdouble_type, .c_longlong_type, + .c_char_type, .c_short_type, .c_uint_type, .c_ulong_type, @@ -10158,6 +10161,7 @@ fn rvalue( as_ty | @enumToInt(Zir.Inst.Ref.i64_type), as_ty | @enumToInt(Zir.Inst.Ref.usize_type), as_ty | @enumToInt(Zir.Inst.Ref.isize_type), + as_ty | @enumToInt(Zir.Inst.Ref.c_char_type), as_ty | @enumToInt(Zir.Inst.Ref.c_short_type), as_ty | @enumToInt(Zir.Inst.Ref.c_ushort_type), as_ty | @enumToInt(Zir.Inst.Ref.c_int_type), diff --git a/src/stage2/Zir.zig b/src/stage2/Zir.zig index 19009f2..0d7d561 100644 --- a/src/stage2/Zir.zig +++ b/src/stage2/Zir.zig @@ -2079,6 +2079,7 @@ pub const Inst = struct { i128_type, usize_type, isize_type, + c_char_type, c_short_type, c_ushort_type, c_int_type,