[clang] [clang] pop explicit to keep context stack balance (PR #77312)

Qizhi Hu via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 8 06:17:33 PST 2024


https://github.com/jcsxky created https://github.com/llvm/llvm-project/pull/77312

None

>From d0a51d88d54420570bfa351e8ca70777ea15e4b7 Mon Sep 17 00:00:00 2001
From: huqizhi <huqizhi at feysh.com>
Date: Mon, 8 Jan 2024 22:15:09 +0800
Subject: [PATCH] [clang] pop explicit to keep context stack balance

---
 clang/lib/Parse/ParseDecl.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index b60ae293ef8c20..9418ee305171c8 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -2637,7 +2637,7 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
     T.consumeOpen();
 
     ExprVector Exprs;
-
+    bool ValidBefore = !ThisDecl->isInvalidDecl();
     InitializerScopeRAII InitScope(*this, D, ThisDecl);
 
     auto ThisVarDecl = dyn_cast_or_null<VarDecl>(ThisDecl);
@@ -2670,6 +2670,11 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
         CalledSignatureHelp = true;
       }
       Actions.ActOnInitializerError(ThisDecl);
+      if (ValidBefore && ThisDecl->isInvalidDecl()) {
+        ThisDecl->setInvalidDecl(false);
+        InitScope.pop();
+        ThisDecl->setInvalidDecl();
+      }
       SkipUntil(tok::r_paren, StopAtSemi);
     } else {
       // Match the ')'.



More information about the cfe-commits mailing list