[clang] [Clang] Fixed a crash when instantiating an invalid out-of-line static data member definition in a local class (PR #196772)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Sun May 10 01:12:03 PDT 2026
================
@@ -1799,6 +1799,14 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D,
if (SemaRef.getLangOpts().OpenCL)
SemaRef.deduceOpenCLAddressSpace(Var);
+ if (D->getQualifierLoc()) {
+ if (D->getLexicalDeclContext()->isDependentContext() &&
+ DC->isFunctionOrMethod()) {
+ Var->setInvalidDecl();
+ return nullptr;
+ }
+ }
+
----------------
zyn0217 wrote:
Why do we have to put it in the instantiator? We don't need an instantiated Var before we can tell if its valid.
https://github.com/llvm/llvm-project/pull/196772
More information about the cfe-commits
mailing list