HomePhabricator

[C++17] Reject shadowing of capture by parameter in lambda

Description

[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

Details

Committed
Rakete1111Oct 25 2018, 1:15 PM
Reviewer
rsmith
Differential Revision
D53595: [C++17] Reject shadowing of capture by parameter in lambda
Branches
Unknown
Tags
Unknown