[cfe-commits] r131362 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp lib/Sema/SemaTemplate.cpp test/SemaCXX/MicrosoftExtensions.cpp

Francois Pichet pichet2000 at gmail.com
Sat May 14 12:17:07 PDT 2011


Author: fpichet
Date: Sat May 14 14:17:07 2011
New Revision: 131362

URL: http://llvm.org/viewvc/llvm-project?rev=131362&view=rev
Log:
Revert 131347. It asserts if the specialization in within a class template:

template<class U> 
struct X1 {
  template<class T> void f(T*);
  template<> void f(int*) { } 
};

Won't be so simple. I need to think more about it.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=131362&r1=131361&r2=131362&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat May 14 14:17:07 2011
@@ -1775,9 +1775,6 @@
   "explicit specialization of %0 in function scope">;
 def err_template_spec_decl_class_scope : Error<
   "explicit specialization of %0 in class scope">;
-def war_template_spec_decl_class_scope : ExtWarn<
-  "Allowing explicit specialization of %0 in class scope is a Microsoft "
-  "extension">, InGroup<Microsoft>;
 def err_template_spec_decl_friend : Error<
   "cannot declare an explicit specialization in a friend">;
 def err_template_spec_decl_out_of_scope_global : Error<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=131362&r1=131361&r2=131362&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat May 14 14:17:07 2011
@@ -1685,14 +1685,10 @@
     if (OldMethod && NewMethod) {
       // Preserve triviality.
       NewMethod->setTrivial(OldMethod->isTrivial());
-   
-      // MSVC allows explicit template specialization at class scope.
-      bool IsMSExplicitSpecialization = getLangOptions().Microsoft &&
-                                 NewMethod->isFunctionTemplateSpecialization();
+
       bool isFriend = NewMethod->getFriendObjectKind();
 
-      if (!isFriend && NewMethod->getLexicalDeclContext()->isRecord() &&
-          !IsMSExplicitSpecialization) {
+      if (!isFriend && NewMethod->getLexicalDeclContext()->isRecord()) {
         //    -- Member function declarations with the same name and the
         //       same parameter types cannot be overloaded if any of them
         //       is a static member function declaration.
@@ -4573,7 +4569,7 @@
         NewFD->setInvalidDecl();
     } else if (isFunctionTemplateSpecialization) {
       if (CurContext->isDependentContext() && CurContext->isRecord() 
-          && !isFriend) {
+          && !isFriend && !getLangOptions().Microsoft) {
         Diag(NewFD->getLocation(), diag::err_function_specialization_in_class)
           << NewFD->getDeclName();
         NewFD->setInvalidDecl();

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=131362&r1=131361&r2=131362&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Sat May 14 14:17:07 2011
@@ -4401,12 +4401,9 @@
   }
 
   if (S.CurContext->isRecord() && !IsPartialSpecialization) {
-    if (S.getLangOptions().Microsoft)
-      S.Diag(Loc, diag::war_template_spec_decl_class_scope) << Specialized;
-    else {    
-      S.Diag(Loc, diag::err_template_spec_decl_class_scope) << Specialized;
-      return true;
-    }
+    S.Diag(Loc, diag::err_template_spec_decl_class_scope)
+      << Specialized;
+    return true;
   }
 
   // C++ [temp.class.spec]p6:

Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=131362&r1=131361&r2=131362&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Sat May 14 14:17:07 2011
@@ -197,10 +197,3 @@
    ch = (char)ptr;
    sh = (short)ptr;
 } 
-
-
-struct X1 {
-  template<typename T> void f(T);
-
-  template<> void f(int) { } // expected-warning{{Allowing explicit specialization of 'f' in class scope is a Microsoft extension}}
-};





More information about the cfe-commits mailing list