From 3cee7e4e2badde2374fc77bb8f3a072e1698d1fe Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Fri, 27 May 2016 12:08:03 +0000 Subject: [PATCH] re PR middle-end/71308 (ICE (segfault) in in gimple_fold_call gimple-fold.c:3060) PR middle-end/71308 * gimple-fold.c (gimple_fold_call): Check that LHS is not null. * g++.dg/torture/pr71308.C: New test. From-SVN: r236815 --- gcc/ChangeLog | 5 +++++ gcc/gimple-fold.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/torture/pr71308.C | 18 ++++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr71308.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 67a20e9eeec..14ba165d82c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-05-27 Marek Polacek + + PR middle-end/71308 + * gimple-fold.c (gimple_fold_call): Check that LHS is not null. + 2016-05-27 Andreas Krebbel * config/s390/s390.md (2x risbg splitters): Use diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index d6657e90799..600aa72f217 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -3053,7 +3053,8 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace) == void_type_node)) gimple_call_set_fntype (stmt, TREE_TYPE (fndecl)); /* If the call becomes noreturn, remove the lhs. */ - if (gimple_call_noreturn_p (stmt) + if (lhs + && gimple_call_noreturn_p (stmt) && (VOID_TYPE_P (TREE_TYPE (gimple_call_fntype (stmt))) || should_remove_lhs_p (lhs))) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c209d98a547..e556f3a3ba2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-05-27 Marek Polacek + + PR middle-end/71308 + * g++.dg/torture/pr71308.C: New test. + 2016-05-27 Dominik Vogt * gcc.dg/zero_bits_compound-1.c: New test. diff --git a/gcc/testsuite/g++.dg/torture/pr71308.C b/gcc/testsuite/g++.dg/torture/pr71308.C new file mode 100644 index 00000000000..ff5cd95fe7c --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr71308.C @@ -0,0 +1,18 @@ +// PR middle-end/71308 +// { dg-do compile } + +class S +{ + void foo (); + virtual void bar () = 0; + virtual ~S (); +}; +inline void +S::foo () +{ + bar (); +}; +S::~S () +{ + foo (); +} -- 2.30.2