forked from OSchip/llvm-project
Handle parsing of templates in member declarations. Pass the AccessSpecifier all the way down to ActOnClassTemplate.
Doug, Sebastian: Plz review! :) llvm-svn: 67723
This commit is contained in:
parent
2ed6ceba1d
commit
dfbbdf6fd5
|
@ -1175,7 +1175,8 @@ public:
|
|||
SourceLocation KWLoc, const CXXScopeSpec &SS,
|
||||
IdentifierInfo *Name, SourceLocation NameLoc,
|
||||
AttributeList *Attr,
|
||||
MultiTemplateParamsArg TemplateParameterLists) {
|
||||
MultiTemplateParamsArg TemplateParameterLists,
|
||||
AccessSpecifier AS) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -549,7 +549,9 @@ private:
|
|||
// C99 6.9: External Definitions.
|
||||
DeclTy *ParseExternalDeclaration();
|
||||
DeclTy *ParseDeclarationOrFunctionDefinition(
|
||||
TemplateParameterLists *TemplateParams = 0);
|
||||
TemplateParameterLists *TemplateParams = 0,
|
||||
AccessSpecifier AS = AS_none);
|
||||
|
||||
DeclTy *ParseFunctionDefinition(Declarator &D);
|
||||
void ParseKNRParamDeclarations(Declarator &D);
|
||||
// EndLoc, if non-NULL, is filled with the location of the last token of
|
||||
|
@ -1027,7 +1029,8 @@ private:
|
|||
typedef llvm::SmallVector<DeclTy *, 4> TemplateParameterList;
|
||||
|
||||
// C++ 14.1: Template Parameters [temp.param]
|
||||
DeclTy *ParseTemplateDeclarationOrSpecialization(unsigned Context);
|
||||
DeclTy *ParseTemplateDeclarationOrSpecialization(unsigned Context,
|
||||
AccessSpecifier AS=AS_none);
|
||||
bool ParseTemplateParameters(unsigned Depth,
|
||||
TemplateParameterList &TemplateParams,
|
||||
SourceLocation &LAngleLoc,
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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] ';'
|
||||
|
|
|
@ -1715,7 +1715,8 @@ public:
|
|||
SourceLocation KWLoc, const CXXScopeSpec &SS,
|
||||
IdentifierInfo *Name, SourceLocation NameLoc,
|
||||
AttributeList *Attr,
|
||||
MultiTemplateParamsArg TemplateParameterLists);
|
||||
MultiTemplateParamsArg TemplateParameterLists,
|
||||
AccessSpecifier AS);
|
||||
|
||||
QualType CheckClassTemplateId(ClassTemplateDecl *ClassTemplate,
|
||||
SourceLocation TemplateLoc,
|
||||
|
|
|
@ -388,7 +388,8 @@ Sema::ActOnClassTemplate(Scope *S, unsigned TagSpec, TagKind TK,
|
|||
SourceLocation KWLoc, const CXXScopeSpec &SS,
|
||||
IdentifierInfo *Name, SourceLocation NameLoc,
|
||||
AttributeList *Attr,
|
||||
MultiTemplateParamsArg TemplateParameterLists) {
|
||||
MultiTemplateParamsArg TemplateParameterLists,
|
||||
AccessSpecifier AS) {
|
||||
assert(TemplateParameterLists.size() > 0 && "No template parameter lists?");
|
||||
assert(TK != TK_Reference && "Can only declare or define class templates");
|
||||
bool Invalid = false;
|
||||
|
|
Loading…
Reference in New Issue