================
@@ -2697,6 +2697,14 @@ void 
ASTDeclReader::VisitVarTemplatePartialSpecializationDecl(
 
   RedeclarableResult Redecl = VisitVarTemplateSpecializationDeclImpl(D);
 
+  // A partial specialization whose primary template is invalid cannot be
+  // instantiated. Mark it invalid too so InstantiateClass skips it, the same
+  // way it already skips the invalid primary, instead of later looking for an
+  // instantiated primary that was never created.
+  if (VarTemplateDecl *Primary = D->getSpecializedTemplate();
+      Primary && Primary->isInvalidDecl())
+    D->setInvalidDecl();
----------------
TPPPP72 wrote:

I have a question: if your premise holds, why is a PCH specifically required to 
trigger this crash? Theoretically, having a `.cpp` file include a non-existent 
file should also cause a fatal error. Since the compiler normally wouldn't 
perform an invalid template instantiation, shouldn't the issue lie in the 
deserialization process—where, for some reason, an "invalid" flag was lost, 
thereby bypassing the check that would have caught the invalid template 
instantiation?

https://github.com/llvm/llvm-project/pull/202958
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to