From: David Majnemer Date: Fri, 30 Jan 2015 05:01:23 +0000 (+0000) Subject: Sema: Disable template instantiation once a fatal error is raised X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=28700a79398a9c385401cc869506fb83a82b7cf2;p=clang Sema: Disable template instantiation once a fatal error is raised Fatal errors disable all further diagnostics. Continuing to permit template instantiation does nothing but make it take longer for clang to finish with the TU. Instead, halt all further instantiation. Fixed in PR22396. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227556 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index 6ac7175cf3..ed0d5a54e8 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -207,6 +207,12 @@ void Sema::InstantiatingTemplate::Initialize( sema::TemplateDeductionInfo *DeductionInfo) { SavedInNonInstantiationSFINAEContext = SemaRef.InNonInstantiationSFINAEContext; + // Don't allow further instantiation if a fatal error has occcured. Any + // diagnostics we might have raised will not be visible. + if (SemaRef.Diags.hasFatalErrorOccurred()) { + Invalid = true; + return; + } Invalid = CheckInstantiationDepth(PointOfInstantiation, InstantiationRange); if (!Invalid) { ActiveTemplateInstantiation Inst;