Skip to content

Commit 922f339

Browse files
authored
Diagnose the code with trailing comma in the function call. (llvm#125232)
This patch fixes a regression caused by llvm#114684 where clang accepts trailing commas for function calls. Fixes llvm#125225
1 parent ee76861 commit 922f339

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

clang/lib/Parse/ParseExpr.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,6 +2236,8 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
22362236
if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
22372237
RunSignatureHelp();
22382238
LHS = ExprError();
2239+
} else if (!HasError && HasTrailingComma) {
2240+
Diag(Tok, diag::err_expected_expression);
22392241
} else if (LHS.isInvalid()) {
22402242
for (auto &E : ArgExprs)
22412243
Actions.CorrectDelayedTyposInExpr(E);

clang/test/Parser/recovery.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,10 @@ struct ::template foo, struct ::template bar; // expected-error 2 {{expected ide
215215
struct ::foo struct::; // expected-error {{no struct named 'foo' in the global namespace}} expected-error {{expected identifier}}
216216
class :: : {} a; // expected-error {{expected identifier}} expected-error {{expected class name}}
217217
}
218+
219+
namespace GH125225 {
220+
void func(int);
221+
void k() {
222+
func(1, ); // expected-error {{expected expression}}
223+
}
224+
}

0 commit comments

Comments
 (0)