[PATCH] D119609: [Clang][Sema] Don't act on ReturnStmt when parsing the lambda declarator.
Erich Keane via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 7 07:50:24 PST 2022
erichkeane added inline comments.
================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:4366
+def err_expr_statement_in_default_arg : Error<
+ "can't use expression statement in default argument">;
----------------
I'm not a fan of this text here(for 1, contractions aren't permitted I think), but I suspect Aaron is the best one to bikeshed. Until then, I might suggest something like:
"expression statement not permitted in default argument".
================
Comment at: clang/lib/Parse/ParseDecl.cpp:7092
+ Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);
+ SkipUntil(tok::comma, tok::r_paren, StopAtSemi | StopBeforeMatch);
+ return;
----------------
Can we have a test to make sure this properly captures everything/doesn't get confused with parens/braces inside the expression statement?
================
Comment at: clang/test/Sema/err-expr-stmt-in-default-arg.cpp:19
+ return bar(l);
+}
----------------
For completeness, I'd like to see an in-function-defined-struct-member-function test here as well.
As for the above question about the recovery, something like:
`void fn(int i, int j = ({ {},{},{,} }), int k = "");` I think checks all the issues I can think of. We want to make sure that 'k' still diagnoses its error correctly (and that we have just skipped all of the expression statement stuff).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119609/new/
https://reviews.llvm.org/D119609
More information about the cfe-commits
mailing list