aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-03-26 00:52:18 +0000
committerAnders Carlsson <andersca@mac.com>2009-03-26 00:52:18 +0000
commit5aeccdbb4bdc94e48c04cacc59fa812af32109b2 (patch)
treea12d78394bc3923a43dea66e6e5054c3bc772a1f /lib/Parse
parent50713450f61b85805e1ca97e547a4082b7798bd3 (diff)
Handle parsing of templates in member declarations. Pass the AccessSpecifier all the way down to ActOnClassTemplate.
Doug, Sebastian: Plz review! :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67723 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse')
-rw-r--r--lib/Parse/ParseDeclCXX.cpp9
-rw-r--r--lib/Parse/ParseTemplate.cpp5
-rw-r--r--lib/Parse/Parser.cpp5
3 files changed, 13 insertions, 6 deletions
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
index 1bbf411874..61182ef9cd 100644
--- a/lib/Parse/ParseDeclCXX.cpp
+++ b/lib/Parse/ParseDeclCXX.cpp
@@ -460,7 +460,8 @@ void Parser::ParseClassSpecifier(DeclSpec &DS,
Attr,
Action::MultiTemplateParamsArg(Actions,
&(*TemplateParams)[0],
- TemplateParams->size()));
+ TemplateParams->size()),
+ AS);
else
TagOrTempResult = Actions.ActOnTag(CurScope, TagType, TK, StartLoc, SS, Name,
NameLoc, Attr, AS);
@@ -615,7 +616,7 @@ AccessSpecifier Parser::getAccessSpecifierIfPresent() const
/// ::[opt] nested-name-specifier template[opt] unqualified-id ';'[TODO]
/// using-declaration [TODO]
/// [C++0x] static_assert-declaration
-/// template-declaration [TODO]
+/// template-declaration
/// [GNU] '__extension__' member-declaration
///
/// member-declarator-list:
@@ -638,6 +639,10 @@ Parser::DeclTy *Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS) {
if (Tok.is(tok::kw_static_assert))
return ParseStaticAssertDeclaration();
+ if (Tok.is(tok::kw_template))
+ return ParseTemplateDeclarationOrSpecialization(Declarator::MemberContext,
+ AS);
+
// Handle: member-declaration ::= '__extension__' member-declaration
if (Tok.is(tok::kw___extension__)) {
// __extension__ silences extension warnings in the subexpression.
diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp
index 2aeb182dbd..2c07823aba 100644
--- a/lib/Parse/ParseTemplate.cpp
+++ b/lib/Parse/ParseTemplate.cpp
@@ -35,7 +35,8 @@ using namespace clang;
/// explicit-specialization: [ C++ temp.expl.spec]
/// 'template' '<' '>' declaration
Parser::DeclTy *
-Parser::ParseTemplateDeclarationOrSpecialization(unsigned Context) {
+Parser::ParseTemplateDeclarationOrSpecialization(unsigned Context,
+ AccessSpecifier AS) {
assert((Tok.is(tok::kw_export) || Tok.is(tok::kw_template)) &&
"Token does not start a template declaration.");
@@ -94,7 +95,7 @@ Parser::ParseTemplateDeclarationOrSpecialization(unsigned Context) {
} while (Tok.is(tok::kw_export) || Tok.is(tok::kw_template));
// Parse the actual template declaration.
- return ParseDeclarationOrFunctionDefinition(&ParamLists);
+ return ParseDeclarationOrFunctionDefinition(&ParamLists, AS);
}
/// ParseTemplateParameters - Parses a template-parameter-list enclosed in
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index 135faf4e9c..7a221d007c 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -442,10 +442,11 @@ Parser::DeclTy *Parser::ParseExternalDeclaration() {
///
Parser::DeclTy *
Parser::ParseDeclarationOrFunctionDefinition(
- TemplateParameterLists *TemplateParams) {
+ TemplateParameterLists *TemplateParams,
+ AccessSpecifier AS) {
// Parse the common declaration-specifiers piece.
DeclSpec DS;
- ParseDeclarationSpecifiers(DS, TemplateParams);
+ ParseDeclarationSpecifiers(DS, TemplateParams, AS);
// C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
// declaration-specifiers init-declarator-list[opt] ';'