From: Paolo Carlini Date: Sat, 29 Jun 2013 00:11:03 +0000 (+0000) Subject: re PR c++/57645 (Explicitly-declared destructor with no exception specification is... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a5e90b2af35e879ce1f310c0639f907009b6c3cb;p=gcc.git re PR c++/57645 (Explicitly-declared destructor with no exception specification is always noexcept(true)) /cp 2013-06-28 Paolo Carlini PR c++/57645 * class.c (deduce_noexcept_on_destructors): Save, set, and restore TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) around the main loop over the destructors. /testsuite 2013-06-28 Paolo Carlini PR c++/57645 * g++.dg/cpp0x/noexcept21.C: New. From-SVN: r200559 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cffed313ce4..c00f24c7fd0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2013-06-28 Paolo Carlini + + PR c++/57645 + * class.c (deduce_noexcept_on_destructors): Save, set, and restore + TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) around the main loop over the + destructors. + 2013-06-28 Balaji V. Iyer * parser.c (cp_parser_array_notation): Removed rejection array notation diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 0067605969a..bb2c3fe80e4 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4593,15 +4593,20 @@ deduce_noexcept_on_destructor (tree dtor) static void deduce_noexcept_on_destructors (tree t) { - tree fns; - /* If for some reason we don't have a CLASSTYPE_METHOD_VEC, we bail out now. */ if (!CLASSTYPE_METHOD_VEC (t)) return; - for (fns = CLASSTYPE_DESTRUCTORS (t); fns; fns = OVL_NEXT (fns)) + bool saved_nontrivial_dtor = TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t); + + /* Avoid early exit from synthesized_method_walk (c++/57645). */ + TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) = true; + + for (tree fns = CLASSTYPE_DESTRUCTORS (t); fns; fns = OVL_NEXT (fns)) deduce_noexcept_on_destructor (OVL_CURRENT (fns)); + + TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) = saved_nontrivial_dtor; } /* Subroutine of set_one_vmethod_tm_attributes. Search base classes diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 28874b0f28f..1ab4a98eb10 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-06-28 Paolo Carlini + + PR c++/57645 + * g++.dg/cpp0x/noexcept21.C: New. + 2013-06-28 Jakub Jelinek PR target/57736 diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept21.C b/gcc/testsuite/g++.dg/cpp0x/noexcept21.C new file mode 100644 index 00000000000..ec88e1d3d87 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept21.C @@ -0,0 +1,87 @@ +// PR c++/57645 +// { dg-do compile { target c++11 } } + +struct Thrower +{ + ~Thrower() noexcept(false) { throw 1; } +}; + +struct ExplicitA +{ + ~ExplicitA() {} + + Thrower t; +}; + +struct ExplicitB +{ + ~ExplicitB(); + + Thrower t; +}; + +ExplicitB::~ExplicitB() {} + +struct ExplicitC +{ + ~ExplicitC() = default; + + Thrower t; +}; + +struct ExplicitD +{ + ~ExplicitD(); + + Thrower t; +}; + +ExplicitD::~ExplicitD() = default; + +struct NoThrower +{ + ~NoThrower() noexcept(true) {} +}; + +struct ExplicitE +{ + ~ExplicitE() {} + + NoThrower t; +}; + +struct ExplicitF +{ + ~ExplicitF(); + + NoThrower t; +}; + +ExplicitF::~ExplicitF() {} + +struct ExplicitG +{ + ~ExplicitG() = default; + + NoThrower t; +}; + +struct ExplicitH +{ + ~ExplicitH(); + + NoThrower t; +}; + +ExplicitH::~ExplicitH() = default; + +#define SA(X) static_assert(X, #X) + +SA( !noexcept(ExplicitA()) ); +SA( !noexcept(ExplicitB()) ); +SA( !noexcept(ExplicitC()) ); +SA( !noexcept(ExplicitD()) ); +SA( noexcept(ExplicitE()) ); +SA( noexcept(ExplicitF()) ); +SA( noexcept(ExplicitG()) ); +SA( noexcept(ExplicitH()) );