On Wed, Nov 23, 2016 at 09:11:02AM -0500, Jason Merrill wrote: > On Tue, Nov 22, 2016 at 3:45 PM, Jakub Jelinek <ja...@redhat.com> wrote: > > As mentioned in the PR, another option I see is special case > > REFERENCE_REF_P INDIRECT_REFs and MEM_REFs into which they are gimplified > > in cp_genericize_r by not changing is_invisiref_parm decls if they are > > already wrapped in those. > > That sounds more robust.
Actually, now that I think about it, it sounds less robust. E.g. if the invisiref parm is initially used as operand of ADDR_EXPR, then during the first cp_genericize_tree it will be turned into ADDR_EXPR <INDIRECT_REF <decl>>, but gimplification will turn that just into decl, and if we genericize that again, we turn it into INDIRECT_REF <decl> because we won't see INDIRECT_REF/MEM_REF wrapping it. Is there any easy way to construct a testcase where VEC_INIT_EXPR initializer will be an arbitrary expression where such &parm could appear if parm is passed by invisible reference? Also, gimplification already performs tons of other folding (through fold_stmt), making it less likely to recognize those. Jakub