aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2009-10-23 21:38:50 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2009-10-23 23:38:50 +0200
commit8ab079f4d53b0a5ec861b81635e105ae4677255f (patch)
treee88a83234204b8e75b9b76fa356282a24451f952
parent92de1b370201aa7ea0a3cf0343840d08445293ba (diff)
downloadgcc-8ab079f4d53b0a5ec861b81635e105ae4677255f.zip
gcc-8ab079f4d53b0a5ec861b81635e105ae4677255f.tar.gz
gcc-8ab079f4d53b0a5ec861b81635e105ae4677255f.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/mangle.c9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/abi/mangle34.C41
4 files changed, 57 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 70cdad3..3ce735b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index f9a5503..d4bcbac 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -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. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4d6eb81..c44b4d7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/g++.dg/abi/mangle34.C b/gcc/testsuite/g++.dg/abi/mangle34.C
new file mode 100644
index 0000000..08c3bc0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/mangle34.C
@@ -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();
+}