From: Nathan Sidwell Date: Mon, 13 Mar 2017 11:58:15 +0000 (+0000) Subject: PR c++/79393 DR 1658 workaround X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=16e93e4b0b1e9ab40689a755c64948b3716ad0c0;p=gcc.git PR c++/79393 DR 1658 workaround PR c++/79393 DR 1658 workaround * method.c (synthesized_method_walk): Check vbases of abstract classes for dtor walk. From-SVN: r246085 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ac7a46e79df..00fb3651959 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-03-13 Nathan Sidwell + + PR c++/79393 DR 1658 workaround + * method.c (synthesized_method_walk): Check vbases of abstract + classes for dtor walk. + 2017-03-10 David Malcolm PR translation/79848 diff --git a/gcc/cp/method.c b/gcc/cp/method.c index f6024cda28a..772a6638c60 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1664,12 +1664,26 @@ synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p, /* Already examined vbases above. */; else if (vec_safe_is_empty (vbases)) /* No virtual bases to worry about. */; - else if (ABSTRACT_CLASS_TYPE_P (ctype) && cxx_dialect >= cxx14) + else if (ABSTRACT_CLASS_TYPE_P (ctype) && cxx_dialect >= cxx14 + /* DR 1658 specifies that vbases of abstract classes are + ignored for both ctors and dtors. However, that breaks + virtual dtor overriding when the ignored base has a + throwing destructor. So, ignore that piece of 1658. A + defect has been filed (no number yet). */ + && sfk != sfk_destructor) /* Vbase cdtors are not relevant. */; else { if (constexpr_p) *constexpr_p = false; + + /* To be conservative, ignore access to the base dtor that + DR1658 instructs us to ignore. */ + bool no_access_check = (cxx_dialect >= cxx14 + && ABSTRACT_CLASS_TYPE_P (ctype)); + + if (no_access_check) + push_deferring_access_checks (dk_no_check); FOR_EACH_VEC_ELT (*vbases, i, base_binfo) synthesized_method_base_walk (binfo, base_binfo, quals, copy_arg_p, move_p, ctor_p, @@ -1677,6 +1691,8 @@ synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p, fnname, flags, diag, spec_p, trivial_p, deleted_p, constexpr_p); + if (no_access_check) + pop_deferring_access_checks (); } /* Now handle the non-static data members. */ diff --git a/gcc/testsuite/g++.dg/cpp1y/pr79393.C b/gcc/testsuite/g++.dg/cpp1y/pr79393.C new file mode 100644 index 00000000000..a9e07d1cfdc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr79393.C @@ -0,0 +1,21 @@ +// { dg-do compile { target c++14 } } +// PR c++/79393 deduced eh spec, deleted dtors and vbases + +struct A3; + +struct VDT { + virtual ~VDT () noexcept (false); +}; + +struct A1 : virtual VDT { + virtual void abstract () = 0; +}; + +struct A2 : A1 { }; + +struct A3 : A2 +{ + virtual void abstract (); +}; + +A3 a3;