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

[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.  But leaving the PACK_INDEX_EXPR check in doesn't seem like
a bad idea.

	PR c++/126546

gcc/cp/ChangeLog:

	* reflect.cc (get_reflection): Check PACK_INDEX_EXPR instead of
	PACK_INDEX_P.

gcc/testsuite/ChangeLog:

	* g++.dg/reflect/pack-index1.C: Accept a reflection of a
	pack-index-specifier.  Reject a reflection of a
	pack-index-expression.
	* g++.dg/reflect/pack-index2.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 files changed