r190970 - Remove a bogus diagnostic preventing static data member templates from being

Richard Smith richard-llvm at metafoo.co.uk
Wed Sep 18 16:09:24 PDT 2013


Author: rsmith
Date: Wed Sep 18 18:09:24 2013
New Revision: 190970

URL: http://llvm.org/viewvc/llvm-project?rev=190970&view=rev
Log:
Remove a bogus diagnostic preventing static data member templates from being
defined with no initializer.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/include/clang/Sema/Sema.h
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=190970&r1=190969&r2=190970&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Sep 18 18:09:24 2013
@@ -4459,9 +4459,6 @@ def ext_standalone_specifier : ExtWarn<"
 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">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=190970&r1=190969&r2=190970&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Sep 18 18:09:24 2013
@@ -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,

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=190970&r1=190969&r2=190970&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Sep 18 18:09:24 2013
@@ -1804,11 +1804,6 @@ Decl *Parser::ParseDeclarationAfterDecla
     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<VarTemplateDecl>(ThisDecl))
       // Re-direct this decl to refer to the templated decl so that we can
       // initialize it.

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=190970&r1=190969&r2=190970&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Sep 18 18:09:24 2013
@@ -4808,21 +4808,6 @@ static bool shouldConsiderLinkage(const
   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,

Modified: cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp?rev=190970&r1=190969&r2=190970&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp Wed Sep 18 18:09:24 2013
@@ -49,8 +49,8 @@ namespace out_of_line {
     template<typename T, typename T0> static CONST T right = T(100);
     template<typename T> static CONST T right<T,int> = T(5);
   };
-  template<typename T, typename T0> CONST T B3::right;  // expected-error {{forward declaration of variable template cannot have a nested name specifier}}
-  template<typename T> CONST T B3::right<T,int>;        // expected-error {{forward declaration of variable template partial specialization cannot have a nested name specifier}}
+  template<typename T, typename T0> CONST T B3::right;
+  template<typename T> CONST T B3::right<T,int>;
 
   class B4 {
     template<typename T, typename T0> static CONST T right;
@@ -58,9 +58,8 @@ namespace out_of_line {
     template<typename T, typename T0> static CONST T right_def = T(100);
     template<typename T> static CONST T right_def<T,int>;   // expected-note {{explicit instantiation refers here}}
   };
-  template<typename T, typename T0> CONST T B4::right;  // expected-error {{forward declaration of variable template cannot have a nested name specifier}}
-  template<typename T> CONST T B4::right<T,int>;        // expected-error {{forward declaration of variable template partial specialization cannot have a nested name specifier}} \
-                                                        // expected-note {{explicit instantiation refers here}}
+  template<typename T, typename T0> CONST T B4::right;
+  template<typename T> CONST T B4::right<T,int>; // expected-note {{explicit instantiation refers here}}
   template CONST int B4::right<int,int>;  // expected-error {{explicit instantiation of undefined static data member template 'right' of class}}
   template CONST int B4::right_def<int,int>;  // 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<int>::x<char>;
-    template<typename T> template<typename U> T A<T>::x<U>[sizeof(U)]; // expected-error {{forward declaration}}
+    template<typename T> template<typename U> T A<T>::x<U>[sizeof(U)];
     static_assert(sizeof(A<int>::x<char>) == 1, ""); // expected-error {{incomplete}}
 
     template<typename T> template<typename...U> T A<T>::y<tuple<U...> >[] = { U()... };





More information about the cfe-commits mailing list