diff options
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)) |