[C++ PATCH] Nested non-type template parameter packs using outer template parameter packs (PR c++/35022)

Doug Gregor doug.gregor@gmail.com
Fri Feb 15 17:41:00 GMT 2008


This patch fixes PR c++/35022, a regression involving non-type
template parameter packs whose type involves template parameter packs
from an outer level of templates. The basic problem shown in PR
c++/35022 is that we weren't properly dealing with
tsubst_pack_expansion when it returns a pack expansion, as it does
when we're substituting into a nested template. This patch fixes this
problem in two contexts: when coercing template arguments to a
non-type template parameter pack  (the ICE from the PR) and also when
dealing with the "sizeof...(X)" form of SIZEOF_EXPR.
Also, the actual PR was an ice-on-invalid-code, where adding an
ellipsis makes the code ill-formed. Unfortunately, that illuminated an
error in the parsing logic, where we weren't properly parsing an
unnamed non-type template parameter pack. The parser tweaks in this
patch fix that problem.

The astute reviewer will note that there are 3 xfails in this new test
case. These are examples that I believe should be well-formed, but (1)
it's not entirely clear that the C++0x working paper agrees with me,
(2) the results of this test case will change anyway if N2488 goes
through in two weeks, and (3) I don't have a fix, but the probable fix
would affect too much C++98 code for me to propose at this stage of
GCC development.

Tested i686-pc-linux-gnu, fixes a regression; okay for 4.3?

  - Doug

2008-02-15  Douglas Gregor  <doug.gregor@gmail.com>

	PR c++/35022
	* pt.c (coerce_template_parameter_pack): Cope with
	tsubst_pack_expansion returning a pack expansion (as occurs when
	substituting into a nested template).
	(tsubst_copy) <case SIZEOF_EXPR>: Cope with tsubst_pack_expansion
	returning a pack expansion, or a TREE_VEC ending in a pack
	expansion, both of which can occur when substituting into a nested
	template.
	(tsubst_copy_and_build) <case SIZEOF_EXPR>: When we're
	instantiating the sizeof...(X) form, make tsubst_copy do the
	work.
	* parser.c (cp_parser_template_parameter): Deal with unnamed
	non-type template parameter packs identified by pack expansions in
	the parameter type.
	
2008-02-15  Douglas Gregor  <doug.gregor@gmail.com>

	PR c++/35022
	* g++.dg/cpp0x/vt-35022.C: New.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: variadic-ttp.patch
Type: text/x-patch
Size: 6982 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080215/6b926e8b/attachment.bin>


More information about the Gcc-patches mailing list