From a8cab015e5f2750cb6f15e71016569739c2ad1e3 Mon Sep 17 00:00:00 2001 From: John McCall Date: Wed, 17 Mar 2010 19:25:57 +0000 Subject: [PATCH] ActOnTagDefinitionError is supposed to 'unwind' ActOnTagStartDefinition, not ActOnStartCXXMemberDeclaration. We haven't started the field collector on this class yet, so don't stop it. Fixes a crash in the VS buildbot and a memory error on all the others. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98760 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/CXXFieldCollector.h | 5 ++++- lib/Sema/SemaDecl.cpp | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Sema/CXXFieldCollector.h b/lib/Sema/CXXFieldCollector.h index 69d13515fa..63c6ee3f74 100644 --- a/lib/Sema/CXXFieldCollector.h +++ b/lib/Sema/CXXFieldCollector.h @@ -58,7 +58,10 @@ public: } /// getCurNumField - The number of fields added to the currently parsed class. - size_t getCurNumFields() const { return FieldCount.back(); } + size_t getCurNumFields() const { + assert(!FieldCount.empty() && "no currently-parsed class"); + return FieldCount.back(); + } /// getCurFields - Pointer to array of fields added to the currently parsed /// class. diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index d562a52694..19885ba9cf 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -5113,11 +5113,11 @@ void Sema::ActOnTagFinishDefinition(Scope *S, DeclPtrTy TagD, void Sema::ActOnTagDefinitionError(Scope *S, DeclPtrTy TagD) { AdjustDeclIfTemplate(TagD); TagDecl *Tag = cast(TagD.getAs()); - Tag->setInvalidDecl(); - if (isa(Tag)) - FieldCollector->FinishClass(); + // We're undoing ActOnTagStartDefinition here, not + // ActOnStartCXXMemberDeclarations, so we don't have to mess with + // the FieldCollector. PopDeclContext(); } -- 2.40.0