]> granicus.if.org Git - clang/commitdiff
Fix the parser's updating of the template depth when parsing local templates and...
authorFaisal Vali <faisalv@yahoo.com>
Sat, 8 Jun 2013 19:47:52 +0000 (19:47 +0000)
committerFaisal Vali <faisalv@yahoo.com>
Sat, 8 Jun 2013 19:47:52 +0000 (19:47 +0000)
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
test/SemaTemplate/local-member-templates.cpp

index 84b7df7295f669e36b4e759870225dec4c63defe..f55fcc074045123892d90cec9bec9b02fe1c8ce0 100644 (file)
@@ -1263,12 +1263,14 @@ void Parser::ParseLateTemplatedFuncDef(LateParsedTemplatedFunction &LMT) {
       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);
index 3cdf5df8d143c63ef54fcde55a0fd4954285309d..847d483a002112781da2ae8ebe17934bd27ad343 100644 (file)
@@ -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