[clang] Diagnose the code with trailing comma in the function call. (PR #125232)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 31 07:55:15 PST 2025
================
@@ -2237,6 +2237,9 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
RunSignatureHelp();
LHS = ExprError();
+ } else if (!HasError && HasTrailingComma) {
+ // FIXME: add a FIXIT to remove the trailing comma.
+ Diag(Tok, diag::err_extraneous_trailing_comma);
----------------
hokein wrote:
Reused the existing err_expected_expression.
I initially thought that the new `err_extraneous_trailing_comma` provided a clearer message than `err_expected_expression`, but it only applies to a specific test case (the one added in this PR).
For other cases, such as `function2Arg(1, );`, the new diagnostic is incorrect.
https://github.com/llvm/llvm-project/pull/125232
More information about the cfe-commits
mailing list