From e260b0a7dda804cd2bd0beee477d47ce9c01d4c0 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 10 Mar 2017 16:33:04 +0100 Subject: [PATCH] re PR c++/79899 (ICE in ctor_omit_inherited_parms at gcc/cp/method.c:576 on ARM target) 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. From-SVN: r246038 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/optimize.c | 4 ++-- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/other/friend7.C | 9 +++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/friend7.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a7acfa7eb36..d3871aada43 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-03-10 Jakub Jelinek + PR c++/79899 + * optimize.c (maybe_thunk_body): Don't ICE if fns[0] is NULL. + Use XALLOCAVEC macro. + PR c++/79896 * decl.c (finish_enum_value_list): If value is error_mark_node, don't copy it and change its type. diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 933612ced76..d646ef73803 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8b89d82e523..a7dae3d232c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-03-10 Jakub Jelinek + PR c++/79899 + * g++.dg/other/friend7.C: New test. + PR c++/79896 * g++.dg/ext/int128-5.C: New test. diff --git a/gcc/testsuite/g++.dg/other/friend7.C b/gcc/testsuite/g++.dg/other/friend7.C new file mode 100644 index 00000000000..4d22a8791fd --- /dev/null +++ b/gcc/testsuite/g++.dg/other/friend7.C @@ -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" } +}; -- 2.30.2