diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-07-22 17:18:37 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-07-22 17:18:37 +0000 |
commit | dfe3f2d8ba49f03d01f42570e640d9a6755e6c08 (patch) | |
tree | 835a53a7b1cfa1edc7f881dc7b9553c4a6a6258c /lib/Sema/SemaDecl.cpp | |
parent | 9533a7fdb8397421f3be52e879442460a87389f6 (diff) |
Implement parsing and semantic analysis for out-of-line definitions of static
data members of class templates. We don't instantiate the definitions yet,
however.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76756 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 283033bd7c..beceeef54d 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1520,7 +1520,9 @@ Sema::HandleDeclarator(Scope *S, Declarator &D, move(TemplateParamLists), IsFunctionDefinition, Redeclaration); } else { - New = ActOnVariableDeclarator(S, D, DC, R, PrevDecl, Redeclaration); + New = ActOnVariableDeclarator(S, D, DC, R, PrevDecl, + move(TemplateParamLists), + Redeclaration); } if (New == 0) @@ -1772,6 +1774,7 @@ isOutOfScopePreviousDeclaration(NamedDecl *PrevDecl, DeclContext *DC, NamedDecl* Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, QualType R,NamedDecl* PrevDecl, + MultiTemplateParamsArg TemplateParamLists, bool &Redeclaration) { DeclarationName Name = GetNameForDeclarator(D); @@ -1840,7 +1843,36 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, } } - + // Check that we can declare a template here. + if (TemplateParamLists.size() && + CheckTemplateDeclScope(S, TemplateParamLists)) + return 0; + + // Match up the template parameter lists with the scope specifier, then + // determine whether we have a template or a template specialization. + if (TemplateParameterList *TemplateParams + = MatchTemplateParametersToScopeSpecifier( + D.getDeclSpec().getSourceRange().getBegin(), + D.getCXXScopeSpec(), + (TemplateParameterList**)TemplateParamLists.release(), + TemplateParamLists.size())) { + if (TemplateParams->size() > 0) { + // There is no such thing as a variable template. + Diag(D.getIdentifierLoc(), diag::err_template_variable) + << II + << SourceRange(TemplateParams->getTemplateLoc(), + TemplateParams->getRAngleLoc()); + return 0; + } else { + // There is an extraneous 'template<>' for this variable. Complain + // about it, but allow the declaration of the variable. + Diag(TemplateParams->getTemplateLoc(), diag::err_template_variable) + << II + << SourceRange(TemplateParams->getTemplateLoc(), + TemplateParams->getRAngleLoc()); + } + } + // The variable can not NewVD = VarDecl::Create(Context, DC, D.getIdentifierLoc(), II, R, SC, @@ -2209,8 +2241,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, } else { // FIXME: Handle function template specializations } - } - + } // C++ [dcl.fct.spec]p5: // The virtual specifier shall only be used in declarations of |