diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-05-28 17:01:20 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-05-28 17:01:20 +0000 |
commit | c49006bcd0deb21ceca25ffee2e6220d861cae49 (patch) | |
tree | ce5870aff037c16b158c02fb51ded76fdc412d23 /gcc/cp/class.c | |
parent | 318a728f904732ccea8f616d2694af282ccfc848 (diff) | |
download | gcc-c49006bcd0deb21ceca25ffee2e6220d861cae49.tar.gz |
PR c++/15214
* class.c (finish_struct_1): Warn only if the dtor is non-private or
the class has friends.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@82366 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 47c60e7851d..0fdd748a7af 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); |