Fix middle-end/71308

Marek Polacek polacek@redhat.com
Fri May 27 12:49:00 GMT 2016


A stupid mistake of mine.  When I introduced the should_remove_lhs_p call,
I removed the check for LHS here, because should_remove_lhs_p checks that.
Well, in this case the LHS was NULL, but gimple_call_fntype (stmt) had void
type, so we went on and crashed on the SSA_NAME check.  Sorry.  But at least
we have a test exercising this path.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2016-05-27  Marek Polacek  <polacek@redhat.com>

	PR middle-end/71308
	* gimple-fold.c (gimple_fold_call): Check that LHS is not null.

	* g++.dg/torture/pr71308.C: New test.

diff --git gcc/gimple-fold.c gcc/gimple-fold.c
index d6657e9..600aa72 100644
--- gcc/gimple-fold.c
+++ 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 gcc/testsuite/g++.dg/torture/pr71308.C gcc/testsuite/g++.dg/torture/pr71308.C
index e69de29..ff5cd95 100644
--- gcc/testsuite/g++.dg/torture/pr71308.C
+++ 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 ();
+}

	Marek



More information about the Gcc-patches mailing list