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

Nicolas Lesser via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 23 11:32:20 PDT 2018


Rakete1111 created this revision.
Rakete1111 added a reviewer: rsmith.

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; };
              ^


Repository:
  rC Clang

https://reviews.llvm.org/D53595

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaLambda.cpp
  test/SemaCXX/warn-shadow-in-lambdas.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53595.170710.patch
Type: text/x-patch
Size: 6395 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181023/722161f5/attachment.bin>


More information about the cfe-commits mailing list