authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-05 17:04:40-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-02-05 17:04:40-05:00
log80ae434b6686f44c98baa7c404131aefd136b977
treeba89f99ec9f9d82da0216ee756ba8316a90aeda7
parent378d733439a574cc7b961f1d6a09167479225da8
parent8c55c4550a7f79d732f0d2ffbf0455b058ab5aad
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #4397 from LemonBoy/fixes

Fixes

6 files changed, 21 insertions(+), 10 deletions(-)

lib/std/fs.zig+5-5
...@@ -810,7 +810,7 @@ pub const Dir = struct {...@@ -810,7 +810,7 @@ pub const Dir = struct {
810 };810 };
811 var attr = w.OBJECT_ATTRIBUTES{811 var attr = w.OBJECT_ATTRIBUTES{
812 .Length = @sizeOf(w.OBJECT_ATTRIBUTES),812 .Length = @sizeOf(w.OBJECT_ATTRIBUTES),
813 .RootDirectory = if (path.isAbsoluteW(sub_path_w)) null else self.fd,813 .RootDirectory = if (path.isAbsoluteWindowsW(sub_path_w)) null else self.fd,
814 .Attributes = 0, // Note we do not use OBJ_CASE_INSENSITIVE here.814 .Attributes = 0, // Note we do not use OBJ_CASE_INSENSITIVE here.
815 .ObjectName = &nt_name,815 .ObjectName = &nt_name,
816 .SecurityDescriptor = null,816 .SecurityDescriptor = null,
...@@ -960,7 +960,7 @@ pub const Dir = struct {...@@ -960,7 +960,7 @@ pub const Dir = struct {
960 };960 };
961 var attr = w.OBJECT_ATTRIBUTES{961 var attr = w.OBJECT_ATTRIBUTES{
962 .Length = @sizeOf(w.OBJECT_ATTRIBUTES),962 .Length = @sizeOf(w.OBJECT_ATTRIBUTES),
963 .RootDirectory = if (path.isAbsoluteW(sub_path_w)) null else self.fd,963 .RootDirectory = if (path.isAbsoluteWindowsW(sub_path_w)) null else self.fd,
964 .Attributes = 0, // Note we do not use OBJ_CASE_INSENSITIVE here.964 .Attributes = 0, // Note we do not use OBJ_CASE_INSENSITIVE here.
965 .ObjectName = &nt_name,965 .ObjectName = &nt_name,
966 .SecurityDescriptor = null,966 .SecurityDescriptor = null,
...@@ -1327,7 +1327,7 @@ pub fn openFileAbsoluteC(absolute_path_c: [*:0]const u8, flags: File.OpenFlags)...@@ -1327,7 +1327,7 @@ pub fn openFileAbsoluteC(absolute_path_c: [*:0]const u8, flags: File.OpenFlags)
13271327
1328/// Same as `openFileAbsolute` but the path parameter is WTF-16 encoded.1328/// Same as `openFileAbsolute` but the path parameter is WTF-16 encoded.
1329pub fn openFileAbsoluteW(absolute_path_w: [*:0]const u16, flags: File.OpenFlags) File.OpenError!File {1329pub fn openFileAbsoluteW(absolute_path_w: [*:0]const u16, flags: File.OpenFlags) File.OpenError!File {
1330 assert(path.isAbsoluteW(absolute_path_w));1330 assert(path.isAbsoluteWindowsW(absolute_path_w));
1331 return cwd().openFileW(absolute_path_w, flags);1331 return cwd().openFileW(absolute_path_w, flags);
1332}1332}
13331333
...@@ -1350,7 +1350,7 @@ pub fn createFileAbsoluteC(absolute_path_c: [*:0]const u8, flags: File.CreateFla...@@ -1350,7 +1350,7 @@ pub fn createFileAbsoluteC(absolute_path_c: [*:0]const u8, flags: File.CreateFla
13501350
1351/// Same as `createFileAbsolute` but the path parameter is WTF-16 encoded.1351/// Same as `createFileAbsolute` but the path parameter is WTF-16 encoded.
1352pub fn createFileAbsoluteW(absolute_path_w: [*:0]const u16, flags: File.CreateFlags) File.OpenError!File {1352pub fn createFileAbsoluteW(absolute_path_w: [*:0]const u16, flags: File.CreateFlags) File.OpenError!File {
1353 assert(path.isAbsoluteW(absolute_path_w));1353 assert(path.isAbsoluteWindowsW(absolute_path_w));
1354 return cwd().createFileW(absolute_path_w, flags);1354 return cwd().createFileW(absolute_path_w, flags);
1355}1355}
13561356
...@@ -1371,7 +1371,7 @@ pub fn deleteFileAbsoluteC(absolute_path_c: [*:0]const u8) DeleteFileError!void...@@ -1371,7 +1371,7 @@ pub fn deleteFileAbsoluteC(absolute_path_c: [*:0]const u8) DeleteFileError!void
13711371
1372/// Same as `deleteFileAbsolute` except the parameter is WTF-16 encoded.1372/// Same as `deleteFileAbsolute` except the parameter is WTF-16 encoded.
1373pub fn deleteFileAbsoluteW(absolute_path_w: [*:0]const u16) DeleteFileError!void {1373pub fn deleteFileAbsoluteW(absolute_path_w: [*:0]const u16) DeleteFileError!void {
1374 assert(path.isAbsoluteW(absolute_path_w));1374 assert(path.isAbsoluteWindowsW(absolute_path_w));
1375 return cwd().deleteFileW(absolute_path_w);1375 return cwd().deleteFileW(absolute_path_w);
1376}1376}
13771377
lib/std/fs/path.zig+1-1
...@@ -173,7 +173,7 @@ pub fn isAbsoluteWindows(path: []const u8) bool {...@@ -173,7 +173,7 @@ pub fn isAbsoluteWindows(path: []const u8) bool {
173 return isAbsoluteWindowsImpl(u8, path);173 return isAbsoluteWindowsImpl(u8, path);
174}174}
175175
176pub fn isAbsoluteW(path_w: [*:0]const u16) bool {176pub fn isAbsoluteWindowsW(path_w: [*:0]const u16) bool {
177 return isAbsoluteWindowsImpl(u16, mem.toSliceConst(u16, path_w));177 return isAbsoluteWindowsImpl(u16, mem.toSliceConst(u16, path_w));
178}178}
179179
lib/std/os/bits/linux.zig+1-1
...@@ -1572,7 +1572,7 @@ pub const NOFLSH = 128;...@@ -1572,7 +1572,7 @@ pub const NOFLSH = 128;
1572pub const TOSTOP = 256;1572pub const TOSTOP = 256;
1573pub const IEXTEN = 32768;1573pub const IEXTEN = 32768;
15741574
1575pub const TCSA = extern enum(usize) {1575pub const TCSA = extern enum(c_uint) {
1576 NOW,1576 NOW,
1577 DRAIN,1577 DRAIN,
1578 FLUSH,1578 FLUSH,
src/ir.cpp+2-2
...@@ -11864,7 +11864,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted...@@ -11864,7 +11864,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted
11864 }11864 }
11865 assert(wanted_type->data.fn.is_generic ||11865 assert(wanted_type->data.fn.is_generic ||
11866 wanted_type->data.fn.fn_type_id.next_param_index == wanted_type->data.fn.fn_type_id.param_count);11866 wanted_type->data.fn.fn_type_id.next_param_index == wanted_type->data.fn.fn_type_id.param_count);
11867 for (size_t i = 0; i < wanted_type->data.fn.fn_type_id.next_param_index; i += 1) {11867 for (size_t i = 0; i < wanted_type->data.fn.fn_type_id.param_count; i += 1) {
11868 // note it's reversed for parameters11868 // note it's reversed for parameters
11869 FnTypeParamInfo *actual_param_info = &actual_type->data.fn.fn_type_id.param_info[i];11869 FnTypeParamInfo *actual_param_info = &actual_type->data.fn.fn_type_id.param_info[i];
11870 FnTypeParamInfo *expected_param_info = &wanted_type->data.fn.fn_type_id.param_info[i];11870 FnTypeParamInfo *expected_param_info = &wanted_type->data.fn.fn_type_id.param_info[i];
...@@ -30285,7 +30285,7 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La...@@ -30285,7 +30285,7 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La
30285 if (param_is_var_args) {30285 if (param_is_var_args) {
30286 if (fn_type_id.cc == CallingConventionC) {30286 if (fn_type_id.cc == CallingConventionC) {
30287 fn_type_id.param_count = fn_type_id.next_param_index;30287 fn_type_id.param_count = fn_type_id.next_param_index;
30288 continue;30288 break;
30289 } else if (fn_type_id.cc == CallingConventionUnspecified) {30289 } else if (fn_type_id.cc == CallingConventionUnspecified) {
30290 return get_generic_fn_type(ira->codegen, &fn_type_id);30290 return get_generic_fn_type(ira->codegen, &fn_type_id);
30291 } else {30291 } else {
src/parser.cpp+1-1
...@@ -806,7 +806,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {...@@ -806,7 +806,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {
806 if (param_decl->data.param_decl.is_var_args)806 if (param_decl->data.param_decl.is_var_args)
807 res->data.fn_proto.is_var_args = true;807 res->data.fn_proto.is_var_args = true;
808 if (i != params.length - 1 && res->data.fn_proto.is_var_args)808 if (i != params.length - 1 && res->data.fn_proto.is_var_args)
809 ast_error(pc, first, "Function prototype have varargs as a none last paramter.");809 ast_error(pc, first, "Function prototype have varargs as a none last parameter.");
810 }810 }
811 return res;811 return res;
812}812}
test/compile_errors.zig+11
...@@ -3,6 +3,17 @@ const builtin = @import("builtin");...@@ -3,6 +3,17 @@ const builtin = @import("builtin");
3const Target = @import("std").Target;3const Target = @import("std").Target;
44
5pub fn addCases(cases: *tests.CompileErrorContext) void {5pub fn addCases(cases: *tests.CompileErrorContext) void {
6 cases.addTest("type mismatch in C prototype with varargs",
7 \\const fn_ty = ?fn ([*c]u8, ...) callconv(.C) void;
8 \\extern fn fn_decl(fmt: [*:0]u8, ...) void;
9 \\
10 \\export fn main() void {
11 \\ const x: fn_ty = fn_decl;
12 \\}
13 , &[_][]const u8{
14 "tmp.zig:5:22: error: expected type 'fn([*c]u8, ...) callconv(.C) void', found 'fn([*:0]u8, ...) callconv(.C) void'",
15 });
16
6 cases.addTest("dependency loop in top-level decl with @TypeInfo",17 cases.addTest("dependency loop in top-level decl with @TypeInfo",
7 \\export const foo = @typeInfo(@This());18 \\export const foo = @typeInfo(@This());
8 , &[_][]const u8{19 , &[_][]const u8{