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/mangle33.C: New test

From-SVN: r153516
This commit is contained in:
Dodji Seketeli 2009-10-23 21:32:35 +00:00 committed by Dodji Seketeli
parent 121e863d1d
commit f010c455f0
4 changed files with 58 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-21 Jakub Jelinek <jakub@redhat.com>
* mangle.c (finish_mangling_get_identifier): Use

View File

@ -2071,21 +2071,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/mangle33.C: New test
2009-10-23 Mikael Pettersson <mikpe@it.uu.se>
* gcc.c-torture/compile/pr11832.c: Delete.

View File

@ -0,0 +1,42 @@
// 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();
}