public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix c++/67337 (segfault in mangle.c)
@ 2015-08-24 11:52 Markus Trippelsdorf
  2015-08-31 10:26 ` ping [aPATCH] " Markus Trippelsdorf
  2015-12-02 19:50 ` [PATCH] " Jason Merrill
  0 siblings, 2 replies; 4+ messages in thread
From: Markus Trippelsdorf @ 2015-08-24 11:52 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* ping [aPATCH] Fix c++/67337 (segfault in mangle.c)
  2015-08-24 11:52 [PATCH] Fix c++/67337 (segfault in mangle.c) Markus Trippelsdorf
@ 2015-08-31 10:26 ` Markus Trippelsdorf
  2015-11-16 15:26   ` Markus Trippelsdorf
  2015-12-02 19:50 ` [PATCH] " Jason Merrill
  1 sibling, 1 reply; 4+ messages in thread
From: Markus Trippelsdorf @ 2015-08-31 10:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

On 2015.08.24 at 13:44 +0200, Markus Trippelsdorf wrote:

ping

> 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
> 

-- 
Markus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ping [aPATCH] Fix c++/67337 (segfault in mangle.c)
  2015-08-31 10:26 ` ping [aPATCH] " Markus Trippelsdorf
@ 2015-11-16 15:26   ` Markus Trippelsdorf
  0 siblings, 0 replies; 4+ messages in thread
From: Markus Trippelsdorf @ 2015-11-16 15:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

On 2015.08.31 at 11:31 +0200, Markus Trippelsdorf wrote:
> On 2015.08.24 at 13:44 +0200, Markus Trippelsdorf wrote:

another ping.

> ping
> 
> > 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
> > 
> 
> -- 
> Markus

-- 
Markus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix c++/67337 (segfault in mangle.c)
  2015-08-24 11:52 [PATCH] Fix c++/67337 (segfault in mangle.c) Markus Trippelsdorf
  2015-08-31 10:26 ` ping [aPATCH] " Markus Trippelsdorf
@ 2015-12-02 19:50 ` Jason Merrill
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2015-12-02 19:50 UTC (permalink / raw)
  To: Markus Trippelsdorf, gcc-patches

OK, thanks.

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-02 19:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-24 11:52 [PATCH] Fix c++/67337 (segfault in mangle.c) Markus Trippelsdorf
2015-08-31 10:26 ` ping [aPATCH] " Markus Trippelsdorf
2015-11-16 15:26   ` Markus Trippelsdorf
2015-12-02 19:50 ` [PATCH] " Jason Merrill

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).