[cfe-commits] r67723 - in /cfe/trunk: include/clang/Parse/Action.h include/clang/Parse/Parser.h lib/Parse/ParseDeclCXX.cpp lib/Parse/ParseTemplate.cpp lib/Parse/Parser.cpp lib/Sema/Sema.h lib/Sema/SemaTemplate.cpp

Anders Carlsson andersca at mac.com
Wed Mar 25 17:52:19 PDT 2009


Author: andersca
Date: Wed Mar 25 19:52:18 2009
New Revision: 67723

URL: http://llvm.org/viewvc/llvm-project?rev=67723&view=rev
Log:
Handle parsing of templates in member declarations. Pass the AccessSpecifier all the way down to ActOnClassTemplate.

Doug, Sebastian: Plz review! :)


Modified:
    cfe/trunk/include/clang/Parse/Action.h
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/lib/Parse/ParseTemplate.cpp
    cfe/trunk/lib/Parse/Parser.cpp
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=67723&r1=67722&r2=67723&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Wed Mar 25 19:52:18 2009
@@ -1175,7 +1175,8 @@
                      SourceLocation KWLoc, const CXXScopeSpec &SS,
                      IdentifierInfo *Name, SourceLocation NameLoc,
                      AttributeList *Attr,
-                     MultiTemplateParamsArg TemplateParameterLists) {
+                     MultiTemplateParamsArg TemplateParameterLists,
+                     AccessSpecifier AS) {
     return 0;
   }
 

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=67723&r1=67722&r2=67723&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 25 19:52:18 2009
@@ -549,7 +549,9 @@
   // 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 @@
   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, 

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=67723&r1=67722&r2=67723&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Wed Mar 25 19:52:18 2009
@@ -460,7 +460,8 @@
                                                  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 @@
 ///         ::[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 @@
   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.

Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=67723&r1=67722&r2=67723&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Wed Mar 25 19:52:18 2009
@@ -35,7 +35,8 @@
 ///       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 @@
   } 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

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=67723&r1=67722&r2=67723&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Wed Mar 25 19:52:18 2009
@@ -442,10 +442,11 @@
 ///
 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] ';'

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=67723&r1=67722&r2=67723&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Mar 25 19:52:18 2009
@@ -1715,7 +1715,8 @@
                      SourceLocation KWLoc, const CXXScopeSpec &SS,
                      IdentifierInfo *Name, SourceLocation NameLoc,
                      AttributeList *Attr,
-                     MultiTemplateParamsArg TemplateParameterLists);
+                     MultiTemplateParamsArg TemplateParameterLists,
+                     AccessSpecifier AS);
 
   QualType CheckClassTemplateId(ClassTemplateDecl *ClassTemplate,
                                 SourceLocation TemplateLoc,

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=67723&r1=67722&r2=67723&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Mar 25 19:52:18 2009
@@ -388,7 +388,8 @@
                          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;





More information about the cfe-commits mailing list