[cfe-commits] r131722 - in /cfe/trunk: lib/Sema/SemaDecl.cpp lib/Sema/SemaExceptionSpec.cpp test/CXX/special/class.dtor/p3-0x.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Thu May 19 22:57:18 PDT 2011


Author: cornedbee
Date: Fri May 20 00:57:18 2011
New Revision: 131722

URL: http://llvm.org/viewvc/llvm-project?rev=131722&view=rev
Log:
Fix PR9941 for out-of-line template destructors too.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
    cfe/trunk/test/CXX/special/class.dtor/p3-0x.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=131722&r1=131721&r2=131722&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri May 20 00:57:18 2011
@@ -8200,10 +8200,10 @@
       const CXXDestructorDecl *Dtor =
               DelayedDestructorExceptionSpecChecks.back().first;
       if (Dtor->getParent() == Record) {
-        // Don't check if we're a template. The spec hasn't been adjusted.
-        if (!Dtor->getParent()->isDependentType())
-          CheckOverridingFunctionExceptionSpec(Dtor,
-              DelayedDestructorExceptionSpecChecks.back().second);
+        assert(!Dtor->getParent()->isDependentType() &&
+            "Should not ever add destructors of templates into the list.");
+        CheckOverridingFunctionExceptionSpec(Dtor,
+            DelayedDestructorExceptionSpecChecks.back().second);
         DelayedDestructorExceptionSpecChecks.pop_back();
       }
     }

Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=131722&r1=131721&r2=131722&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Fri May 20 00:57:18 2011
@@ -701,13 +701,18 @@
 
 bool Sema::CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New,
                                                 const CXXMethodDecl *Old) {
-  if (getLangOptions().CPlusPlus0x && New->getParent()->isBeingDefined() &&
-      isa<CXXDestructorDecl>(New)) {
-    // The destructor might be updated once the definition is finished. So
-    // remember it and check later.
-    DelayedDestructorExceptionSpecChecks.push_back(std::make_pair(
-      cast<CXXDestructorDecl>(New), cast<CXXDestructorDecl>(Old)));
-    return false;
+  if (getLangOptions().CPlusPlus0x && isa<CXXDestructorDecl>(New)) {
+    // Don't check uninstantiated template destructors at all. We can only
+    // synthesize correct specs after the template is instantiated.
+    if (New->getParent()->isDependentType())
+      return false;
+    if (New->getParent()->isBeingDefined()) {
+      // The destructor might be updated once the definition is finished. So
+      // remember it and check later.
+      DelayedDestructorExceptionSpecChecks.push_back(std::make_pair(
+        cast<CXXDestructorDecl>(New), cast<CXXDestructorDecl>(Old)));
+      return false;
+    }
   }
   return CheckExceptionSpecSubset(PDiag(diag::err_override_exception_spec),
                                   PDiag(diag::note_overridden_virtual_function),

Modified: cfe/trunk/test/CXX/special/class.dtor/p3-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/special/class.dtor/p3-0x.cpp?rev=131722&r1=131721&r2=131722&view=diff
==============================================================================
--- cfe/trunk/test/CXX/special/class.dtor/p3-0x.cpp (original)
+++ cfe/trunk/test/CXX/special/class.dtor/p3-0x.cpp Fri May 20 00:57:18 2011
@@ -169,3 +169,9 @@
 // CHECK: _ZTIi
 // CHECK: __cxa_call_unexpected
 // CHECK: define linkonce_odr void @_ZN2SwIiED1Ev({{.*}} nounwind
+
+template <typename T>
+struct TVC : VX
+{ virtual ~TVC(); };
+template <typename T>
+TVC<T>::~TVC() {}





More information about the cfe-commits mailing list