On Tue, Mar 23, 2021 at 04:51:52PM -0400, Jason Merrill wrote: > > --- gcc/cp/tree.c.jj 2021-03-18 09:49:22.112712307 +0100 > > +++ gcc/cp/tree.c 2021-03-23 00:08:35.901724895 +0100 > > @@ -3128,6 +3128,35 @@ bot_manip (tree* tp, int* walk_subtrees, > > } > > return NULL_TREE; > > } > > + if (TREE_CODE (*tp) == DECL_EXPR > > + && VAR_P (DECL_EXPR_DECL (*tp)) > > + && DECL_ARTIFICIAL (DECL_EXPR_DECL (*tp)) > > + && !TREE_STATIC (DECL_EXPR_DECL (*tp)) > > + && DECL_CONTEXT (DECL_EXPR_DECL (*tp)) == NULL_TREE > > I might drop the DECL_CONTEXT check; I'd think any embedded temporaries that > happen to have it set would also need this treatment.
I had that first that way but it broke g++.dg/cpp0x/nsdmi12.C test. I can have another look why tomorrow. > > + && !splay_tree_lookup (target_remap, > > + (splay_tree_key) DECL_EXPR_DECL (*tp))) > > + { > > + tree t = create_temporary_var (TREE_TYPE (DECL_EXPR_DECL (*tp))); > > You don't need to copy DECL_INITIAL here? No, because all the temporaries that have DECL_INITIAL need to be manually put into BIND_EXPR_VARS of some BIND_EXPR, otherwise they wouldn't be handled properly elsewhere (e.g. walk_tree only walks DECL_INITIAL on BIND_EXPR). I can add there gcc_assert (DECL_INITIAL (DECL_EXPR_DECL (*tp)) == NULL_TREE); Jakub