+2011-07-01 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ PR c++/49605
+ * init.c (build_delete): Only warn for sfk_deleting_destructor.
+
2011-07-01 Jakub Jelinek <jakub@redhat.com>
* Make-lang.in (cp/decl.o): Depend on pointer-set.h.
}
complete_p = false;
}
- else if (warn_delnonvdtor && MAYBE_CLASS_TYPE_P (type)
- && !CLASSTYPE_FINAL (type) && TYPE_POLYMORPHIC_P (type))
+ else if (auto_delete == sfk_deleting_destructor && warn_delnonvdtor
+ && MAYBE_CLASS_TYPE_P (type) && !CLASSTYPE_FINAL (type)
+ && TYPE_POLYMORPHIC_P (type))
{
tree dtor;
dtor = CLASSTYPE_DESTRUCTORS (type);
+2011-07-01 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ PR c++/49605
+ * g++.dg/warn/delete-non-virtual-dtor.C: Adjust.
+
2011-07-01 Jason Merrill <jason@redhat.com>
PR c++/48261
void f(polyBase* p, polyBase* arr)
{
+ polyBase pb;
delete p; // { dg-warning "non-virtual destructor might" }
delete [] arr;
}
void f(polyDerived* p, polyDerived* arr)
{
+ polyDerived pd;
delete p; // { dg-warning "non-virtual destructor might" }
delete [] arr;
}
void f(finalDerived* p, finalDerived* arr)
{
+ finalDerived fd;
delete p; // no error for final classes
delete [] arr;
}
void f(safeDerived* p, safeDerived* arr)
{
+ safeDerived sd;
delete p; // no error because base has virtual dtor
delete [] arr;
}
+struct polyBaseNonTrivial { ~polyBaseNonTrivial(); virtual void f(); };
+
+void f(polyBaseNonTrivial* p, polyBaseNonTrivial* arr)
+{
+ polyBaseNonTrivial pbnt;
+ delete p; // { dg-warning "non-virtual destructor might" }
+ delete [] arr;
+}
+
+struct polyDerivedNT : polyBaseNonTrivial { ~polyDerivedNT(); };
+
+void f(polyDerivedNT* p, polyDerivedNT* arr)
+{
+ polyDerivedNT pdnt;
+ delete p; // { dg-warning "non-virtual destructor might" }
+ delete [] arr;
+}
+