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