[PATCH] D124351: [Clang][WIP] Implement Change scope of lambda trailing-return-type - Take 2

Elizabeth Andrews via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 16 05:04:19 PST 2022


eandrews added a comment.

I came across a strange error when capturing arguments in a lambda inside another lambda. I filed an issue here - https://github.com/llvm/llvm-project/issues/59549

Short reproducer:

  void foo () {
    constexpr int i = 2;
  
    [&]() {
      [=]() [[clang::annotate_type("test", i)]]{};
    };
  }
  
  <source>:5:42: error: variable 'i' cannot be implicitly captured in a lambda with no capture-default specified
      [=]() [[clang::annotate_type("test", i)]]{};
                                           ^
  <source>:2:17: note: 'i' declared here
    constexpr int i = 2;

I noticed the error is not thrown if 'i' is captured in lambda body instead. IIUC all changes pertaining to P2036R3 has been reverted from clang right? So this bug is an existing issue in Clang with how attributes on lambdas are handled? Will this case be fixed in this PR?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124351/new/

https://reviews.llvm.org/D124351



More information about the cfe-commits mailing list