From: Markus Trippelsdorf <markus@trippelsdorf.de>
To: gcc-patches@gcc.gnu.org
Cc: Jason Merrill <jason@redhat.com>
Subject: [PATCH] Fix c++/67337 (segfault in mangle.c)
Date: Mon, 24 Aug 2015 11:52:00 -0000 [thread overview]
Message-ID: <20150824114438.GC401@x4> (raw)
decl_mangling_context() in mangle.c returns a NULL_TREE in case of
template type parameters. write_template_prefix() needs to handle this
situation.
Tested on ppc64le.
This is a regression from gcc=4.8.
OK for trunk, gcc-5 and gcc-4.9?
Thanks.
PR c++/67337
* mangle.c (write_template_prefix): Guard against context==NULL.
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 342cb93e68b3..a9993f40b94d 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -1149,7 +1149,7 @@ write_template_prefix (const tree node)
So, for the example above, `Outer<int>::Inner' is represented as a
substitution candidate by a TREE_LIST whose purpose is `Outer<int>'
and whose value is `Outer<T>::Inner<U>'. */
- if (TYPE_P (context))
+ if (context && TYPE_P (context))
substitution = build_tree_list (context, templ);
else
substitution = templ;
diff --git a/gcc/testsuite/g++.dg/template/pr67337.C b/gcc/testsuite/g++.dg/template/pr67337.C
new file mode 100644
index 000000000000..df2651bc9a57
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/pr67337.C
@@ -0,0 +1,25 @@
+template <class> class A
+{
+ void m_fn1 (int *, int);
+};
+
+template <class> class B
+{
+public:
+ typedef int Type;
+};
+
+template <class> class C
+{
+public:
+ C (int);
+ template <template <class> class T> void m_fn2 (typename T<void>::Type);
+};
+
+template <>
+void
+A<int>::m_fn1 (int *, int)
+{
+ C<int> a (0);
+ a.m_fn2<B> (0);
+}
--
Markus
next reply other threads:[~2015-08-24 11:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-24 11:52 Markus Trippelsdorf [this message]
2015-08-31 10:26 ` ping [aPATCH] " Markus Trippelsdorf
2015-11-16 15:26 ` Markus Trippelsdorf
2015-12-02 19:50 ` [PATCH] " Jason Merrill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150824114438.GC401@x4 \
--to=markus@trippelsdorf.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).