This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR c++/38646: ICE with invalid specialization of variadic template
- From: Simon Martin <simartin at users dot sourceforge dot net>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 15 Nov 2009 22:35:43 +0100
- Subject: [PATCH] Fix PR c++/38646: ICE with invalid specialization of variadic template
Hello,
The following invalid snippet causes an ICE with checking turned on:
=== cut ===
template<int...> struct A;
template<int... N> struct A<N..., N...>
{
template<typename> struct B;
template<typename T> struct B<T*> {};
};
=== cut ===
The problem is that the first "N..." in the specialization is turned
into error_mark_node due to its invalid position, which causes a
"checking ICE" (unexpected error_mark_node) in template_class_depth.
The attached patch fixes this by not turning parameter pack arguments
into error_mark_node when they're not at the end of the parameter list.
It also splits a too long line into two.
I have successfully regtested this on x86_64-apple-darwin-9. Is it OK
for trunk?
Best regards,
Simon
:ADDPATCH c++:
2009-11-15 Simon Martin <simartin@users.sourceforge.net>
PR c++/38646
* pt.c (process_partial_specialization): Do not turn wrongly located
parameter pack arguments into error_mark_node.
Split too long lines into two.
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c (revision 154188)
+++ gcc/cp/pt.c (working copy)
@@ -3795,12 +3795,11 @@
|| (!packed_args && i < nargs - 1))
{
if (TREE_CODE (arg) == EXPR_PACK_EXPANSION)
- error ("parameter pack argument %qE must be at the end of the template argument list", arg);
+ error ("parameter pack argument %qE must be at the "
+ "end of the template argument list", arg);
else
- error ("parameter pack argument %qT must be at the end of the template argument list", arg);
-
- if (packed_args)
- TREE_VEC_ELT (packed_args, j) = error_mark_node;
+ error ("parameter pack argument %qT must be at the "
+ "end of the template argument list", arg);
}
}
2009-11-15 Simon Martin <simartin@users.sourceforge.net>
PR c++/38646
* g++.dg/cpp0x/pr38646.C: New test.
/* PR c++/38646 */
/* { dg-do "compile" } */
/* { dg-options "-std=c++0x" } */
template<int...> struct A;
template<int... N> struct A<N..., N...> /* { dg-error "must be at the end" } */
{
template<typename> struct B;
template<typename T> struct B<T*> {};
};