Merge pull request #4397 from LemonBoy/fixes

Fixes
This commit is contained in:
Andrew Kelley 2020-02-05 17:04:40 -05:00 committed by GitHub
commit 80ae434b66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 10 deletions

View File

@ -810,7 +810,7 @@ pub const Dir = struct {
};
var attr = w.OBJECT_ATTRIBUTES{
.Length = @sizeOf(w.OBJECT_ATTRIBUTES),
.RootDirectory = if (path.isAbsoluteW(sub_path_w)) null else self.fd,
.RootDirectory = if (path.isAbsoluteWindowsW(sub_path_w)) null else self.fd,
.Attributes = 0, // Note we do not use OBJ_CASE_INSENSITIVE here.
.ObjectName = &nt_name,
.SecurityDescriptor = null,
@ -960,7 +960,7 @@ pub const Dir = struct {
};
var attr = w.OBJECT_ATTRIBUTES{
.Length = @sizeOf(w.OBJECT_ATTRIBUTES),
.RootDirectory = if (path.isAbsoluteW(sub_path_w)) null else self.fd,
.RootDirectory = if (path.isAbsoluteWindowsW(sub_path_w)) null else self.fd,
.Attributes = 0, // Note we do not use OBJ_CASE_INSENSITIVE here.
.ObjectName = &nt_name,
.SecurityDescriptor = null,
@ -1327,7 +1327,7 @@ pub fn openFileAbsoluteC(absolute_path_c: [*:0]const u8, flags: File.OpenFlags)
/// Same as `openFileAbsolute` but the path parameter is WTF-16 encoded.
pub fn openFileAbsoluteW(absolute_path_w: [*:0]const u16, flags: File.OpenFlags) File.OpenError!File {
assert(path.isAbsoluteW(absolute_path_w));
assert(path.isAbsoluteWindowsW(absolute_path_w));
return cwd().openFileW(absolute_path_w, flags);
}
@ -1350,7 +1350,7 @@ pub fn createFileAbsoluteC(absolute_path_c: [*:0]const u8, flags: File.CreateFla
/// Same as `createFileAbsolute` but the path parameter is WTF-16 encoded.
pub fn createFileAbsoluteW(absolute_path_w: [*:0]const u16, flags: File.CreateFlags) File.OpenError!File {
assert(path.isAbsoluteW(absolute_path_w));
assert(path.isAbsoluteWindowsW(absolute_path_w));
return cwd().createFileW(absolute_path_w, flags);
}
@ -1371,7 +1371,7 @@ pub fn deleteFileAbsoluteC(absolute_path_c: [*:0]const u8) DeleteFileError!void
/// Same as `deleteFileAbsolute` except the parameter is WTF-16 encoded.
pub fn deleteFileAbsoluteW(absolute_path_w: [*:0]const u16) DeleteFileError!void {
assert(path.isAbsoluteW(absolute_path_w));
assert(path.isAbsoluteWindowsW(absolute_path_w));
return cwd().deleteFileW(absolute_path_w);
}

View File

@ -173,7 +173,7 @@ pub fn isAbsoluteWindows(path: []const u8) bool {
return isAbsoluteWindowsImpl(u8, path);
}
pub fn isAbsoluteW(path_w: [*:0]const u16) bool {
pub fn isAbsoluteWindowsW(path_w: [*:0]const u16) bool {
return isAbsoluteWindowsImpl(u16, mem.toSliceConst(u16, path_w));
}

View File

@ -1572,7 +1572,7 @@ pub const NOFLSH = 128;
pub const TOSTOP = 256;
pub const IEXTEN = 32768;
pub const TCSA = extern enum(usize) {
pub const TCSA = extern enum(c_uint) {
NOW,
DRAIN,
FLUSH,

View File

@ -11864,7 +11864,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted
}
assert(wanted_type->data.fn.is_generic ||
wanted_type->data.fn.fn_type_id.next_param_index == wanted_type->data.fn.fn_type_id.param_count);
for (size_t i = 0; i < wanted_type->data.fn.fn_type_id.next_param_index; i += 1) {
for (size_t i = 0; i < wanted_type->data.fn.fn_type_id.param_count; i += 1) {
// note it's reversed for parameters
FnTypeParamInfo *actual_param_info = &actual_type->data.fn.fn_type_id.param_info[i];
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
if (param_is_var_args) {
if (fn_type_id.cc == CallingConventionC) {
fn_type_id.param_count = fn_type_id.next_param_index;
continue;
break;
} else if (fn_type_id.cc == CallingConventionUnspecified) {
return get_generic_fn_type(ira->codegen, &fn_type_id);
} else {

View File

@ -806,7 +806,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {
if (param_decl->data.param_decl.is_var_args)
res->data.fn_proto.is_var_args = true;
if (i != params.length - 1 && res->data.fn_proto.is_var_args)
ast_error(pc, first, "Function prototype have varargs as a none last paramter.");
ast_error(pc, first, "Function prototype have varargs as a none last parameter.");
}
return res;
}

View File

@ -3,6 +3,17 @@ const builtin = @import("builtin");
const Target = @import("std").Target;
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.addTest("type mismatch in C prototype with varargs",
\\const fn_ty = ?fn ([*c]u8, ...) callconv(.C) void;
\\extern fn fn_decl(fmt: [*:0]u8, ...) void;
\\
\\export fn main() void {
\\ const x: fn_ty = fn_decl;
\\}
, &[_][]const u8{
"tmp.zig:5:22: error: expected type 'fn([*c]u8, ...) callconv(.C) void', found 'fn([*:0]u8, ...) callconv(.C) void'",
});
cases.addTest("dependency loop in top-level decl with @TypeInfo",
\\export const foo = @typeInfo(@This());
, &[_][]const u8{