diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index aa8b3870a188c..0cadede51a9b3 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -2237,6 +2237,8 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { if (PP.isCodeCompletionReached() && !CalledSignatureHelp) RunSignatureHelp(); LHS = ExprError(); + } else if (!HasError && HasTrailingComma) { + Diag(Tok, diag::err_expected_expression); } else if (LHS.isInvalid()) { for (auto &E : ArgExprs) Actions.CorrectDelayedTyposInExpr(E); diff --git a/clang/test/Parser/recovery.cpp b/clang/test/Parser/recovery.cpp index 4e2811c4cac92..2fce67a52c6b6 100644 --- a/clang/test/Parser/recovery.cpp +++ b/clang/test/Parser/recovery.cpp @@ -215,3 +215,10 @@ struct ::template foo, struct ::template bar; // expected-error 2 {{expected ide struct ::foo struct::; // expected-error {{no struct named 'foo' in the global namespace}} expected-error {{expected identifier}} class :: : {} a; // expected-error {{expected identifier}} expected-error {{expected class name}} } + +namespace GH125225 { +void func(int); +void k() { + func(1, ); // expected-error {{expected expression}} +} +}