[cfe-commits] r110175 - in /cfe/trunk: lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclCXX.cpp test/CXX/special/class.dtor/p9.cpp test/SemaCXX/destructor.cpp

John McCall rjmccall at apple.com
Tue Aug 3 18:04:25 PDT 2010


Author: rjmccall
Date: Tue Aug  3 20:04:25 2010
New Revision: 110175

URL: http://llvm.org/viewvc/llvm-project?rev=110175&view=rev
Log:
Only look up an 'operator delete' on the definition of a destructor, not on
a declaration.


Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/CXX/special/class.dtor/p9.cpp
    cfe/trunk/test/SemaCXX/destructor.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=110175&r1=110174&r2=110175&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Aug  3 20:04:25 2010
@@ -3731,12 +3731,6 @@
         AddOverriddenMethods(Method->getParent(), Method);
     }
 
-    // Additional checks for the destructor; make sure we do this after we
-    // figure out whether the destructor is virtual.
-    if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(NewFD))
-      if (!Destructor->getParent()->isDependentType())
-        CheckDestructor(Destructor);
-
     // Extra checking for C++ overloaded operators (C++ [over.oper]).
     if (NewFD->isOverloadedOperator() &&
         CheckOverloadedOperatorDeclaration(NewFD))
@@ -4793,9 +4787,13 @@
         !hasAnyErrorsInThisFunction())
       DiagnoseInvalidJumps(Body);
 
-    if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(dcl))
+    if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(dcl)) {
+      if (!Destructor->getParent()->isDependentType())
+        CheckDestructor(Destructor);
+
       MarkBaseAndMemberDestructorsReferenced(Destructor->getLocation(),
                                              Destructor->getParent());
+    }
     
     // If any errors have occurred, clear out any temporaries that may have
     // been leftover. This ensures that these temporaries won't be picked up for

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=110175&r1=110174&r2=110175&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Aug  3 20:04:25 2010
@@ -2877,8 +2877,9 @@
     ClassDecl->addedConstructor(Context, Constructor);
 }
 
-/// CheckDestructor - Checks a fully-formed destructor for well-formedness, 
-/// issuing any diagnostics required. Returns true on error.
+/// CheckDestructor - Checks a fully-formed destructor definition for
+/// well-formedness, issuing any diagnostics required.  Returns true
+/// on error.
 bool Sema::CheckDestructor(CXXDestructorDecl *Destructor) {
   CXXRecordDecl *RD = Destructor->getParent();
   

Modified: cfe/trunk/test/CXX/special/class.dtor/p9.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/special/class.dtor/p9.cpp?rev=110175&r1=110174&r2=110175&view=diff
==============================================================================
--- cfe/trunk/test/CXX/special/class.dtor/p9.cpp (original)
+++ cfe/trunk/test/CXX/special/class.dtor/p9.cpp Tue Aug  3 20:04:25 2010
@@ -43,6 +43,30 @@
     using A::operator delete;
     using B::operator delete;
 
-    ~C(); // expected-error {{multiple suitable 'operator delete' functions in 'C'}}
+    ~C();
   };
+
+  C::~C() {} // expected-error {{multiple suitable 'operator delete' functions in 'C'}}
+}
+
+// ...at the point of definition of a virtual destructor...
+namespace test2 {
+  struct A {
+    virtual ~A();
+    static void operator delete(void*, const int &);
+  };
+
+  struct B {
+    virtual ~B();
+    static void operator delete(void*, const int &); // expected-note {{declared here}}
+  };
+  B::~B() {} // expected-error {{no suitable member 'operator delete' in 'B'}}
+
+  struct CBase { virtual ~CBase(); };
+  struct C : CBase { // expected-error {{no suitable member 'operator delete' in 'C'}}
+    static void operator delete(void*, const int &); // expected-note {{declared here}}
+  };
+  void test() {
+    C c; // expected-note {{first required here}}
+  }
 }

Modified: cfe/trunk/test/SemaCXX/destructor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/destructor.cpp?rev=110175&r1=110174&r2=110175&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/destructor.cpp (original)
+++ cfe/trunk/test/SemaCXX/destructor.cpp Tue Aug  3 20:04:25 2010
@@ -103,5 +103,5 @@
   };
 
   class B : A<int> { B(); };
-  B::B() {}
+  B::B() {} // expected-note {{in instantiation of member function 'test6::A<int>::~A' requested here}}
 }





More information about the cfe-commits mailing list