From abce92087ba064d1f01be91d533389a0e1287f0e Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 18 Sep 2014 13:48:33 +0000 Subject: [PATCH] re PR c++/62232 (-Wnon-virtual-dtor shouldn't warn on final classes) /cp 2014-09-18 Paolo Carlini PR c++/62232 * class.c (finish_struct_1): Do not -Wnon-virtual-dtor warn for final class types. /testsuite 2014-09-18 Paolo Carlini PR c++/62232 * g++.dg/cpp0x/Wdtor1.C: New. From-SVN: r215351 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/class.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/Wdtor1.C | 13 +++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/Wdtor1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1e79182e86e..3a20e92612c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-09-18 Paolo Carlini + + PR c++/62232 + * class.c (finish_struct_1): Do not -Wnon-virtual-dtor warn + for final class types. + 2014-09-15 Jason Merrill * pt.c (lookup_template_class_1): Splice out abi_tag attribute if diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 6b86ef4d923..010ed25ea36 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -6506,7 +6506,8 @@ finish_struct_1 (tree t) /* This warning does not make sense for Java classes, since they cannot have destructors. */ if (!TYPE_FOR_JAVA (t) && warn_nonvdtor - && TYPE_POLYMORPHIC_P (t) && accessible_nvdtor_p (t)) + && TYPE_POLYMORPHIC_P (t) && accessible_nvdtor_p (t) + && !CLASSTYPE_FINAL (t)) warning (OPT_Wnon_virtual_dtor, "%q#T has virtual functions and accessible" " non-virtual destructor", t); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 41e5d2bfb62..3bebe31de92 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-09-18 Paolo Carlini + + PR c++/62232 + * g++.dg/cpp0x/Wdtor1.C: New. + 2014-09-18 Joseph Myers * gcc.dg/torture/float128-exact-underflow.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp0x/Wdtor1.C b/gcc/testsuite/g++.dg/cpp0x/Wdtor1.C new file mode 100644 index 00000000000..e376017deb3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/Wdtor1.C @@ -0,0 +1,13 @@ +// PR c++/62232 +// { dg-do compile { target c++11 } } +// { dg-options "-Wnon-virtual-dtor" } + +class base +{ +protected: + ~base () {} + virtual void foo (){}; +}; +class derive final : public base +{ +};