[clang] [Clang] [Sema] Don't crash on unexpanded pack in invalid block literal (PR #110762)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 3 13:36:47 PDT 2024


cor3ntin wrote:

> Side note: lambdas don’t suffer from this problem because they push a new LambdaScopeInfo, so if the lambda is discarded, the ‘enclosing lambda’ (which is just that very same lambda) is discarded along with it. I’m not sure making blocks work the same way would work (i.e. allowing unexpanded parameter packs if there is an enclosing lambda or block, but I’m assuming there is a reason why we don’t support that...), because currently, e.g. this doesn’t work at all:

I am not sure i understand that.

Imo the issue is that `DiagnoseUnexpandedParameterPacks` (where we set `LambdaScopeInfo::ContainsUnexpandedParameterPack` does not account for blocks - and probably should.

Ideally
 - DiagnoseUnexpandedParameterPacks would handle arbitrary capturing-scope thingies (statement expressions, lambdas, blocks, eventually do expressions, and other terrifying such constructs)
 - Once the innermost such construct is fully constructed, the `ContainsUnexpandedParameterPack` flag could bubble upward to the enclosing capturing scope



https://github.com/llvm/llvm-project/pull/110762


More information about the cfe-commits mailing list