re PR c++/40808 (member template specialization causes ICE)

Fix for PR c++/40808

gcc/cp/ChangeLog:

	PR c++/40808
	* mangle.c (write_template_args): Allow mangling of empty template
	argument list. Updated function comments.

gcc/testsuite/ChangeLog:

	PR c++/40808
	* g++.dg/abi/mangle34.C: New test

From-SVN: r153517
This commit is contained in:
Dodji Seketeli 2009-10-23 21:38:50 +00:00 committed by Dodji Seketeli
parent 92de1b3702
commit 8ab079f4d5
4 changed files with 57 additions and 4 deletions

View file

@ -1,3 +1,9 @@
2009-10-23 Dodji Seketeli <dodji@redhat.com>
PR c++/40808
* mangle.c (write_template_args): Allow mangling of empty template
argument list. Updated function comments.
2009-10-23 Jason Merrill <jason@redhat.com>
* semantics.c (lambda_expr_this_capture): Use thisify_lambda_field.

View file

@ -2284,21 +2284,22 @@ write_class_enum_type (const tree type)
/* Non-terminal <template-args>. ARGS is a TREE_VEC of template
arguments.
<template-args> ::= I <template-arg>+ E */
<template-args> ::= I <template-arg>* E */
static void
write_template_args (tree args)
{
int i;
int length = TREE_VEC_LENGTH (args);
int length = 0;
MANGLE_TRACE_TREE ("template-args", args);
write_char ('I');
gcc_assert (length > 0);
if (args)
length = TREE_VEC_LENGTH (args);
if (TREE_CODE (TREE_VEC_ELT (args, 0)) == TREE_VEC)
if (args && TREE_CODE (TREE_VEC_ELT (args, 0)) == TREE_VEC)
{
/* We have nested template args. We want the innermost template
argument list. */

View file

@ -1,3 +1,8 @@
2009-10-23 Dodji Seketeli <dodji@redhat.com>
PR c++/40808
* g++.dg/abi/mangle34.C: New test
2009-10-23 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/lambda/lambda-nested2.C: New.

View file

@ -0,0 +1,41 @@
// Contributed by Dodji Seketeli <dodji@redhat.com>
// Origin PR c++/40808
// { dg-do compile }
// This tests the mangling of empty template argument list in a template
// id.
// { dg-final { scan-assembler "_ZNK5DummyclI3GenEENT_3SigIE10ResultTypeERKS2_" } }
struct Void {};
template <class R> struct FunType {
typedef R ResultType;
};
struct WrongNumberOfSigArgs {};
template <typename R> struct CFunType {
template <class Dummy1=Void, class Dummy2=Void> struct Sig : public
FunType<WrongNumberOfSigArgs> {};
template <class Dummy> struct Sig<Void,Dummy> : public FunType<R> {};
};
struct Dummy {
template <typename F> typename F::template Sig<>::ResultType operator()(F
const& f) const {
return typename F::template Sig<>::ResultType(0);
}
};
struct Gen: public CFunType<int> {
int operator()() const {return 0;}
Gen() {}
};
int myfunction() {
return Dummy()(Gen());
}
int main() {
myfunction();
}