-
Notifications
You must be signed in to change notification settings - Fork 165
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
Verify functions have sized parameters/return values #2738
base: master
Are you sure you want to change the base?
Conversation
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 is a great idea, thank you :) I like how simple it is too
@@ -254,6 +254,7 @@ struct CompileOptions | |||
NameResolution, | |||
Lowering, | |||
TypeCheck, | |||
SizedCheck, |
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.
you'll need to update gcc/rust/lang.opt
as well to add that option
|
||
for (auto ¶m : fntype->get_params ()) | ||
if (!is_sized (param.second)) | ||
rust_error_at (param.first->get_locus (), "function parameter type %<%s%> is dynamically sized", param.second->as_string ().c_str ()); |
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.
rust_error_at (param.first->get_locus (), "function parameter type %<%s%> is dynamically sized", param.second->as_string ().c_str ()); | |
rust_error_at (param.first->get_locus (), "function parameter type %qs is dynamically sized", param.second->as_string ().c_str ()); |
TyTy::BaseType *ret_type = fntype->get_return_type (); | ||
if (!is_sized (ret_type)) | ||
// TODO: give this a better location_t | ||
rust_error_at (function.get_locus (), "function return type %<%s%> is dynamically sized", ret_type->as_string ().c_str ()); |
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.
same here
This adds an extra compiler pass called
SizedChecker
which handles the new checks