[clang] [clang] reject to capture variable in `RequiresExprBodyDecl` (PR #78598)

Congcong Cai via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 19 22:01:59 PST 2024


HerrCai0907 wrote:

> Thanks for the patch!
> 
> Requires Expressions should be in an unevaluated context, so we should never try to capture variables they mentioned.
> 
> Maybe we need to test the evaluation context in either `tryCaptureVariable` or `NeedToCaptureVariable`, rather than a specific handling for requires expressions
> 
> https://eel.is/c++draft/expr.prim.lambda.capture#7.sentence-2
> 
> WDYT?
> 
> @erichkeane

We will use `tryCaptureVariable` to diagnose `-Wunused-lambda-capture`. So simply ignoring them in an unevaluated context is not a good idea. I have changed the PR to match this function work even for `RequiresExprBodyDecl`.

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


More information about the cfe-commits mailing list