We were adjusting the EH specification for destructors before looking at
the base classes, so we hadn't yet noticed that there was a non-trivial
base destructor to make things more complicated.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 799ff49ea8aa959deed277b590954bc3ef8253d2
Author: Jason Merrill <ja...@redhat.com>
Date: Fri Feb 15 10:30:22 2013 -0500
PR c++/56343
* class.c (check_bases_and_members): Deduce noexcept after
checking bases.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 38339f2..eaa109a 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5245,14 +5245,15 @@ check_bases_and_members (tree t)
cant_have_const_ctor = 0;
no_const_asn_ref = 0;
- /* Deduce noexcept on destructors. */
- if (cxx_dialect >= cxx0x)
- deduce_noexcept_on_destructors (t);
-
/* Check all the base-classes. */
check_bases (t, &cant_have_const_ctor,
&no_const_asn_ref);
+ /* Deduce noexcept on destructors. This needs to happen after we've set
+ triviality flags appropriately for our bases. */
+ if (cxx_dialect >= cxx0x)
+ deduce_noexcept_on_destructors (t);
+
/* Check all the method declarations. */
check_methods (t);
diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted41.C b/gcc/testsuite/g++.dg/cpp0x/defaulted41.C
new file mode 100644
index 0000000..4272012
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/defaulted41.C
@@ -0,0 +1,14 @@
+// PR c++/56343
+// { dg-do compile { target c++11 } }
+
+class B
+{
+public:
+ virtual ~B() noexcept(false) { }
+};
+
+class D : public B
+{
+public:
+ virtual ~D() = default;
+};