diff options
author | Markus Trippelsdorf <markus@trippelsdorf.de> | 2015-12-02 19:57:55 +0000 |
---|---|---|
committer | Markus Trippelsdorf <trippels@gcc.gnu.org> | 2015-12-02 19:57:55 +0000 |
commit | e7fc41a776a1e85fd052fc84184618768274a1af (patch) | |
tree | 966f1ad320883735aa2c30fdd61f16111dd2bacc | |
parent | 157bb85d48034bba6eb24f6f9f4ca4e6e8a5fa93 (diff) | |
download | gcc-e7fc41a776a1e85fd052fc84184618768274a1af.zip gcc-e7fc41a776a1e85fd052fc84184618768274a1af.tar.gz gcc-e7fc41a776a1e85fd052fc84184618768274a1af.tar.bz2 |
Fix c++/67337 (segfault in mangle.c)
PR c++/67337
* mangle.c (write_template_prefix): Guard against context==NULL.
From-SVN: r231203
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/mangle.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/pr67337.C | 25 |
3 files changed, 31 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6d344ff..ce26e5d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-12-02 Markus Trippelsdorf <markus@trippelsdorf.de> + + PR c++/67337 + * mangle.c (write_template_prefix): Guard against context==NULL. + 2015-12-02 Jason Merrill <jason@redhat.com> * call.c (build_new_op_1): Don't fold arguments to diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 6f8bf68..3ff3066 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<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 0000000..df2651b --- /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); +} |