sammccall added a comment. This approach isn't the most obvious one, to me. In the test, the lambda is invalid with `auto` return type, where it seems that valid with `int` return type and a body that contains-errors would be better.
I'm guessing this comes down to what fits most naturally in the implementation? (If you skip return statements with broken types, you need to distinguish between void lambdas and broken ones somehow). Anyway, this decision/motivation probably also deserves a comment. ================ Comment at: clang/lib/Sema/SemaStmt.cpp:3306 StmtResult Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { // If this is the first return we've seen, infer the return type. ---------------- This seems to only handle lambdas (and blocks). Is there a corresponding fix needed for C++14 `auto x() { ... }` ? ================ Comment at: clang/lib/Sema/SemaStmt.cpp:3331 + FunctionDecl *FD = CurLambda->CallOperator; + if (FD->isInvalidDecl()) + return StmtError(); ---------------- This deserves a comment, like: ``` // If we've already decided this lambda is invalid, e.g. because // we saw a `return` whose expression had an error, don't keep // trying to deduce its return type. ``` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D92211/new/ https://reviews.llvm.org/D92211 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits