diff options
author | Nicolas Lesser <blitzrakete@gmail.com> | 2018-10-25 20:15:03 +0000 |
---|---|---|
committer | Nicolas Lesser <blitzrakete@gmail.com> | 2018-10-25 20:15:03 +0000 |
commit | 5897428cd24e2deefbcc6f6744c0d7d233aa6747 (patch) | |
tree | 6e50d61fb9d487a5c6bfa3a2d1aaca299c97bcd0 /test/CXX | |
parent | e2c6f9622e58d1cf15204ef6cf26cc3a1c7d50c5 (diff) |
[C++17] Reject shadowing of capture by parameter in lambda
Summary:
This change rejects the shadowing of a capture by a parameter in lambdas in C++17.
```
int main() {
int a;
auto f = [a](int a) { return a; };
}
```
results in:
```
main.cpp:3:20: error: a lambda parameter cannot shadow an explicitly captured entity
auto f = [a](int a) { return a; };
^
main.cpp:3:13: note: variable a is explicitly captured here
auto f = [a](int a) { return a; };
^
```
Reviewers: rsmith
Reviewed By: rsmith
Subscribers: lebedev.ri, erik.pilkington, cfe-commits
Differential Revision: https://reviews.llvm.org/D53595
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345308 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX')
-rw-r--r-- | test/CXX/drs/dr22xx.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/CXX/drs/dr22xx.cpp b/test/CXX/drs/dr22xx.cpp index 021707d876..70a26db757 100644 --- a/test/CXX/drs/dr22xx.cpp +++ b/test/CXX/drs/dr22xx.cpp @@ -15,3 +15,14 @@ struct AnonBitfieldQualifiers { const volatile unsigned i3 : 1; }; } + +#if __cplusplus >= 201103L +namespace dr2211 { // dr2211: 8 +void f() { + int a; + auto f = [a](int a) { (void)a; }; // expected-error {{a lambda parameter cannot shadow an explicitly captured entity}} + // expected-note@-1{{variable 'a' is explicitly captured here}} + auto g = [=](int a) { (void)a; }; +} +} +#endif |