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.
This commit is contained in:
Jason Merrill 2020-01-23 12:32:02 -05:00
parent 648796dab4
commit 20afdcd369
3 changed files with 26 additions and 1 deletions

View file

@ -1,3 +1,10 @@
2020-01-23 Jason Merrill <jason@redhat.com>
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 <polacek@redhat.com>
PR c++/92907 - noexcept does not consider "const" in member functions.

View file

@ -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;

View file

@ -0,0 +1,17 @@
// PR c++/93345
// { dg-do compile { target c++11 } }
struct ln {
~ln ();
};
struct ry {
ln kj;
};
template<typename GC>
void
dz ()
{
ry{};
}