r183620 - Fix the parser's updating of the template depth when parsing local templates and late-parsed templates.
Faisal Vali
faisalv at yahoo.com
Sat Jun 8 12:47:53 PDT 2013
Author: faisalv
Date: Sat Jun 8 14:47:52 2013
New Revision: 183620
URL: http://llvm.org/viewvc/llvm-project?rev=183620&view=rev
Log:
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)
Modified:
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/test/SemaTemplate/local-member-templates.cpp
Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=183620&r1=183619&r2=183620&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Sat Jun 8 14:47:52 2013
@@ -1263,12 +1263,14 @@ void Parser::ParseLateTemplatedFuncDef(L
Actions.ActOnReenterTemplateScope(getCurScope(), MD);
++CurTemplateDepthTracker;
} else if (CXXRecordDecl *MD = dyn_cast_or_null<CXXRecordDecl>(*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);
Modified: cfe/trunk/test/SemaTemplate/local-member-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/local-member-templates.cpp?rev=183620&r1=183619&r2=183620&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/local-member-templates.cpp (original)
+++ cfe/trunk/test/SemaTemplate/local-member-templates.cpp Sat Jun 8 14:47:52 2013
@@ -74,3 +74,26 @@ template void
Outer<int>::outer_mem(int, char); //expected-note{{in instantiation of}}
}
+
+namespace more_nested_local_templates {
+
+int test() {
+ struct Local {
+ template<class U> void foo(U u) {
+ struct Inner {
+ template<class A>
+ 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
More information about the cfe-commits
mailing list