aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Marshall <tmarshall@real.com>2004-05-28 17:01:20 +0000
committerJason Merrill <jason@gcc.gnu.org>2004-05-28 13:01:20 -0400
commit9fd8f60d1dd31235b31af53659807573b4b53c50 (patch)
treece5870aff037c16b158c02fb51ded76fdc412d23
parentd1a7edafe6a978e8f380a74f1f6d386d871bf417 (diff)
downloadgcc-9fd8f60d1dd31235b31af53659807573b4b53c50.zip
gcc-9fd8f60d1dd31235b31af53659807573b4b53c50.tar.gz
gcc-9fd8f60d1dd31235b31af53659807573b4b53c50.tar.bz2
re PR c++/15214 (Warning non-virtual-dtor too strict)
PR c++/15214 * class.c (finish_struct_1): Warn only if the dtor is non-private or the class has friends. From-SVN: r82366
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/class.c11
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 92b10d0..b65da55 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2004-05-20 Tom Marshall <tmarshall@real.com>
+
+ PR c++/15214
+ * class.c (finish_struct_1): Warn only if the dtor is non-private or
+ the class has friends.
+
2004-05-27 Adam Nemet <anemet@lnxw.com>
PR c++/12883
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 47c60e7..0fdd748 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5185,7 +5185,16 @@ finish_struct_1 (tree t)
if (warn_nonvdtor && TYPE_POLYMORPHIC_P (t) && TYPE_HAS_DESTRUCTOR (t)
&& DECL_VINDEX (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (t), 1)) == NULL_TREE)
- warning ("`%#T' has virtual functions but non-virtual destructor", t);
+
+ {
+ tree dtor = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (t), 1);
+
+ /* Warn only if the dtor is non-private or the class has friends */
+ if (!TREE_PRIVATE (dtor) ||
+ (CLASSTYPE_FRIEND_CLASSES (t) ||
+ DECL_FRIENDLIST (TYPE_MAIN_DECL (t))))
+ warning ("%#T' has virtual functions but non-virtual destructor", t);
+ }
complete_vars (t);