}
else if (gfc_match ("ancestor : ") == MATCH_YES)
{
+ bool has_requires = false;
c->ancestor = true;
- if (!(gfc_current_ns->omp_requires & OMP_REQ_REVERSE_OFFLOAD))
+ for (gfc_namespace *ns = gfc_current_ns; ns; ns = ns->parent)
+ if (ns->omp_requires & OMP_REQ_REVERSE_OFFLOAD)
+ {
+ has_requires = true;
+ break;
+ }
+ if (!has_requires)
{
gfc_error ("%<ancestor%> device modifier not "
"preceded by %<requires%> directive "
--- /dev/null
+! { dg-do compile }
+!
+! Check that a requires directive is still recognized
+! if it is in the associated parent namespace of the
+! target directive.
+!
+
+module m
+ !$omp requires reverse_offload ! { dg-error "REQUIRES directive is not yet supported" }
+contains
+ subroutine foo()
+ !$omp target device(ancestor:1)
+ !$omp end target
+ end subroutine foo
+
+ subroutine bar()
+ block
+ block
+ block
+ !$omp target device(ancestor:1)
+ !$omp end target
+ end block
+ end block
+ end block
+ end subroutine bar
+end module m
+
+subroutine foo()
+ !$omp requires reverse_offload ! { dg-error "REQUIRES directive is not yet supported" }
+ block
+ block
+ block
+ !$omp target device(ancestor:1)
+ !$omp end target
+ end block
+ end block
+ end block
+contains
+ subroutine bar()
+ block
+ block
+ block
+ !$omp target device(ancestor:1)
+ !$omp end target
+ end block
+ end block
+ end block
+ end subroutine bar
+end subroutine foo
+
+program main
+ !$omp requires reverse_offload ! { dg-error "REQUIRES directive is not yet supported" }
+contains
+ subroutine foo()
+ !$omp target device(ancestor:1)
+ !$omp end target
+ end subroutine foo
+
+ subroutine bar()
+ block
+ block
+ block
+ !$omp target device(ancestor:1)
+ !$omp end target
+ end block
+ end block
+ end block
+ end subroutine bar
+end