[cfe-commits] r107573 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/destructor.cpp
John McCall
rjmccall at apple.com
Sat Jul 3 11:33:00 PDT 2010
Author: rjmccall
Date: Sat Jul 3 13:33:00 2010
New Revision: 107573
URL: http://llvm.org/viewvc/llvm-project?rev=107573&view=rev
Log:
Mark the operator delete associated with a virtual destructor as referenced.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/destructor.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=107573&r1=107572&r2=107573&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Jul 3 13:33:00 2010
@@ -2898,6 +2898,8 @@
Context.DeclarationNames.getCXXOperatorName(OO_Delete);
if (FindDeallocationFunction(Loc, RD, Name, OperatorDelete))
return true;
+
+ MarkDeclarationReferenced(Loc, OperatorDelete);
Destructor->setOperatorDelete(OperatorDelete);
}
Modified: cfe/trunk/test/SemaCXX/destructor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/destructor.cpp?rev=107573&r1=107572&r2=107573&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/destructor.cpp (original)
+++ cfe/trunk/test/SemaCXX/destructor.cpp Sat Jul 3 13:33:00 2010
@@ -88,3 +88,20 @@
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() {}
+}
More information about the cfe-commits
mailing list