-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[clang][Sema] Emit more specific diagnostic for auto in lambda before C++14 (#46059) #68540
[clang][Sema] Emit more specific diagnostic for auto in lambda before C++14 (#46059) #68540
Conversation
Thanks for this patch! Our policy is to not mix functional changes and formatting changes. |
3690ee2
to
7e62fe6
Compare
Thank you for the feedback and for your patience. :-) It should be fixed now (hopefully!) |
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.
A small nit, otherwise LGTM
I'm not sure it's strictly necessary here, but you could add a release note in clang/docs/ReleaseNotes.rst - under the diagnostics improvement section
@@ -2393,7 +2393,7 @@ def err_auto_not_allowed : Error< | |||
"|in type allocated by 'new'|in K&R-style function parameter" | |||
"|in template parameter|in friend declaration|in function prototype that is " | |||
"not a function declaration|in requires expression parameter" | |||
"|in array declaration}1">; | |||
"|in array declaration|in lambda parameter until C++14}1">; |
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.
"|in array declaration|in lambda parameter until C++14}1">; | |
"|in array declaration|in lambda parameter before C++14}1">; |
To be consistent with other diagnostics
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.
Thanks, done.
… C++14 (llvm#46059) Namely, we specify that `auto` in a lambda parameter is a C++14 extension in the error message, which now reads: `'auto' not allowed in lambda parameter until C++14` This does not change the behavior for `decltype(auto)` and `__auto_type` though. The relevant change to `SemaType.cpp` is the addition of a branch that sets `Error = 24`, whilst the bulk of the change comes from formatting.
7e62fe6
to
99bc3b6
Compare
LMK if the release note sounds good. If so, could you land this patch for me? Please use "Leonardo Duarte weltschildkroete@gmail.com" to commit the change. Thanks! |
clang/lib/Sema/SemaType.cpp
Outdated
Auto->getKeyword() != AutoTypeKeyword::Auto) { | ||
if (!SemaRef.getLangOpts().CPlusPlus14 && Auto && | ||
Auto->getKeyword() == AutoTypeKeyword::Auto) { | ||
Error = 24; |
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.
A lot of the other cases have comments explaining what diagnostic the code pertains to. See 20 or 7 below for example.
This is not really great but at least we have a guide to which diagnostic we intend to emit.
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.
Makes sense. I added some similar comments as well.
✅ With the latest revision this PR passed the C/C++ code formatter. |
@shafik I'll let you have the final say :) |
@shafik ping |
Apologies, this got lost on my end. |
Namely, we specify that
auto
in a lambda parameter is a C++14 extension in the error message, which now reads:'auto' not allowed in lambda parameter before C++14
This does not change the behavior for
decltype(auto)
and__auto_type
though.