* [C++ PATCH] Fix error-recovery in maybe_thunk_body (PR c++/79899)
@ 2017-03-07 19:03 Jakub Jelinek
2017-03-10 15:20 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2017-03-07 19:03 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
Hi!
Apparently in error recovery, populate_clone_array can't return fns
with all NULLs. maybe_thunk_body used to handle that fine, but
the newly added ctor_omit_inherited_parms call ICEs.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?
2017-03-07 Jakub Jelinek <jakub@redhat.com>
PR c++/79899
* optimize.c (maybe_thunk_body): Don't ICE if fns[0] is NULL.
Use XALLOCAVEC macro.
* g++.dg/other/friend7.C: New test.
--- gcc/cp/optimize.c.jj 2017-02-04 08:43:15.000000000 +0100
+++ gcc/cp/optimize.c 2017-03-07 13:21:52.280184213 +0100
@@ -262,7 +262,7 @@ maybe_thunk_body (tree fn, bool force)
populate_clone_array (fn, fns);
/* Don't use thunks if the base clone omits inherited parameters. */
- if (ctor_omit_inherited_parms (fns[0]))
+ if (fns[0] && ctor_omit_inherited_parms (fns[0]))
return 0;
DECL_ABSTRACT_P (fn) = false;
@@ -324,7 +324,7 @@ maybe_thunk_body (tree fn, bool force)
if (length > max_parms)
max_parms = length;
}
- args = (tree *) alloca (max_parms * sizeof (tree));
+ args = XALLOCAVEC (tree, max_parms);
/* We know that any clones immediately follow FN in TYPE_METHODS. */
FOR_EACH_CLONE (clone, fn)
--- gcc/testsuite/g++.dg/other/friend7.C.jj 2017-03-07 13:22:44.814487619 +0100
+++ gcc/testsuite/g++.dg/other/friend7.C 2017-03-07 13:23:16.793063590 +0100
@@ -0,0 +1,9 @@
+// PR c++/79899
+
+// { dg-do compile }
+// { dg-options "-Os" }
+
+struct A
+{
+ friend A::~A() {} // { dg-error "implicitly friends of their class" }
+};
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C++ PATCH] Fix error-recovery in maybe_thunk_body (PR c++/79899)
2017-03-07 19:03 [C++ PATCH] Fix error-recovery in maybe_thunk_body (PR c++/79899) Jakub Jelinek
@ 2017-03-10 15:20 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2017-03-10 15:20 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches List
OK.
On Tue, Mar 7, 2017 at 2:03 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> Apparently in error recovery, populate_clone_array can't return fns
> with all NULLs. maybe_thunk_body used to handle that fine, but
> the newly added ctor_omit_inherited_parms call ICEs.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
>
> 2017-03-07 Jakub Jelinek <jakub@redhat.com>
>
> PR c++/79899
> * optimize.c (maybe_thunk_body): Don't ICE if fns[0] is NULL.
> Use XALLOCAVEC macro.
>
> * g++.dg/other/friend7.C: New test.
>
> --- gcc/cp/optimize.c.jj 2017-02-04 08:43:15.000000000 +0100
> +++ gcc/cp/optimize.c 2017-03-07 13:21:52.280184213 +0100
> @@ -262,7 +262,7 @@ maybe_thunk_body (tree fn, bool force)
> populate_clone_array (fn, fns);
>
> /* Don't use thunks if the base clone omits inherited parameters. */
> - if (ctor_omit_inherited_parms (fns[0]))
> + if (fns[0] && ctor_omit_inherited_parms (fns[0]))
> return 0;
>
> DECL_ABSTRACT_P (fn) = false;
> @@ -324,7 +324,7 @@ maybe_thunk_body (tree fn, bool force)
> if (length > max_parms)
> max_parms = length;
> }
> - args = (tree *) alloca (max_parms * sizeof (tree));
> + args = XALLOCAVEC (tree, max_parms);
>
> /* We know that any clones immediately follow FN in TYPE_METHODS. */
> FOR_EACH_CLONE (clone, fn)
> --- gcc/testsuite/g++.dg/other/friend7.C.jj 2017-03-07 13:22:44.814487619 +0100
> +++ gcc/testsuite/g++.dg/other/friend7.C 2017-03-07 13:23:16.793063590 +0100
> @@ -0,0 +1,9 @@
> +// PR c++/79899
> +
> +// { dg-do compile }
> +// { dg-options "-Os" }
> +
> +struct A
> +{
> + friend A::~A() {} // { dg-error "implicitly friends of their class" }
> +};
>
> Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-10 15:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-07 19:03 [C++ PATCH] Fix error-recovery in maybe_thunk_body (PR c++/79899) Jakub Jelinek
2017-03-10 15:20 ` 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).