]> granicus.if.org Git - clang/commitdiff
Mark the operator delete associated with a virtual destructor as referenced.
authorJohn McCall <rjmccall@apple.com>
Sat, 3 Jul 2010 18:33:00 +0000 (18:33 +0000)
committerJohn McCall <rjmccall@apple.com>
Sat, 3 Jul 2010 18:33:00 +0000 (18:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107573 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/destructor.cpp

index 4dd5e3f30dddafc1a8572d26b9c53ba99ac09c02..1d0264853cbddf08451e391ce4927d8e9bf87856 100644 (file)
@@ -2898,6 +2898,8 @@ bool Sema::CheckDestructor(CXXDestructorDecl *Destructor) {
     Context.DeclarationNames.getCXXOperatorName(OO_Delete);
     if (FindDeallocationFunction(Loc, RD, Name, OperatorDelete))
       return true;
+
+    MarkDeclarationReferenced(Loc, OperatorDelete);
     
     Destructor->setOperatorDelete(OperatorDelete);
   }
index 3c63c3d36a788a7dc3412ddd8f6b992e6321bf82..2c60b32204901b2b45afd79c85902282f99daff7 100644 (file)
@@ -88,3 +88,20 @@ namespace PR6709 {
 
 struct X0 { virtual ~X0() throw(); };
 struct X1 : public X0 { };
+
+// Make sure we instantiate operator deletes when building a virtual
+// destructor.
+namespace test6 {
+  template <class T> class A {
+  public:
+    void *operator new(unsigned long);
+    void operator delete(void *p) {
+      T::deleteIt(p); // expected-error {{type 'int' cannot be used prior to '::'}}
+    }
+
+    virtual ~A() {} // expected-note {{in instantiation of member function 'test6::A<int>::operator delete' requested here}}
+  };
+
+  class B : A<int> { B(); };
+  B::B() {}
+}