-
Notifications
You must be signed in to change notification settings - Fork 159
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
#[no_mangle]
should not be applied to non-ASCII items
#2552
Conversation
51fd830
to
fa611cb
Compare
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.
Hm, I'm not sure having that check so late in the backend is the right way to go about it. We can add a check to the attribute checker in rust-attributes.h
and just check if a function or method has the attribute and a non-ascii name. I think that will be easier
rustc does somethinig like it. It will be better. |
a4743cc
to
ca730f1
Compare
@CohenArthur |
23ba1f7
to
179a71f
Compare
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.
Looks really good! And yeah, it is much simpler. Thanks for making the changes! Great work!
gcc/rust/util/rust-attributes.cc
Outdated
auto check_function_name = [] (const char *name, const Identifier &ident) { | ||
if (!is_ascii_only (ident.as_string ())) | ||
rust_error_at (ident.get_locus (), | ||
"the %<#[%s]%> attribute requires ASCII identifier", name); | ||
}; |
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.
will this function be used for anything other than the #[no_mangle]
attribute? If no, we can skip having the const char *name
argument. I think it would also be cleaner to have it as a static void
function in the file rather than a lambda, as C++ lambdas are not super easy to read
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.
Okay. I will fix it later.
gcc/rust/ChangeLog: * lex/rust-input-source.h: Move constants from here... * util/rust-codepoint.h (struct Codepoint): ... to here * util/rust-attributes.cc (check_no_mangle_function): New function. (AttributeChecker::visit): Use it. * util/rust-unicode.cc (is_ascii_only): New function. * util/rust-unicode.h (is_ascii_only): Likewise. * backend/rust-mangle.cc (legacy_mangle_name): Use it. * util/rust-punycode.cc (extract_basic_string): Likewise. * lex/rust-lex.cc (Lexer::parse_byte_char): Likewise. Signed-off-by: Raiki Tamura <[email protected]>
179a71f
to
dbdbd56
Compare
@CohenArthur Everything is fixed now :) |
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.
Looks great! Tiny nitpick and I'll merge this. Thank you!
Fixes #2548
Error diagnostics looks like this: