match
gfc_match_omp_declare_variant (void)
{
- bool first_p = true;
char buf[GFC_MAX_SYMBOL_LEN + 1];
if (gfc_match (" (") != MATCH_YES)
return MATCH_ERROR;
}
- bool has_match = false, has_adjust_args = false;
+ bool has_match = false, has_adjust_args = false, error_p = false;
locus adjust_args_loc;
for (;;)
{
+ gfc_gobble_whitespace ();
+ gfc_match_char (',');
+ gfc_gobble_whitespace ();
+
enum clause
{
match,
}
else
{
- if (first_p)
- {
- gfc_error ("expected %<match%> or %<adjust_args%> at %C");
- return MATCH_ERROR;
- }
- else
- break;
+ if (gfc_match_omp_eos () != MATCH_YES)
+ error_p = true;
+ break;
}
if (gfc_match (" (") != MATCH_YES)
for (gfc_omp_namelist *n = *head; n != NULL; n = n->next)
n->u.need_device_ptr = true;
}
+ }
- first_p = false;
+ if (error_p || (!has_match && !has_adjust_args))
+ {
+ gfc_error ("expected %<match%> or %<adjust_args%> at %C");
+ return MATCH_ERROR;
}
if (has_adjust_args && !has_match)
--- /dev/null
+/* { dg-do compile } */
+
+/* Check that the OpenMP 5.1 syntax with commas after the directive name and
+ between clauses is supported. */
+
+int f (int a, void *b, float c[2]);
+
+#pragma omp declare variant (f), match (construct={dispatch}), adjust_args (nothing: a), adjust_args (need_device_ptr: b, c)
+int f0 (int a, void *b, float c[2]);
+
+int test () {
+ int a;
+ void *b;
+ float c[2];
+ struct {int a;} s;
+
+ #pragma omp dispatch, novariants(0), nocontext(1)
+ s.a = f0 (a, b, c);
+
+ return s.a;
+}
--- /dev/null
+! { dg-do compile }
+
+! Check that the OpenMP syntax with commas between clauses is supported.
+! A comma after the directive name is introduced in 5.2, which currently is only
+! partially supported.
+
+module main
+ use iso_c_binding, only: c_ptr
+ implicit none
+
+ type :: struct
+ integer :: a
+ real :: b
+ end type
+
+ interface
+ integer function f(a, b, c)
+ import c_ptr
+ integer, intent(in) :: a
+ type(c_ptr), intent(inout) :: b
+ type(c_ptr), intent(out) :: c(:)
+ end function
+ integer function f0(a, b, c)
+ import c_ptr
+ integer, intent(in) :: a
+ type(c_ptr), intent(inout) :: b
+ type(c_ptr), intent(out) :: c(:)
+ !$omp declare variant (f), match (construct={dispatch}) , &
+ !$omp& adjust_args (nothing: a) ,adjust_args (need_device_ptr: b),adjust_args (need_device_ptr: c)
+ end function
+ end interface
+
+contains
+subroutine test
+ integer :: a
+ type(c_ptr) :: b
+ type(c_ptr) :: c(2)
+ type(struct) :: s
+
+ !!$omp dispatch, nocontext(.false.), novariants(.false.) ! Not supported yet
+ !$omp dispatch nocontext(.false.), novariants(.false.)
+ s%a = f0 (a, b, c)
+
+end subroutine
+end module
subroutine f74 ()
!$omp declare variant (f1) match(construct={requires}) ! { dg-warning "unknown selector 'requires' for context selector set 'construct' at .1." }
end subroutine
- subroutine f75 ()
- !$omp declare variant (f1),match(construct={parallel}) ! { dg-error "expected 'match' or 'adjust_args' at .1." }
+ subroutine f75a ()
+ !$omp declare variant(f1) ,,match(construct={dispatch}) adjust_args(need_device_ptr : c) ! { dg-error "expected 'match' or 'adjust_args' at .1." }
+ end subroutine
+ subroutine f75b ()
+ !$omp declare variant(f1) match(construct={dispatch}),,adjust_args(need_device_ptr : c) ! { dg-error "expected 'match' or 'adjust_args' at .1." }
+ end subroutine
+ subroutine f75c ()
+ !$omp declare variant(f1) match(construct={dispatch}),nowait(a) ! { dg-error "expected 'match' or 'adjust_args' at .1." }
end subroutine
subroutine f76 ()
!$omp declare variant (f1) match(implementation={atomic_default_mem_order("relaxed")}) ! { dg-error "expected identifier at .1." }