+2020-01-10 Jason Merrill <jason@redhat.com>
+
+ PR c++/93173 - incorrect tree sharing.
+ * gimplify.c (copy_if_shared): No longer static.
+ * gimplify.h: Declare it.
+
2020-01-10 Richard Sandiford <richard.sandiford@arm.com>
* doc/invoke.texi (-msve-vector-bits=): Document that
+2020-01-10 Jason Merrill <jason@redhat.com>
+
+ PR c++/93173 - incorrect tree sharing.
+ PR c++/93033
+ * cp-gimplify.c (cp_gimplify_init_expr, cp_gimplify_expr): Use
+ copy_if_shared after cp_genericize_tree.
+ * typeck2.c (split_nonconstant_init): Don't unshare here.
+
2020-01-08 Jason Merrill <jason@redhat.com>
* cp-gimplify.c (cp_gimplify_expr) [TARGET_EXPR]: Check
replace_placeholders (from, to);
from = split_nonconstant_init (to, from);
cp_genericize_tree (&from, false);
+ copy_if_shared (&from);
*expr_p = from;
return;
}
hash_set<tree> pset;
cp_walk_tree (expr_p, cp_fold_r, &pset, NULL);
cp_genericize_tree (expr_p, false);
+ copy_if_shared (expr_p);
ret = GS_OK;
input_location = loc;
}
#include "intl.h"
#include "gcc-rich-location.h"
#include "target.h"
-#include "gimplify.h"
static tree
process_init_constructor (tree type, tree init, int nested, int flags,
}
else if (init)
{
- tree ie = build2 (INIT_EXPR, void_type_node,
- unshare_expr (dest), init);
+ tree ie = build2 (INIT_EXPR, void_type_node, dest, init);
code = add_stmt_to_compound (ie, code);
}
}
/* Unshare most of the shared trees rooted at *TP. DATA is passed to the
copy_if_shared_r callback unmodified. */
-static inline void
+void
copy_if_shared (tree *tp, void *data)
{
walk_tree (tp, copy_if_shared_r, data, NULL);
extern void declare_vars (tree, gimple *, bool);
extern void gimple_add_tmp_var (tree);
extern void gimple_add_tmp_var_fn (struct function *, tree);
+extern void copy_if_shared (tree *, void * = NULL);
extern tree unshare_expr (tree);
extern tree unshare_expr_without_location (tree);
extern tree voidify_wrapper_expr (tree, tree);
--- /dev/null
+// PR c++/93173
+// { dg-do compile { target c++11 } }
+
+template<typename> struct S1 {
+ S1(S1 &);
+ ~S1();
+};
+struct S2 {
+ S1<void> x;
+ int y;
+ int z;
+};
+void f(S1<void> x, int y, int z) { new S2{x, y, z}; }