diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6d344ffdf3c..ce26e5daa2f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-12-02 Markus Trippelsdorf + + PR c++/67337 + * mangle.c (write_template_prefix): Guard against context==NULL. + 2015-12-02 Jason Merrill * call.c (build_new_op_1): Don't fold arguments to diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 6f8bf68d951..3ff30663f08 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -1145,7 +1145,7 @@ write_template_prefix (const tree node) So, for the example above, `Outer::Inner' is represented as a substitution candidate by a TREE_LIST whose purpose is `Outer' and whose value is `Outer::Inner'. */ - 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 00000000000..df2651bc9a5 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr67337.C @@ -0,0 +1,25 @@ +template class A +{ + void m_fn1 (int *, int); +}; + +template class B +{ +public: + typedef int Type; +}; + +template class C +{ +public: + C (int); + template