From 688f9866c7d35725c947b080fb17055446912390 Mon Sep 17 00:00:00 2001 From: Faisal Vali Date: Sat, 8 Jun 2013 19:47:52 +0000 Subject: [PATCH] Fix the parser's updating of the template depth when parsing local templates and late-parsed templates. This is a slight tweak of r180708; It avoids incrementing depth when non-template local classes nested within member templates of local classes are encountered. This patch was LGTM'd by Doug http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130506/079656.html and passed the regression tests that normally pass (i.e. excluding many Module and Index tests on Windows that fail regardless) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183620 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseTemplate.cpp | 8 ++++--- test/SemaTemplate/local-member-templates.cpp | 23 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp index 84b7df7295..f55fcc0740 100644 --- a/lib/Parse/ParseTemplate.cpp +++ b/lib/Parse/ParseTemplate.cpp @@ -1263,12 +1263,14 @@ void Parser::ParseLateTemplatedFuncDef(LateParsedTemplatedFunction &LMT) { Actions.ActOnReenterTemplateScope(getCurScope(), MD); ++CurTemplateDepthTracker; } else if (CXXRecordDecl *MD = dyn_cast_or_null(*II)) { - bool ManageScope = MD->getDescribedClassTemplate() != 0; + bool IsClassTemplate = MD->getDescribedClassTemplate() != 0; TemplateParamScopeStack.push_back( - new ParseScope(this, Scope::TemplateParamScope, ManageScope)); + new ParseScope(this, Scope::TemplateParamScope, + /*ManageScope*/IsClassTemplate)); Actions.ActOnReenterTemplateScope(getCurScope(), MD->getDescribedClassTemplate()); - ++CurTemplateDepthTracker; + if (IsClassTemplate) + ++CurTemplateDepthTracker; } TemplateParamScopeStack.push_back(new ParseScope(this, Scope::DeclScope)); Actions.PushDeclContext(Actions.getCurScope(), *II); diff --git a/test/SemaTemplate/local-member-templates.cpp b/test/SemaTemplate/local-member-templates.cpp index 3cdf5df8d1..847d483a00 100644 --- a/test/SemaTemplate/local-member-templates.cpp +++ b/test/SemaTemplate/local-member-templates.cpp @@ -74,3 +74,26 @@ template void Outer::outer_mem(int, char); //expected-note{{in instantiation of}} } + +namespace more_nested_local_templates { + +int test() { + struct Local { + template void foo(U u) { + struct Inner { + template + auto operator()(A a, U u2) -> U { + return u2; + }; + }; + Inner GL; + GL('a', u ); + GL(3.14, u ); + } + }; + Local l; + l.foo("nmabc"); + return 0; +} +int t = test(); +} \ No newline at end of file -- 2.40.0