[PATCH] D36915: [Sema] Diagnose local variables and parameters captured by lambda and block expressions in a default argument

Faisal Vali via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 22 18:22:32 PDT 2017


faisalv added a comment.

I don't think this approach is entirely correct for at least the following reasons:

1. in the lambda case the machinery that diagnoses capture failures should be the machinery erroring on the lambda (when the parameter is odr-used)
2. in the unevaluated case, once you disable the error, the instantiation machinery will fail to find the corresponding instantiated parmvardecl.

I think - in addition to allowing unevaluated uses of parmvardecls by tweaking the DefaultArgumentChecker, you would also need to add the instantiated mappings of the parameters, prior to instantiating the default argument (to avoid the assertion) and perhaps need to tweak DoMarkVarDeclReferenced and/or tryCaptureVariable to make sure such cases for lambdas produce errors (if they don't, w the above fix).

Thanks for working on this!


https://reviews.llvm.org/D36915





More information about the cfe-commits mailing list