diff options
author | Jason Merrill <jason@redhat.com> | 2020-01-23 12:32:02 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2020-01-23 13:11:10 -0500 |
commit | 20afdcd36982752ba012960b862e9be7154b1274 (patch) | |
tree | b1b84dfb8fe2f82951a212efb5388a807bd245b7 | |
parent | 648796dab42b6e839f10fee5835f24cd2016a9f4 (diff) | |
download | gcc-20afdcd36982752ba012960b862e9be7154b1274.zip gcc-20afdcd36982752ba012960b862e9be7154b1274.tar.gz gcc-20afdcd36982752ba012960b862e9be7154b1274.tar.bz2 |
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.
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/decl.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/initlist-cleanup1.C | 17 |
3 files changed, 26 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 47d4f2d..f99951c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 47ff7ee..98ed79f 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 0000000..1e3ac12 --- /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<typename GC> +void +dz () +{ + ry{}; +} |