[PATCH] Fix incorrect substitution substituting into variadic alias template

Eli Friedman eli.friedman at gmail.com
Fri Jul 19 16:11:48 PDT 2013


On Fri, Jul 19, 2013 at 11:18 AM, Richard Smith <richard at metafoo.co.uk> wrote:
> On Thu, Jul 18, 2013 at 5:51 PM, Eli Friedman <eli.friedman at gmail.com>
> wrote:
>>
>> New patch attached.  It should be much more clear what it is and is
>> not doing.  (Also added the template template parameter test.)
>
>
> LGTM (but we seem to have some remaining problems -- see below)
>
>>
>> On Wed, Jul 17, 2013 at 6:58 PM, Eli Friedman <eli.friedman at gmail.com>
>> wrote:
>> > On Wed, Jul 17, 2013 at 6:01 PM, Richard Smith <richard at metafoo.co.uk>
>> > wrote:
>> >> On Wed, Jul 17, 2013 at 5:43 PM, Eli Friedman <eli.friedman at gmail.com>
>> >> wrote:
>> >>>
>> >>> Patch attached.  Fixes PR16646.  The concept is that when substitution
>> >>> replaces a pack with another pack, we don't want to expand the pack
>> >>> immediately: we want to expand it at the same level as the original
>> >>> pack.
>> >>
>> >>
>> >> How do we ensure that the we retain a pack expansion around the
>> >> transformed
>> >> entity?
>> >
>> > I'm pretty sure that if we find a template argument which is a pack
>> > expansion, the input TemplateTypeParmType has to be an unexpanded
>> > parameter pack; if I'm wrong about that, the code should be moved a
>> > bit.  I'll probably end up moving it anyway to make it more clear.
>> >
>> > If we are expanding a parameter pack, we must be in the context of an
>> > ArgumentPackSubstitutionIndexRAII which should expect the possibility
>> > of an unexpanded parameter pack.
>
>
> Some (but not all) cases where we expand parameter packs do detect the case
> where the transformed result contains an unexpanded pack and rebuild a pack
> expansion around it. Looking for callers of TryExpandParameterPacks in
> TreeTransform, I see:
>
> TransformExprs, TransformTemplateArguments, TransformObjCDictionaryLiteral
> get this right.
>
> TransformFunctionTypeParams, TransformTypeTraitExpr, TransformLambdaScope
> get this wrong.

I committed fixes for TransformTypeTraitExpr and one of the
TransformFunctionTypeParams cases.  I'm not sure it's possible to
trigger the others given that they can't be written in an alias
template.

-Eli



More information about the cfe-commits mailing list