{
gfc_omp_clauses *c;
if (gfc_match_omp_clauses (&c, mask, true, true, false, false,
- (op == EXEC_OMP_TARGET)) != MATCH_YES)
+ op == EXEC_OMP_TARGET) != MATCH_YES)
return MATCH_ERROR;
new_st.op = op;
new_st.ext.omp_clauses = c;
tree copy = copy_var_decl (var, name, type);
DECL_CONTEXT (copy) = current_function_decl;
- DECL_CHAIN (copy) = ctx->block_vars;
+
+ if (ctx)
+ {
+ DECL_CHAIN (copy) = ctx->block_vars;
+ ctx->block_vars = copy;
+ }
+ else
+ record_vars (copy);
+
/* If VAR is listed in task_shared_vars, it means it wasn't
originally addressable and is just because task needs to take
it's address. But we don't need to take address of privatizations
|| (global_nonaddressable_vars
&& bitmap_bit_p (global_nonaddressable_vars, DECL_UID (var)))))
TREE_ADDRESSABLE (copy) = 0;
- ctx->block_vars = copy;
return copy;
}
gcc_assert (DECL_P (t));
}
tree at = t;
- omp_context *scan_ctx = ctx;
if (ctx->outer)
- {
- scan_omp_op (&at, ctx->outer);
- scan_ctx = ctx->outer;
- }
- tree nt = omp_copy_decl_1 (at, scan_ctx);
+ scan_omp_op (&at, ctx->outer);
+ tree nt = omp_copy_decl_1 (at, ctx->outer);
splay_tree_insert (ctx->field_map,
(splay_tree_key) &DECL_CONTEXT (t),
(splay_tree_value) nt);
if (is_omp_target (ctx->stmt))
{
tree at = decl;
- omp_context *scan_ctx = ctx;
if (ctx->outer)
- {
- scan_omp_op (&at, ctx->outer);
- scan_ctx = ctx->outer;
- }
- tree nt = omp_copy_decl_1 (at, scan_ctx);
+ scan_omp_op (&at, ctx->outer);
+ tree nt = omp_copy_decl_1 (at, ctx->outer);
splay_tree_insert (ctx->field_map,
(splay_tree_key) &DECL_CONTEXT (decl),
(splay_tree_value) nt);
! { dg-do run }
-subroutine foo (x, y)
- integer :: x, y
+module mod1
+ contains
- !$omp taskgroup task_reduction (+: x, y)
+ subroutine foo (x, y)
+ integer :: x, y
- !$omp target in_reduction (+: x, y)
- x = x + 8
- y = y + 16
- !$omp end target
+ !$omp taskgroup task_reduction (+: x, y)
- !$omp task in_reduction (+: x, y)
- x = x + 2
- y = y + 4
- !$omp end task
+ !$omp target in_reduction (+: x, y)
+ x = x + 8
+ y = y + 16
+ !$omp end target
- !$omp end taskgroup
+ !$omp task in_reduction (+: x, y)
+ x = x + 2
+ y = y + 4
+ !$omp end task
+
+ !$omp end taskgroup
+ end subroutine foo
+
+ integer function bar (x)
+ integer, value :: x
+
+ !$omp taskgroup task_reduction (+: x)
+
+ !$omp target in_reduction (+: x)
+ x = x + 16
+ !$omp end target
+
+ !$omp task in_reduction (+: x)
+ x = x + 32
+ !$omp end task
+
+ !$omp end taskgroup
-end subroutine foo
+ bar = x
+ end function bar
+ end module mod1
program main
+ use mod1
integer :: x, y
+ real :: f;
x = 1
y = 1
if (x .ne. 11) stop 1
if (y .ne. 21) stop 2
+ y = bar (8)
+ if (y .ne. 56) stop 3
+
+ x = 0
+ f = 0.0
+
+ !$omp taskgroup task_reduction (+: x, f)
+ !$omp target in_reduction (+: x, f)
+ x = x + 1
+ f = f + 2.0
+ !$omp end target
+
+ !$omp task in_reduction (+: x, f)
+ x = x + 2
+ f = f + 3.0
+ !$omp end task
+
+ !$omp end taskgroup
+
+ if (x .ne. 3) stop 4
+ if (f .ne. 5.0) stop 5
+
end program main