@@ -3317,6 +3317,19 @@ remove_unreachable_handlers (void)
SET_BIT (r_reachable, region->index);
SET_BIT (lp_reachable, lp_nr);
}
+
+ /* Avoid removing regions referenced from RESX/EH_DISPATCH. */
+ switch (gimple_code (stmt))
+ {
+ case GIMPLE_RESX:
+ SET_BIT (r_reachable, gimple_resx_region (stmt));
+ break;
+ case GIMPLE_EH_DISPATCH:
+ SET_BIT (r_reachable, gimple_eh_dispatch_region (stmt));
+ break;
+ default:
+ break;
+ }
}
}
@@ -0,0 +1,12 @@
+! PR tree-optimization/48611
+! { dg-do compile }
+! { dg-options "-Os -fopenmp -fexceptions -fno-tree-ccp -fno-tree-copy-prop" }
+
+ integer, allocatable :: a(:)
+ logical :: l
+!$omp parallel private (a) reduction (.or.:l)
+ do i = 1, 7
+ a(:) = i
+ end do
+!$omp end parallel
+end
@@ -0,0 +1,12 @@
+! PR tree-optimization/48794
+! { dg-do compile }
+! { dg-options "-Os -fopenmp -fexceptions -fno-tree-ccp -fno-tree-copy-prop" }
+
+ integer, allocatable :: a(:)
+ logical :: l
+ if (allocated (a)) call abort
+!$omp parallel private (a) reduction (.or.:l)
+ do i = 1, 7
+ end do
+!$omp end parallel
+end