royjacobson added inline comments.
================ Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1037-1041 +def err_static_mutable_lambda : Error< + "lambda cannot be both mutable and static">; +def err_static_lambda_captures : Error< + "a static lambda cannot have any captures">; +def note_lambda_captures : Note<"captures declared here">; ---------------- aaron.ballman wrote: > These are semantic errors, not parsing ones. This means these will be > diagnosed when parsing the lambda rather than when instantiating it. I don't > think that matters for the cast of combining `mutable` and `static`, but I'm > less certain about "have any captures" because of cases like: > ``` > template <typename... Types> > auto func(Types... Ts) { > return [Ts...] { return 1; }; > } > > int main() { > auto lambda = func(); > } > ``` > I'm pretty sure that lambda has no captures for that call, but it could have > captures depending on the instantiation. > > Actually, from some off-list discussion with @erichkeane, even mutable and > static are a problem in code like: > ``` > template <typename Ty> > void func(T t) { > if constexpr (Something<T>) { > [](){}; > } else { > [t](){}; > } > ``` > where the lambda is in a discarded statement. > > So I think these might need to change to be Sema diagnostics (and we should > add some additional test coverage). From https://eel.is/c++draft/expr.prim.lambda.general#4 > If the lambda-specifier-seq contains static, there shall be no lambda-capture So this should be a parsing error. Or maybe I don't understand what you're saying. There are no static lambdas in your examples so I'm not sure how they're related. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D133659/new/ https://reviews.llvm.org/D133659 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits