-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[Clang] correct error message when assigning to const reference captured in lambda #105647
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,6 +194,11 @@ namespace ModifyingCapture { | |
[=] { | ||
n = 1; // expected-error {{cannot assign to a variable captured by copy in a non-mutable lambda}} | ||
}; | ||
const int cn = 0; | ||
// cxx03-cxx11-warning@+1 {{initialized lambda captures are a C++14 extension}} | ||
[&cnr = cn]{ // expected-note {{variable 'cnr' declared const here}} | ||
|
||
cnr = 1; // expected-error {{cannot assign to variable 'cnr' with const-qualified type 'const int &'}} | ||
}; | ||
} | ||
} | ||
|
||
|
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.
I think we should have also tested a
constexpr
variable case and maybe aauto &
assigned fromcn
as well just to cover a more complete test set.