From 057dd91d0c1df52679f71644d95fea2ae9522f3e Mon Sep 17 00:00:00 2001
From: Jakub Jelinek <jakub@redhat.com>
Date: Tue, 26 Jan 2010 10:47:45 +0100
Subject: [PATCH] re PR fortran/42866 (ICE for REDUCTION with ALLOCATABLE array
 as variable on SECTIONS)

	PR fortran/42866
	* omp-low.c (expand_omp_sections): Only use single_pred if
	l2_bb is single_pred_p.

	* testsuite/libgomp.fortran/allocatable5.f90: New test.

From-SVN: r156235
---
 gcc/ChangeLog                                   |  6 ++++++
 gcc/omp-low.c                                   |  2 +-
 libgomp/ChangeLog                               |  5 +++++
 .../testsuite/libgomp.fortran/allocatable5.f90  | 17 +++++++++++++++++
 4 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 libgomp/testsuite/libgomp.fortran/allocatable5.f90

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ca8d69a9c5c2..b97384aa2acf 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2010-01-26  Jakub Jelinek  <jakub@redhat.com>
+
+	PR fortran/42866
+	* omp-low.c (expand_omp_sections): Only use single_pred if
+	l2_bb is single_pred_p.
+
 2010-01-25  Christian Bruel  <christian.bruel@st.com>
 
 	PR target/42841
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 317003186d17..bb1a86a66489 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -4663,7 +4663,7 @@ expand_omp_sections (struct omp_region *region)
   l2_bb = region->exit;
   if (exit_reachable)
     {
-      if (single_pred (l2_bb) == l0_bb)
+      if (single_pred_p (l2_bb) && single_pred (l2_bb) == l0_bb)
 	l2 = gimple_block_label (l2_bb);
       else
 	{
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index a20b4976aad3..4b20087ff71f 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,8 @@
+2010-01-26  Jakub Jelinek  <jakub@redhat.com>
+
+	PR fortran/42866
+	* testsuite/libgomp.fortran/allocatable5.f90: New test.
+
 2010-01-20  Paolo Bonzini  <bonzini@gnu.org>
 
 	* configure.ac: Test for executability of GFORTRAN.
diff --git a/libgomp/testsuite/libgomp.fortran/allocatable5.f90 b/libgomp/testsuite/libgomp.fortran/allocatable5.f90
new file mode 100644
index 000000000000..41809302413c
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/allocatable5.f90
@@ -0,0 +1,17 @@
+! PR fortran/42866
+! { dg-do run }
+
+program pr42866
+  integer, allocatable :: a(:)
+  allocate (a(16))
+  a = 0
+  !$omp parallel
+    !$omp sections reduction(+:a)
+      a = a + 1
+    !$omp section
+      a = a + 2
+    !$omp end sections
+  !$omp end parallel
+  if (any (a.ne.3)) call abort
+  deallocate (a)
+end
-- 
GitLab