cor3ntin added a comment.

In D124351#4001050 <https://reviews.llvm.org/D124351#4001050>, @eandrews wrote:

> 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?

Yes, this does fix that, thanks for reporting.
Prior to this change, `i` would be looked for in the parent scope which 
explains why capturing it in the inner lambda solves the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124351

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to