backport: re PR c++/55542 (g++ segmentation fault)

Backported from mainline
	2012-12-01  Jakub Jelinek  <jakub@redhat.com>

	PR c++/55542
	* pt.c (make_ith_pack_parameter_name): Return NULL if
	name is NULL.
	(tsubst_decl): Call make_ith_pack_parameter_name even if
	DECL_NAME is NULL.

	* g++.dg/cpp0x/vt-55542.C: New test.

From-SVN: r195652
This commit is contained in:
Jakub Jelinek 2013-02-01 15:03:44 +01:00 committed by Jakub Jelinek
parent 5712a08697
commit 51c5e92a52
4 changed files with 40 additions and 4 deletions

View File

@ -1,6 +1,14 @@
2013-02-01 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
2012-12-01 Jakub Jelinek <jakub@redhat.com>
PR c++/55542
* pt.c (make_ith_pack_parameter_name): Return NULL if
name is NULL.
(tsubst_decl): Call make_ith_pack_parameter_name even if
DECL_NAME is NULL.
2012-11-23 Jakub Jelinek <jakub@redhat.com>
PR c++/54046

View File

@ -2861,6 +2861,8 @@ make_ith_pack_parameter_name (tree name, int i)
char* newname;
int newname_len;
if (name == NULL_TREE)
return name;
snprintf (numbuf, NUMBUF_LEN, "%i", i);
newname_len = IDENTIFIER_LENGTH (name)
+ strlen (numbuf) + 2;
@ -10164,10 +10166,9 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
/* Get the Ith type. */
type = TREE_VEC_ELT (expanded_types, i);
if (DECL_NAME (r))
/* Rename the parameter to include the index. */
DECL_NAME (r) =
make_ith_pack_parameter_name (DECL_NAME (r), i);
/* Rename the parameter to include the index. */
DECL_NAME (r)
= make_ith_pack_parameter_name (DECL_NAME (r), i);
}
else if (!type)
/* We're dealing with a normal parameter. */

View File

@ -1,6 +1,11 @@
2013-02-01 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
2012-12-01 Jakub Jelinek <jakub@redhat.com>
PR c++/55542
* g++.dg/cpp0x/vt-55542.C: New test.
2012-11-23 Jakub Jelinek <jakub@redhat.com>
PR c++/54046

View File

@ -0,0 +1,22 @@
// PR c++/55542
// { dg-options "-std=c++11" }
template <typename ... P>
struct B
{
template <typename O>
B (O *o, void (O::*f) (P ... p)) {}
};
class C
{
void foo (void *, int);
template <typename ... A>
void bar (A ... a);
B <void *> c;
B <void *, int> d;
C (int) : c (this, &C::bar), d (this, &C::foo) {}
};
template <typename ... A>
void C::bar (A ...)
{
}