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.
Tested x86_64-pc-linux-gnu, applying to trunk.
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.
---
gcc/cp/decl.c | 3 ++-
gcc/testsuite/g++.dg/cpp0x/initlist-cleanup1.C | 17 +++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist-cleanup1.C
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 47ff7eea88f..98ed79f3579 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 00000000000..1e3ac122480
--- /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{};
+}
base-commit: 6d00f052ef209bacdd93f503b0c5fb428cc6c434
--
2.18.1