error ("parenthesized initializer in array new");
return error_mark_node;
}
+
+ /* Collect flags for disabling subobject cleanups once the complete
+ object is fully constructed. */
+ vec<tree, va_gc> *flags = make_tree_vector ();
+
init_expr
= build_vec_init (data_addr,
cp_build_binary_op (input_location,
vecinit,
explicit_value_init_p,
/*from_array=*/0,
- complain);
+ complain,
+ &flags);
+
+ for (tree f : flags)
+ {
+ /* See maybe_push_temp_cleanup. */
+ tree d = f;
+ tree i = boolean_false_node;
+ if (TREE_CODE (f) == TREE_LIST)
+ {
+ /* To disable a build_vec_init cleanup, set
+ iterator = maxindex. */
+ d = TREE_PURPOSE (f);
+ i = TREE_VALUE (f);
+ ggc_free (f);
+ }
+ tree cl = build2 (MODIFY_EXPR, TREE_TYPE (d), d, i);
+ cl = convert_to_void (cl, ICV_STATEMENT, complain);
+ init_expr = build2 (COMPOUND_EXPR, void_type_node,
+ init_expr, cl);
+ }
+ release_tree_vector (flags);
}
else
{
--- /dev/null
+// PR c++/117827
+// { dg-do run { target c++11 } }
+
+struct C {
+ int c;
+ static int d, e;
+ C () : c (0) { ++d; }
+ C (const C &) = delete;
+ C &operator= (const C &) = delete;
+ ~C () { ++e; }
+};
+int C::d, C::e;
+
+C *
+foo (C *p)
+{
+ delete[] p;
+ throw 1;
+}
+
+int
+main ()
+{
+ try
+ {
+ foo (new C[1] {});
+ }
+ catch (...)
+ {
+ }
+ if (C::d != C::e)
+ __builtin_abort ();
+}