aaron.ballman added inline comments.

================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:162
+    // Init captures are always VarDecl.
+    auto *D = cast<VarDecl>(LC.getCapturedVar());
+    Invalid |= Visit(D->getInit());
----------------
aaron.ballman wrote:
> Can you add a test case showing what happens with structured bindings? e.g.,
> ```
> int array[] = { 1, 2 };
> auto [a, b] = array; 
> 
> void func(int c = [x = a] { return x; }());
> ```
> Note, I think Clang has a bug here so you might have to write the test with a 
> FIXME comment. (I don't think we implement https://wg21.link/cwg2358 or 
> http://eel.is/c++draft/expr.prim.lambda#capture-3 properly yet.)
> 
> The part that worries me there specifically is that a `BindingDecl` is a 
> `ValueDecl` and not a `VarDecl`, so I think that `cast<>` may assert in this 
> case.
*sigh* this is implementing CWG2358...

So no FIXME comment, I think we should add a test to demonstrate that this 
works.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137172

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

Reply via email to