From: Richard Smith Date: Wed, 18 Sep 2013 23:09:24 +0000 (+0000) Subject: Remove a bogus diagnostic preventing static data member templates from being X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=58ee425b11e178c652fa6ff4c1c924fe9b98801e;p=clang Remove a bogus diagnostic preventing static data member templates from being defined with no initializer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190970 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index f53ca666d5..46733b0869 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -4459,9 +4459,6 @@ def ext_standalone_specifier : ExtWarn<"'%0' is not permitted on a declaration " def err_standalone_class_nested_name_specifier : Error< "forward declaration of %select{class|struct|interface|union|enum}0 cannot " "have a nested name specifier">; -def err_forward_var_nested_name_specifier : Error< - "forward declaration of variable template%select{| partial specialization}0 cannot " - "have a nested name specifier">; def err_typecheck_sclass_func : Error<"illegal storage class on function">; def err_static_block_func : Error< "function declared in block scope cannot have 'static' storage class">; diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 5d0f081391..b914cb2b20 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -1460,7 +1460,6 @@ public: LookupResult &Previous); NamedDecl* ActOnTypedefNameDecl(Scope* S, DeclContext* DC, TypedefNameDecl *D, LookupResult &Previous, bool &Redeclaration); - bool HandleVariableRedeclaration(Decl *D, CXXScopeSpec &SS); NamedDecl *ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 915fb607a6..a1a796de41 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1804,11 +1804,6 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(Declarator &D, ThisDecl = Actions.ActOnTemplateDeclarator(getCurScope(), *TemplateInfo.TemplateParams, D); - if (Tok.is(tok::semi) && - Actions.HandleVariableRedeclaration(ThisDecl, D.getCXXScopeSpec())) { - SkipUntil(tok::semi, true, true); - return 0; - } if (VarTemplateDecl *VT = dyn_cast_or_null(ThisDecl)) // Re-direct this decl to refer to the templated decl so that we can // initialize it. diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index beffe414f5..4d4637fd14 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4808,21 +4808,6 @@ 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(D) || - isa(D))) { - Diag(SS.getBeginLoc(), diag::err_forward_var_nested_name_specifier) - << isa(D) << SS.getRange(); - return true; - } - return false; -} - NamedDecl * Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, diff --git a/test/SemaCXX/cxx1y-variable-templates_in_class.cpp b/test/SemaCXX/cxx1y-variable-templates_in_class.cpp index c878c13906..139dd982b3 100644 --- a/test/SemaCXX/cxx1y-variable-templates_in_class.cpp +++ b/test/SemaCXX/cxx1y-variable-templates_in_class.cpp @@ -49,8 +49,8 @@ namespace out_of_line { template static CONST T right = T(100); template static CONST T right = T(5); }; - template CONST T B3::right; // expected-error {{forward declaration of variable template cannot have a nested name specifier}} - template CONST T B3::right; // expected-error {{forward declaration of variable template partial specialization cannot have a nested name specifier}} + template CONST T B3::right; + template CONST T B3::right; class B4 { template static CONST T right; @@ -58,9 +58,8 @@ namespace out_of_line { template static CONST T right_def = T(100); template static CONST T right_def; // expected-note {{explicit instantiation refers here}} }; - template CONST T B4::right; // expected-error {{forward declaration of variable template cannot have a nested name specifier}} - template CONST T B4::right; // expected-error {{forward declaration of variable template partial specialization cannot have a nested name specifier}} \ - // expected-note {{explicit instantiation refers here}} + template CONST T B4::right; + template CONST T B4::right; // expected-note {{explicit instantiation refers here}} template CONST int B4::right; // expected-error {{explicit instantiation of undefined static data member template 'right' of class}} template CONST int B4::right_def; // expected-error {{explicit instantiation of undefined static data member template 'right_def' of class}} } @@ -245,7 +244,7 @@ namespace in_class_template { // FIXME: These cases should be accepted. int *use_before_definition = A::x; - template template T A::x[sizeof(U)]; // expected-error {{forward declaration}} + template template T A::x[sizeof(U)]; static_assert(sizeof(A::x) == 1, ""); // expected-error {{incomplete}} template template T A::y >[] = { U()... };