[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 19:37:20 PST 2024
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/77312
>From f3671079bb27100dd77f9572a20445285c6850dd 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 | 1 +
.../cxx-static-member-init-no-crash.cpp | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
create mode 100644 clang/test/Parser/cxx-static-member-init-no-crash.cpp
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index b60ae293ef8c20..6b16320f86721b 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -2669,6 +2669,7 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
/*Braced=*/false);
CalledSignatureHelp = true;
}
+ InitScope.pop();
Actions.ActOnInitializerError(ThisDecl);
SkipUntil(tok::r_paren, StopAtSemi);
} else {
diff --git a/clang/test/Parser/cxx-static-member-init-no-crash.cpp b/clang/test/Parser/cxx-static-member-init-no-crash.cpp
new file mode 100644
index 00000000000000..304f2ce7550e4b
--- /dev/null
+++ b/clang/test/Parser/cxx-static-member-init-no-crash.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+template <typename T, typename Base> class EngineClassTypeInfo;
+template <typename T> struct _ConcreteClassBase {};
+
+struct _GLOBALSCOPE {};
+template <typename T = _GLOBALSCOPE> struct _SCOPE {};
+
+class Zone {
+private:
+ typedef _ConcreteClassBase<Zone> _ClassBase;
+ static EngineClassTypeInfo<Zone, _ClassBase> _smTypeInfo;
+ static EngineExportScope &__engineExportScope();
+};
+
+EngineClassTypeInfo<Zone, Zone::_ClassBase>
+ Zone::_smTypeInfo("Zone", &_SCOPE<__DeclScope>()(), 0);
+EngineExportScope &Zone::__engineExportScope() { return Zone::_smTypeInfo; }
More information about the cfe-commits
mailing list