On 11/09/2013 08:21 AM, Adam Butcher wrote:
+      TYPE_STUB_DECL (t) = TYPE_NAME (t) = TEMPLATE_TYPE_DECL (t);

Is this changing anything?  I'm not sure if we need to copy the decl
or if we can just reuse it, but either way we need to set the type of
TEMPLATE_TYPE_DECL (t) to t.

I think it (or at least one of the assignments) is necessary.  It is
derived from some similar code in tsubst.

The code in tsubst is updating the type because the TEMPLATE_TYPE_PARM_INDEX has changed; in this case, it hasn't, so neither has the TEMPLATE_TYPE_DECL. But see below...

I'll have another look into
it and add TREE_TYPE (TEMPLATE_TYPE_DECL (t)) = t also.  What problem
will be caused by not setting the latter; is it a consistency issue?  I
have not seen any probs in testing so far.

Just that without this assignment anything wanting to get from the TYPE_DECL to its type will get the non-pack, but we want it to get the pack.

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.

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.

Jason

Reply via email to