OMP_CLAUSE_ATTACH,
OMP_CLAUSE_NOHOST,
OMP_CLAUSE_HAS_DEVICE_ADDR, /* OpenMP 5.1 */
+ OMP_CLAUSE_ENTER, /* OpenMP 5.2 */
/* This must come last. */
OMP_MASK2_LAST
};
continue;
}
break;
+ case 'e':
+ if ((mask & OMP_CLAUSE_ENTER))
+ {
+ m = gfc_match_omp_to_link ("enter (", &c->lists[OMP_LIST_ENTER]);
+ if (m == MATCH_ERROR)
+ goto error;
+ if (m == MATCH_YES)
+ continue;
+ }
+ break;
case 'f':
if ((mask & OMP_CLAUSE_FAIL)
&& (m = gfc_match_dupl_check (c->fail == OMP_MEMORDER_UNSET,
continue;
if ((mask & OMP_CLAUSE_TO) && (mask & OMP_CLAUSE_LINK))
{
- if (gfc_match_omp_to_link ("to (", &c->lists[OMP_LIST_TO])
- == MATCH_YES)
+ /* Declare target: 'to' is an alias for 'enter';
+ 'to' is deprecated since 5.2. */
+ m = gfc_match_omp_to_link ("to (", &c->lists[OMP_LIST_TO]);
+ if (m == MATCH_ERROR)
+ goto error;
+ if (m == MATCH_YES)
continue;
}
else if ((mask & OMP_CLAUSE_TO)
#define OMP_ORDERED_CLAUSES \
(omp_mask (OMP_CLAUSE_THREADS) | OMP_CLAUSE_SIMD)
#define OMP_DECLARE_TARGET_CLAUSES \
- (omp_mask (OMP_CLAUSE_TO) | OMP_CLAUSE_LINK | OMP_CLAUSE_DEVICE_TYPE)
+ (omp_mask (OMP_CLAUSE_ENTER) | OMP_CLAUSE_LINK | OMP_CLAUSE_DEVICE_TYPE \
+ | OMP_CLAUSE_TO)
#define OMP_ATOMIC_CLAUSES \
(omp_mask (OMP_CLAUSE_ATOMIC) | OMP_CLAUSE_CAPTURE | OMP_CLAUSE_HINT \
| OMP_CLAUSE_MEMORDER | OMP_CLAUSE_COMPARE | OMP_CLAUSE_FAIL \
{
c = gfc_get_omp_clauses ();
gfc_current_locus = old_loc;
- m = gfc_match_omp_to_link (" (", &c->lists[OMP_LIST_TO]);
+ m = gfc_match_omp_to_link (" (", &c->lists[OMP_LIST_ENTER]);
if (m != MATCH_YES)
goto syntax;
if (gfc_match_omp_eos () != MATCH_YES)
gfc_buffer_error (false);
- for (list = OMP_LIST_TO; list != OMP_LIST_NUM;
- list = (list == OMP_LIST_TO ? OMP_LIST_LINK : OMP_LIST_NUM))
+ static const int to_enter_link_lists[]
+ = { OMP_LIST_TO, OMP_LIST_ENTER, OMP_LIST_LINK };
+ for (size_t listn = 0; listn < ARRAY_SIZE (to_enter_link_lists)
+ && (list = to_enter_link_lists[listn], true); ++listn)
for (n = c->lists[list]; n; n = n->next)
if (n->sym)
n->sym->mark = 0;
else if (n->u.common->head)
n->u.common->head->mark = 0;
- for (list = OMP_LIST_TO; list != OMP_LIST_NUM;
- list = (list == OMP_LIST_TO ? OMP_LIST_LINK : OMP_LIST_NUM))
+ for (size_t listn = 0; listn < ARRAY_SIZE (to_enter_link_lists)
+ && (list = to_enter_link_lists[listn], true); ++listn)
for (n = c->lists[list]; n; n = n->next)
if (n->sym)
{
if (n->sym->attr.in_common)
gfc_error_now ("OMP DECLARE TARGET variable at %L is an "
"element of a COMMON block", &n->where);
+ else if (n->sym->mark)
+ gfc_error_now ("Variable at %L mentioned multiple times in "
+ "clauses of the same OMP DECLARE TARGET directive",
+ &n->where);
else if (n->sym->attr.omp_declare_target
&& n->sym->attr.omp_declare_target_link
&& list != OMP_LIST_LINK)
gfc_error_now ("OMP DECLARE TARGET variable at %L previously "
- "mentioned in LINK clause and later in TO clause",
- &n->where);
+ "mentioned in LINK clause and later in %s clause",
+ &n->where, list == OMP_LIST_TO ? "TO" : "ENTER");
else if (n->sym->attr.omp_declare_target
&& !n->sym->attr.omp_declare_target_link
&& list == OMP_LIST_LINK)
gfc_error_now ("OMP DECLARE TARGET variable at %L previously "
- "mentioned in TO clause and later in LINK clause",
- &n->where);
- else if (n->sym->mark)
- gfc_error_now ("Variable at %L mentioned multiple times in "
- "clauses of the same OMP DECLARE TARGET directive",
- &n->where);
+ "mentioned in TO or ENTER clause and later in "
+ "LINK clause", &n->where);
else if (gfc_add_omp_declare_target (&n->sym->attr, n->sym->name,
&n->sym->declared_at))
{
&& n->u.common->omp_declare_target_link
&& list != OMP_LIST_LINK)
gfc_error_now ("OMP DECLARE TARGET COMMON at %L previously "
- "mentioned in LINK clause and later in TO clause",
- &n->where);
+ "mentioned in LINK clause and later in %s clause",
+ &n->where, list == OMP_LIST_TO ? "TO" : "ENTER");
else if (n->u.common->omp_declare_target
&& !n->u.common->omp_declare_target_link
&& list == OMP_LIST_LINK)
gfc_error_now ("OMP DECLARE TARGET COMMON at %L previously "
- "mentioned in TO clause and later in LINK clause",
- &n->where);
+ "mentioned in TO or ENTER clause and later in "
+ "LINK clause", &n->where);
else if (n->u.common->head && n->u.common->head->mark)
gfc_error_now ("COMMON at %L mentioned multiple times in "
"clauses of the same OMP DECLARE TARGET directive",
s->attr.omp_device_type = c->device_type;
}
}
- if (c->device_type && !c->lists[OMP_LIST_TO] && !c->lists[OMP_LIST_LINK])
+ if (c->device_type
+ && !c->lists[OMP_LIST_ENTER]
+ && !c->lists[OMP_LIST_TO]
+ && !c->lists[OMP_LIST_LINK])
gfc_warning_now (0, "OMP DECLARE TARGET directive at %L with only "
"DEVICE_TYPE clause is ignored", &old_loc);
"IN_REDUCTION", "TASK_REDUCTION",
"DEVICE_RESIDENT", "LINK", "USE_DEVICE",
"CACHE", "IS_DEVICE_PTR", "USE_DEVICE_PTR", "USE_DEVICE_ADDR",
- "NONTEMPORAL", "ALLOCATE", "HAS_DEVICE_ADDR" };
+ "NONTEMPORAL", "ALLOCATE", "HAS_DEVICE_ADDR", "ENTER" };
STATIC_ASSERT (ARRAY_SIZE (clause_names) == OMP_LIST_NUM);
if (omp_clauses == NULL)
! { dg-do compile }
module declare_target_2
- !$omp declare target to (a) link (a) ! { dg-error "TO clause and later in LINK" }
+ !$omp declare target to (a) link (a) ! { dg-error "mentioned multiple times in clauses of the same OMP DECLARE TARGET directive" }
!$omp declare target (b)
- !$omp declare target link (b) ! { dg-error "TO clause and later in LINK" }
+ !$omp declare target link (b) ! { dg-error "TO or ENTER clause and later in LINK" }
!$omp declare target link (f)
!$omp declare target to (f) ! { dg-error "LINK clause and later in TO" }
!$omp declare target(c, c) ! { dg-error "mentioned multiple times in clauses of the same" }
!$omp declare target to (/c2/)
!$omp declare target (/c2/)
!$omp declare target to(/c2/)
- !$omp declare target link(/c2/) ! { dg-error "TO clause and later in LINK" }
+ !$omp declare target link(/c2/) ! { dg-error "TO or ENTER clause and later in LINK" }
!$omp declare target link(/c3/)
- !$omp declare target (/c3/) ! { dg-error "LINK clause and later in TO" }
+ !$omp declare target (/c3/) ! { dg-error "LINK clause and later in ENTER" }
!$omp declare target (/c4/, /c4/) ! { dg-error "mentioned multiple times in clauses of the same" }
!$omp declare target to (/c4/) to(/c4/) ! { dg-error "mentioned multiple times in clauses of the same" }
!$omp declare target link (/c5/)
!$omp declare target link(/c5/)link(/c5/) ! { dg-error "mentioned multiple times in clauses of the same" }
!$omp declare target link(/c5/,/c5/) ! { dg-error "mentioned multiple times in clauses of the same" }
end subroutine
+
+module declare_target_3
+ !$omp declare target enter (a) link (a) ! { dg-error "mentioned multiple times in clauses of the same OMP DECLARE TARGET directive" }
+ !$omp declare target link(b) enter(b) ! { dg-error "mentioned multiple times in clauses of the same OMP DECLARE TARGET directive" }
+ !$omp declare target to (c) enter (c) ! { dg-error "mentioned multiple times in clauses of the same" }
+ !$omp declare target enter (d) to (d) ! { dg-error "mentioned multiple times in clauses of the same" }
+ !$omp declare target enter (e) enter (e) ! { dg-error "mentioned multiple times in clauses of the same" }
+ integer, save :: a, b, c, d, e
+end
+
!$omp declare target device_type (nohost) to (f5)
end subroutine
+subroutine f6
+ !$omp declare target enter (f6) device_type (any)
+end subroutine
+
module mymod
! device_type is ignored for variables in OpenMP 5.0
! but TR8 and later apply those rules to variables as well
public :: m, n, o, p, q, r, s, t, u, v, w, x
end module m2
-! { dg-final { scan-tree-dump-times "omp declare target" 7 "original" } }
-! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(" 7 "original" } }
+! { dg-final { scan-tree-dump-times "omp declare target" 8 "original" } }
+! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(" 8 "original" } }
! { dg-final { scan-tree-dump-not "__attribute__\\(\\(omp declare target \[^\n\r\]*\[\n\r\]void f1" "original" } }
! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(any\\)\\)\\)\\)\[\n\r]__attribute__\[^\n\r]+\[\n\r]void f2" 1 "original" } }
! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(any\\)\\)\\)\\)\[\n\r]__attribute__\[^\n\r]+\[\n\r\]void f3" 1 "original" } }
! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(host\\)\\)\\)\\)\[\n\r]__attribute__\[^\n\r]+\[\n\r\]void f4" 1 "original" } }
! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(nohost\\)\\)\\)\\)\[\n\r]__attribute__\[^\n\r]+\[\n\r\]void f5" 1 "original" } }
+! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(any\\)\\)\\)\\)\[\n\r]__attribute__\[^\n\r]+\[\n\r]void f6" 1 "original" } }
! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(any\\)\\)\\)\\)\[\n\r]__attribute__\[^\n\r]+\[\n\r\]void s1" 1 "original" } }
! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(nohost\\)\\)\\)\\)\[\n\r]__attribute__\[^\n\r]+\[\n\r\]void s2" 1 "original" } }
! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare target \\(device_type\\(host\\)\\)\\)\\)\[\n\r]__attribute__\[^\n\r]+\[\n\r\]void s3" 1 "original" } }