-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check argument size on static array parameters #742
Conversation
src/aro/Parser.zig
Outdated
@@ -7683,6 +7684,18 @@ fn callExpr(p: *Parser, lhs: Result) Error!Result { | |||
continue; | |||
} | |||
const p_ty = params[arg_count].ty; | |||
if (p_ty.statically_sized_array) { | |||
if (arg.ty.data == .array and arg.ty.data.array.*.len < p_ty.data.array.*.len) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use arrayLen
instead of making the union tagged.
.expected = @intCast(arg.ty.data.array.*.len), | ||
.actual = @intCast(p_ty.data.array.*.len), | ||
} }; | ||
try p.errExtra(.array_argument_too_small, param_tok, extra); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang also adds a callee declares array parameter as static here
note. You should be able to do the same with params[arg_count].name_tok
.
src/aro/Type.zig
Outdated
@@ -425,6 +425,7 @@ data: union { | |||
specifier: Specifier, | |||
qual: Qualifiers = .{}, | |||
decayed: bool = false, | |||
statically_sized_array: bool = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vexu all the desired changes have been made |
Closes #349