[committed] Fix ICE in cleanup_omp_return (PR c++/42234)
Jakub Jelinek
jakub@redhat.com
Tue Dec 1 19:57:00 GMT 2009
Hi!
The attached testcase ICEd on the 4.4 branch because the block preceeding
GIMPLE_OMP_RETURN was empty and thus last_stmt returned NULL.
While 4.5 doesn't ICE on this testcase, it has the same problem latently.
Bootstrapped/regtested on x86_64-linux, committed to trunk/4.4.
2009-12-01 Jakub Jelinek <jakub@redhat.com>
PR c++/42234
* tree-cfgcleanup.c (cleanup_omp_return): Don't ICE if control_bb
contains no statements.
* g++.dg/gomp/pr42234.C: New test.
--- gcc/tree-cfgcleanup.c.jj 2009-04-24 21:41:34.000000000 +0200
+++ gcc/tree-cfgcleanup.c 2009-12-01 14:46:43.000000000 +0100
@@ -1,5 +1,5 @@
/* CFG cleanup for trees.
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
This file is part of GCC.
@@ -517,7 +517,7 @@ cleanup_omp_return (basic_block bb)
control_bb = single_pred (bb);
stmt = last_stmt (control_bb);
- if (gimple_code (stmt) != GIMPLE_OMP_SECTIONS_SWITCH)
+ if (stmt == NULL || gimple_code (stmt) != GIMPLE_OMP_SECTIONS_SWITCH)
return false;
/* The block with the control statement normally has two entry edges -- one
--- gcc/testsuite/g++.dg/gomp/pr42234.C.jj 2009-12-01 14:49:26.000000000 +0100
+++ gcc/testsuite/g++.dg/gomp/pr42234.C 2009-12-01 14:49:10.000000000 +0100
@@ -0,0 +1,19 @@
+// PR c++/42234
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+extern int foo (void);
+
+void
+bar (int x)
+{
+ #pragma omp critical
+ {
+ int j;
+ for (j = 0; j < foo (); j++)
+ ;
+ if (0)
+ if (x >= 4)
+ ;
+ }
+}
Jakub
More information about the Gcc-patches
mailing list