On 2013-11-10 10:38, Adam Butcher wrote: > On 2013-11-10 6:10, Jason Merrill wrote: >> >> Hmm, actually I think messing with the non-pack's decl is dangerous, >> and we should come up with a new decl for the pack instead. I think >> you can use reduce_template_parm_level with a "levels" argument of 0 >> to build a new decl and parm index. >> > I actually did this in one of my experiments and it worked fine. > Although I also had to update the template parm list with new decl: > > TREE_VALUE (TREE_VEC_ELT (current, i)) = TREE_CHAIN (t); > > At that point I had the convert function in pt.c an operating > directly > on current_template_parms (also having direct access to the two > statics > required; reduce_template_parm_level and canonical_type_parameter). > > I can't think of a case where we'd want to make this substitution in > anything but the current_template_parms so maybe moving the convert > function back into to pt.c and removing the 'current' parm from it > might be best? > >> And if we're doing that, setting TYPE_STUB_DECL and TYPE_NAME is >> indeed necessary. >> >>> Only for the sake of not exposing this (currently static) function >>> from >>> pt.c (or moving the pack convert function into pt.c). My original >>> impl >>> did extern canonical_type_parameter and use that and I think it >>> worked >>> as expected. Would that be preferred? >> >> Yes. Please declare it in cp-tree.h rather than within the >> function. >> > Will do. Unless, as suggested above, we go for moving > convert_generic_types_to_packs into pt.c in which case exposing these > internals won't be necessary. > With the convert function in pt.c, PATCH 2/3 now looks as follows: