From: Jason Merrill Date: Thu, 23 Jan 2020 17:32:02 +0000 (-0500) Subject: c++: Fix ICE with defaulted destructor and template. X-Git-Tag: basepoints/gcc-11~1895 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20afdcd36982752ba012960b862e9be7154b1274;p=thirdparty%2Fgcc.git c++: Fix ICE with defaulted destructor and template. In a template we don't instantiate a deferred noexcept-spec, and we don't need it because we aren't going to do anything with the value of throwing_cleanup in a template anyway. PR c++/93345 - ICE with defaulted dtor and template. PR c++/33799 * decl.c (cxx_maybe_build_cleanup): Don't try to set throwing_cleanup in a template. --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 47d4f2d496cb..f99951cb72c5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2020-01-23 Jason Merrill + + PR c++/93345 - ICE with defaulted dtor and template. + PR c++/33799 + * decl.c (cxx_maybe_build_cleanup): Don't try to set + throwing_cleanup in a template. + 2020-01-22 Marek Polacek PR c++/92907 - noexcept does not consider "const" in member functions. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 47ff7eea88f1..98ed79f3579e 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -17393,7 +17393,8 @@ cxx_maybe_build_cleanup (tree decl, tsubst_flags_t complain) && !mark_used (decl, complain) && !(complain & tf_error)) return error_mark_node; - if (cleanup && cfun && !expr_noexcept_p (cleanup, tf_none)) + if (cleanup && cfun && !processing_template_decl + && !expr_noexcept_p (cleanup, tf_none)) cp_function_chain->throwing_cleanup = true; return cleanup; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-cleanup1.C b/gcc/testsuite/g++.dg/cpp0x/initlist-cleanup1.C new file mode 100644 index 000000000000..1e3ac122480b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-cleanup1.C @@ -0,0 +1,17 @@ +// PR c++/93345 +// { dg-do compile { target c++11 } } + +struct ln { + ~ln (); +}; + +struct ry { + ln kj; +}; + +template +void +dz () +{ + ry{}; +}