aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseCXXInlineMethods.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-08-22 00:34:47 +0000
committerDouglas Gregor <dgregor@apple.com>2009-08-22 00:34:47 +0000
commitd83d04041f64a2c89123d227fa8003b482391279 (patch)
treecff3c814385b448dfc048774b1ba787dfd188f0b /lib/Parse/ParseCXXInlineMethods.cpp
parentc141086bff9c2809aa46efdc5ce66756430f3470 (diff)
Implement delayed parsing for member function templates. Fixes PR4608.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79709 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseCXXInlineMethods.cpp')
-rw-r--r--lib/Parse/ParseCXXInlineMethods.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/Parse/ParseCXXInlineMethods.cpp b/lib/Parse/ParseCXXInlineMethods.cpp
index 80feff42d7..f967c7a69d 100644
--- a/lib/Parse/ParseCXXInlineMethods.cpp
+++ b/lib/Parse/ParseCXXInlineMethods.cpp
@@ -44,6 +44,8 @@ Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, Declarator &D,
// Consume the tokens and store them for later parsing.
getCurrentClass().MethodDefs.push_back(LexedMethod(FnD));
+ getCurrentClass().MethodDefs.back().TemplateScope
+ = CurScope->isTemplateParamScope();
CachedTokens &Toks = getCurrentClass().MethodDefs.back().Toks;
tok::TokenKind kind = Tok.getKind();
@@ -99,9 +101,11 @@ void Parser::ParseLexedMethodDeclarations(ParsingClass &Class) {
for (; !Class.MethodDecls.empty(); Class.MethodDecls.pop_front()) {
LateParsedMethodDeclaration &LM = Class.MethodDecls.front();
- // FIXME: For member function templates, we'll need to introduce a
- // scope for the template parameters.
-
+ // If this is a member template, introduce the template parameter scope.
+ ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
+ if (LM.TemplateScope)
+ Actions.ActOnReenterTemplateScope(CurScope, LM.Method);
+
// Start the delayed C++ method declaration
Actions.ActOnStartDelayedCXXMethodDeclaration(CurScope, LM.Method);
@@ -161,6 +165,11 @@ void Parser::ParseLexedMethodDefs(ParsingClass &Class) {
for (; !Class.MethodDefs.empty(); Class.MethodDefs.pop_front()) {
LexedMethod &LM = Class.MethodDefs.front();
+ // If this is a member template, introduce the template parameter scope.
+ ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
+ if (LM.TemplateScope)
+ Actions.ActOnReenterTemplateScope(CurScope, LM.D);
+
assert(!LM.Toks.empty() && "Empty body!");
// Append the current token at the end of the new token stream so that it
// doesn't get lost.