Re: [PATCH] c++/reflection: ^^ rejects pack-index-specifier [PR126546]

Jason Merrill <[email protected]> Mon, 3 Aug 2026 17:02:02 -0400
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>
On 8/3/26 5:01 PM, Jason Merrill wrote:
> On 8/3/26 2:23 PM, Marek Polacek wrote:
>> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/16?
>>
>> -- >8 --
>> [expr.reflect] says that a reflection of a pack-index-expressions
>> is ill-formed.  But that applies to the ^^id-expression production,
>> not ^^type-id, in which a pack-index-specifier (for types) can be
>> used.  So it's wrong for get_reflection to check PACK_INDEX_P, it
>> should only reject PACK_INDEX_EXPR.
>>
>> I don't think that currently we can get there with a PACK_INDEX_EXPR
>> though: for a pack-index-expression Xs...[0] cp_parser_reflection_name
>> will consume Xs and then immediately call get_reflection which gives
>> an error.
> 
> This seems like a bit of a bug, since "A reflect-expression is parsed as 
> the longest possible sequence of tokens that could syntactically form a 
> reflect-expression.", i.e. the full pack-index-expression.  But not an 
> important one, since it's ill-formed either way.
> 
> OK for trunk/16.
(after 16 opens again)