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

via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 8 06:18:03 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Qizhi Hu (jcsxky)

<details>
<summary>Changes</summary>



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


1 Files Affected:

- (modified) clang/lib/Parse/ParseDecl.cpp (+6-1) 


``````````diff
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 ')'.

``````````

</details>


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


More information about the cfe-commits mailing list