diff options
author | Larisse Voufo <lvoufo@google.com> | 2013-08-06 03:43:07 +0000 |
---|---|---|
committer | Larisse Voufo <lvoufo@google.com> | 2013-08-06 03:43:07 +0000 |
commit | 21de36ba6656db23c97de8989f0c26ed52204395 (patch) | |
tree | ad23d18be0bb427fc8cd8c7a4cf78c6acf28cab9 /clang/lib/Sema/SemaDecl.cpp | |
parent | cecdabb0bf4cad972e425e481d405580b08a8545 (diff) | |
download | bcm5719-llvm-21de36ba6656db23c97de8989f0c26ed52204395.tar.gz bcm5719-llvm-21de36ba6656db23c97de8989f0c26ed52204395.zip |
Moved diagnosis of forward declarations of variable templates from Parser to Sema.
llvm-svn: 187768
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 80ac1167ffa..15e6a492725 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4770,6 +4770,21 @@ static bool shouldConsiderLinkage(const FunctionDecl *FD) { llvm_unreachable("Unexpected context"); } +bool Sema::HandleVariableRedeclaration(Decl *D, CXXScopeSpec &SS) { + // If this is a redeclaration of a variable template or a forward + // declaration of a variable template partial specialization + // with nested name specifier, complain. + + if (D && SS.isNotEmpty() && + (isa<VarTemplateDecl>(D) || + isa<VarTemplatePartialSpecializationDecl>(D))) { + Diag(SS.getBeginLoc(), diag::err_forward_var_nested_name_specifier) + << isa<VarTemplatePartialSpecializationDecl>(D) << SS.getRange(); + return true; + } + return false; +} + NamedDecl * Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, @@ -4907,7 +4922,8 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, case SC_OpenCLWorkGroupLocal: llvm_unreachable("OpenCL storage class in c++!"); } - } + } + if (SC == SC_Static && CurContext->isRecord()) { if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) { if (RD->isLocalClass()) @@ -4966,7 +4982,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, IsPartialSpecialization = TemplateParams->size() > 0; } else { // if (TemplateParams->size() > 0) - // This is a template declaration. + // This is a template declaration. // Check that we can declare a template here. if (CheckTemplateDeclScope(S, TemplateParams)) |