diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/Sema.h | 2 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index da192dd887..4d017cada3 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -3433,7 +3433,7 @@ public: void InstantiatedLocal(const Decl *D, Decl *Inst) { Decl *&Stored = LocalDecls[D]; - assert(!Stored && "Already instantiated this local"); + assert((!Stored || Stored == Inst) && "Already instantiated this local"); Stored = Inst; } }; diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 0f7bae835f..292820b821 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -491,6 +491,9 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) { Owner->addDecl(Enum); Enum->startDefinition(); + if (D->getDeclContext()->isFunctionOrMethod()) + SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Enum); + llvm::SmallVector<Sema::DeclPtrTy, 4> Enumerators; EnumConstantDecl *LastEnumConst = 0; @@ -530,6 +533,12 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) { Enum->addDecl(EnumConst); Enumerators.push_back(Sema::DeclPtrTy::make(EnumConst)); LastEnumConst = EnumConst; + + if (D->getDeclContext()->isFunctionOrMethod()) { + // If the enumeration is within a function or method, record the enum + // constant as a local. + SemaRef.CurrentInstantiationScope->InstantiatedLocal(*EC, EnumConst); + } } } |