Skip to content

Commit 37f7f15

Browse files
hokeintstellar
authored andcommitted
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 (cherry picked from commit 922f339)
1 parent 2a358ba commit 37f7f15

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
@@ -2237,6 +2237,8 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
22372237
if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
22382238
RunSignatureHelp();
22392239
LHS = ExprError();
2240+
} else if (!HasError && HasTrailingComma) {
2241+
Diag(Tok, diag::err_expected_expression);
22402242
} else if (LHS.isInvalid()) {
22412243
for (auto &E : ArgExprs)
22422244
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)