Skip to content

Conversation

@llvmbot
Copy link
Member

@llvmbot llvmbot commented Feb 14, 2025

Backport 922f339

Requested by: @hokein

@llvmbot llvmbot added this to the LLVM 20.X Release milestone Feb 14, 2025
@llvmbot
Copy link
Member Author

llvmbot commented Feb 14, 2025

@a-tarasyuk What do you think about merging this PR to the release branch?

@llvmbot llvmbot requested a review from a-tarasyuk February 14, 2025 15:32
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Feb 14, 2025
@llvmbot
Copy link
Member Author

llvmbot commented Feb 14, 2025

@llvm/pr-subscribers-clang

Author: None (llvmbot)

Changes

Backport 922f339

Requested by: @hokein


Full diff: https://github.com/llvm/llvm-project/pull/127215.diff

2 Files Affected:

  • (modified) clang/lib/Parse/ParseExpr.cpp (+2)
  • (modified) clang/test/Parser/recovery.cpp (+7)
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}}
+}
+}

)

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)
@tstellar tstellar merged commit 37f7f15 into llvm:release/20.x Feb 14, 2025
8 of 11 checks passed
@github-actions
Copy link

@hokein (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

Development

Successfully merging this pull request may close these issues.

4 participants