aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/init.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/warn/delete-non-virtual-dtor.C22
4 files changed, 35 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 8125299..6ffebf1 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+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.
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index f80c475..7970b9a 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -3467,8 +3467,9 @@ build_delete (tree type, tree addr, special_function_kind auto_delete,
}
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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c13fd9f..5d44545 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/testsuite/g++.dg/warn/delete-non-virtual-dtor.C b/gcc/testsuite/g++.dg/warn/delete-non-virtual-dtor.C
index 9849b1e..c4acbde 100644
--- a/gcc/testsuite/g++.dg/warn/delete-non-virtual-dtor.C
+++ b/gcc/testsuite/g++.dg/warn/delete-non-virtual-dtor.C
@@ -5,6 +5,7 @@ struct polyBase { virtual void f(); };
void f(polyBase* p, polyBase* arr)
{
+ polyBase pb;
delete p; // { dg-warning "non-virtual destructor might" }
delete [] arr;
}
@@ -13,6 +14,7 @@ struct polyDerived : polyBase { };
void f(polyDerived* p, polyDerived* arr)
{
+ polyDerived pd;
delete p; // { dg-warning "non-virtual destructor might" }
delete [] arr;
}
@@ -29,6 +31,7 @@ struct finalDerived final : polyBase { };
void f(finalDerived* p, finalDerived* arr)
{
+ finalDerived fd;
delete p; // no error for final classes
delete [] arr;
}
@@ -38,7 +41,26 @@ struct safeDerived : safeBase { virtual void f(); };
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;
+}
+