@@ -4001,10 +4001,7 @@ gfc_trans_omp_parallel_workshare (gfc_co
code->loc);
pushlevel ();
stmt = gfc_trans_omp_workshare (code, &workshare_clauses);
- if (TREE_CODE (stmt) != BIND_EXPR)
- stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0));
- else
- poplevel (0, 0);
+ stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0));
stmt = build2_loc (input_location, OMP_PARALLEL, void_type_node, stmt,
omp_clauses);
OMP_PARALLEL_COMBINED (stmt) = 1;
@@ -0,0 +1,16 @@
+! PR fortran/77352
+! { dg-do compile }
+! { dg-additional-options "-fstack-arrays -O2" }
+! { dg-additional-options "-fopenacc" { target fopenacc } }
+
+program pr77352
+ real, allocatable :: a(:,:), b(:)
+ integer :: m, n
+ m = 4
+ n = 2
+ allocate (a(m,n), b(m))
+ a = 1.0
+!$omp parallel workshare
+ b(:) = [ sum(a, dim=1) ]
+!$omp end parallel workshare
+end