aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/openmp.c
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2021-08-23 15:18:37 +0200
committerTobias Burnus <tobias@codesourcery.com>2021-08-23 15:29:49 +0200
commit57a9e63c96fca56299d7a52f6712e2d9290c197e (patch)
treed9b0762fcf800567baa0cce7cfebc57ef8ea30e4 /gcc/fortran/openmp.c
parentd4de7e32eff0a6363defa50b052d7a30548b6552 (diff)
downloadgcc-57a9e63c96fca56299d7a52f6712e2d9290c197e.zip
gcc-57a9e63c96fca56299d7a52f6712e2d9290c197e.tar.gz
gcc-57a9e63c96fca56299d7a52f6712e2d9290c197e.tar.bz2
Fortran/OpenMP: Improve duplicate errors
gcc/fortran/ChangeLog: * openmp.c (gfc_match_dupl_check, gfc_match_dupl_memorder, gfc_match_dupl_atomic): New. (gfc_match_omp_clauses): Use them; remove duplicate 'release'/'relaxed' clause matching; improve error dignostic for 'default'. gcc/testsuite/ChangeLog: * gfortran.dg/goacc/asyncwait-1.f95: Update dg-error. * gfortran.dg/goacc/default-2.f: Update dg-error. * gfortran.dg/goacc/enter-exit-data.f95: Update dg-error. * gfortran.dg/goacc/if.f95: Update dg-error. * gfortran.dg/goacc/parallel-kernels-clauses.f95: Update dg-error. * gfortran.dg/goacc/routine-6.f90: Update dg-error. * gfortran.dg/goacc/sie.f95: Update dg-error. * gfortran.dg/goacc/update-if_present-2.f90: Update dg-error. * gfortran.dg/gomp/cancel-2.f90: Update dg-error. * gfortran.dg/gomp/declare-simd-1.f90: Update dg-error. * gfortran.dg/gomp/error-3.f90: Update dg-error. * gfortran.dg/gomp/loop-2.f90: Update dg-error. * gfortran.dg/gomp/masked-2.f90: Update dg-error.
Diffstat (limited to 'gcc/fortran/openmp.c')
-rw-r--r--gcc/fortran/openmp.c627
1 files changed, 403 insertions, 224 deletions
diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index 1aae35a..715fd32 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -1289,6 +1289,64 @@ gfc_match_omp_clause_reduction (char pc, gfc_omp_clauses *c, bool openacc,
return MATCH_YES;
}
+
+/* Match with duplicate check. Matches 'name'. If expr != NULL, it
+ then matches '(expr)', otherwise, if open_parens is true,
+ it matches a ' ( ' after 'name'.
+ dupl_message requires '%qs %L' - and is used by
+ gfc_match_dupl_memorder and gfc_match_dupl_atomic. */
+
+static match
+gfc_match_dupl_check (bool not_dupl, const char *name, bool open_parens = false,
+ gfc_expr **expr = NULL, const char *dupl_msg = NULL)
+{
+ match m;
+ locus old_loc = gfc_current_locus;
+ if ((m = gfc_match (name)) != MATCH_YES)
+ return m;
+ if (!not_dupl)
+ {
+ if (dupl_msg)
+ gfc_error (dupl_msg, name, &old_loc);
+ else
+ gfc_error ("Duplicated %qs clause at %L", name, &old_loc);
+ return MATCH_ERROR;
+ }
+ if (open_parens || expr)
+ {
+ if (gfc_match (" ( ") != MATCH_YES)
+ {
+ gfc_error ("Expected %<(%> after %qs at %C", name);
+ return MATCH_ERROR;
+ }
+ if (expr)
+ {
+ if (gfc_match ("%e )", expr) != MATCH_YES)
+ {
+ gfc_error ("Invalid expression after %<%s(%> at %C", name);
+ return MATCH_ERROR;
+ }
+ }
+ }
+ return MATCH_YES;
+}
+
+static match
+gfc_match_dupl_memorder (bool not_dupl, const char *name)
+{
+ return gfc_match_dupl_check (not_dupl, name, false, NULL,
+ "Duplicated memory-order clause: unexpected %s "
+ "clause at %L");
+}
+
+static match
+gfc_match_dupl_atomic (bool not_dupl, const char *name)
+{
+ return gfc_match_dupl_check (not_dupl, name, false, NULL,
+ "Duplicated atomic clause: unexpected %s "
+ "clause at %L");
+}
+
/* Match OpenMP and OpenACC directive clauses. MASK is a bitmask of
clauses that are allowed for a particular directive. */
@@ -1323,6 +1381,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
gfc_omp_namelist **head;
old_loc = gfc_current_locus;
char pc = gfc_peek_ascii_char ();
+ match m;
switch (pc)
{
case 'a':
@@ -1352,17 +1411,23 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
continue;
}
if ((mask & OMP_CLAUSE_MEMORDER)
- && c->memorder == OMP_MEMORDER_UNSET
- && gfc_match ("acq_rel") == MATCH_YES)
+ && (m = gfc_match_dupl_memorder ((c->memorder
+ == OMP_MEMORDER_UNSET),
+ "acq_rel")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->memorder = OMP_MEMORDER_ACQ_REL;
needs_space = true;
continue;
}
if ((mask & OMP_CLAUSE_MEMORDER)
- && c->memorder == OMP_MEMORDER_UNSET
- && gfc_match ("acquire") == MATCH_YES)
+ && (m = gfc_match_dupl_memorder ((c->memorder
+ == OMP_MEMORDER_UNSET),
+ "acquire")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->memorder = OMP_MEMORDER_ACQUIRE;
needs_space = true;
continue;
@@ -1371,7 +1436,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
&& gfc_match ("affinity ( ") == MATCH_YES)
{
gfc_namespace *ns_iter = NULL, *ns_curr = gfc_current_ns;
- match m = gfc_match_iterator (&ns_iter, true);
+ m = gfc_match_iterator (&ns_iter, true);
if (m == MATCH_ERROR)
break;
if (m == MATCH_YES && gfc_match (" : ") != MATCH_YES)
@@ -1398,9 +1463,11 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
continue;
}
if ((mask & OMP_CLAUSE_AT)
- && c->at == OMP_AT_UNSET
- && gfc_match ("at ( ") == MATCH_YES)
+ && (m = gfc_match_dupl_check (c->at == OMP_AT_UNSET, "at", true))
+ != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
if (gfc_match ("compilation )") == MATCH_YES)
c->at = OMP_AT_COMPILATION;
else if (gfc_match ("execution )") == MATCH_YES)
@@ -1414,11 +1481,12 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
continue;
}
if ((mask & OMP_CLAUSE_ASYNC)
- && !c->async
- && gfc_match ("async") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->async, "async")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->async = true;
- match m = gfc_match (" ( %e )", &c->async_expr);
+ m = gfc_match (" ( %e )", &c->async_expr);
if (m == MATCH_ERROR)
{
gfc_current_locus = old_loc;
@@ -1436,9 +1504,11 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
continue;
}
if ((mask & OMP_CLAUSE_AUTO)
- && !c->par_auto
- && gfc_match ("auto") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->par_auto, "auto"))
+ != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->par_auto = true;
needs_space = true;
continue;
@@ -1452,9 +1522,11 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
break;
case 'b':
if ((mask & OMP_CLAUSE_BIND)
- && c->bind == OMP_BIND_UNSET
- && gfc_match ("bind ( ") == MATCH_YES)
+ && (m = gfc_match_dupl_check (c->bind == OMP_BIND_UNSET, "bind",
+ true)) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
if (gfc_match ("teams )") == MATCH_YES)
c->bind = OMP_BIND_TEAMS;
else if (gfc_match ("parallel )") == MATCH_YES)
@@ -1472,34 +1544,36 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
break;
case 'c':
if ((mask & OMP_CLAUSE_CAPTURE)
- && !c->capture
- && gfc_match ("capture") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->capture, "capture"))
+ != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->capture = true;
needs_space = true;
continue;
}
- if ((mask & OMP_CLAUSE_COLLAPSE)
- && !c->collapse)
+ if (mask & OMP_CLAUSE_COLLAPSE)
{
gfc_expr *cexpr = NULL;
- match m = gfc_match ("collapse ( %e )", &cexpr);
-
- if (m == MATCH_YES)
- {
- int collapse;
- if (gfc_extract_int (cexpr, &collapse, -1))
+ if ((m = gfc_match_dupl_check (!c->collapse, "collapse", true,
+ &cexpr)) != MATCH_NO)
+ {
+ int collapse;
+ if (m == MATCH_ERROR)
+ goto error;
+ if (gfc_extract_int (cexpr, &collapse, -1))
+ collapse = 1;
+ else if (collapse <= 0)
+ {
+ gfc_error_now ("COLLAPSE clause argument not constant "
+ "positive integer at %C");
collapse = 1;
- else if (collapse <= 0)
- {
- gfc_error_now ("COLLAPSE clause argument not"
- " constant positive integer at %C");
- collapse = 1;
- }
- c->collapse = collapse;
- gfc_free_expr (cexpr);
- continue;
- }
+ }
+ gfc_free_expr (cexpr);
+ c->collapse = collapse;
+ continue;
+ }
}
if ((mask & OMP_CLAUSE_COPY)
&& gfc_match ("copy ( ") == MATCH_YES
@@ -1539,28 +1613,6 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
continue;
break;
case 'd':
- if ((mask & OMP_CLAUSE_DEFAULT)
- && c->default_sharing == OMP_DEFAULT_UNKNOWN)
- {
- if (gfc_match ("default ( none )") == MATCH_YES)
- c->default_sharing = OMP_DEFAULT_NONE;
- else if (openacc)
- {
- if (gfc_match ("default ( present )") == MATCH_YES)
- c->default_sharing = OMP_DEFAULT_PRESENT;
- }
- else
- {
- if (gfc_match ("default ( firstprivate )") == MATCH_YES)
- c->default_sharing = OMP_DEFAULT_FIRSTPRIVATE;
- else if (gfc_match ("default ( private )") == MATCH_YES)
- c->default_sharing = OMP_DEFAULT_PRIVATE;
- else if (gfc_match ("default ( shared )") == MATCH_YES)
- c->default_sharing = OMP_DEFAULT_SHARED;
- }
- if (c->default_sharing != OMP_DEFAULT_UNKNOWN)
- continue;
- }
if ((mask & OMP_CLAUSE_DEFAULTMAP)
&& gfc_match ("defaultmap ( ") == MATCH_YES)
{
@@ -1645,6 +1697,43 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
break;
continue;
}
+ if ((mask & OMP_CLAUSE_DEFAULT)
+ && (m = gfc_match_dupl_check (c->default_sharing
+ == OMP_DEFAULT_UNKNOWN, "default",
+ true)) != MATCH_NO)
+ {
+ if (m == MATCH_ERROR)
+ goto error;
+ if (gfc_match ("none") == MATCH_YES)
+ c->default_sharing = OMP_DEFAULT_NONE;
+ else if (openacc)
+ {
+ if (gfc_match ("present") == MATCH_YES)
+ c->default_sharing = OMP_DEFAULT_PRESENT;
+ }
+ else
+ {
+ if (gfc_match ("firstprivate") == MATCH_YES)
+ c->default_sharing = OMP_DEFAULT_FIRSTPRIVATE;
+ else if (gfc_match ("private") == MATCH_YES)
+ c->default_sharing = OMP_DEFAULT_PRIVATE;
+ else if (gfc_match ("shared") == MATCH_YES)
+ c->default_sharing = OMP_DEFAULT_SHARED;
+ }
+ if (c->default_sharing == OMP_DEFAULT_UNKNOWN)
+ {
+ if (openacc)
+ gfc_error ("Expected NONE or PRESENT in DEFAULT clause "
+ "at %C");
+ else
+ gfc_error ("Expected NONE, FIRSTPRIVATE, PRIVATE or SHARED "
+ "in DEFAULT clause at %C");
+ goto error;
+ }
+ if (gfc_match (" )") != MATCH_YES)
+ goto error;
+ continue;
+ }
if ((mask & OMP_CLAUSE_DELETE)
&& gfc_match ("delete ( ") == MATCH_YES
&& gfc_match_omp_map_clause (&c->lists[OMP_LIST_MAP],
@@ -1660,7 +1749,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
break;
if (m_it == MATCH_YES && gfc_match (" , ") != MATCH_YES)
break;
- match m = MATCH_YES;
+ m = MATCH_YES;
gfc_omp_depend_op depend_op = OMP_DEPEND_OUT;
if (gfc_match ("inout") == MATCH_YES)
depend_op = OMP_DEPEND_INOUT;
@@ -1736,9 +1825,13 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
continue;
if ((mask & OMP_CLAUSE_DEVICE)
&& !openacc
- && c->device == NULL
- && gfc_match ("device ( %e )", &c->device) == MATCH_YES)
- continue;
+ && (m = gfc_match_dupl_check (!c->device, "device", true,
+ &c->device)) != MATCH_NO)
+ {
+ if (m == MATCH_ERROR)
+ goto error;
+ continue;
+ }
if ((mask & OMP_CLAUSE_DEVICE)
&& openacc
&& gfc_match ("device ( ") == MATCH_YES
@@ -1779,7 +1872,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
&& c->dist_sched_kind == OMP_SCHED_NONE
&& gfc_match ("dist_schedule ( static") == MATCH_YES)
{
- match m = MATCH_NO;
+ m = MATCH_NO;
c->dist_sched_kind = OMP_SCHED_STATIC;
m = gfc_match (" , %e )", &c->dist_chunk_size);
if (m != MATCH_YES)
@@ -1795,17 +1888,27 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
break;
case 'f':
if ((mask & OMP_CLAUSE_FILTER)
- && c->filter == NULL
- && gfc_match ("filter ( %e )", &c->filter) == MATCH_YES)
- continue;
+ && (m = gfc_match_dupl_check (!c->filter, "filter", true,
+ &c->filter)) != MATCH_NO)
+ {
+ if (m == MATCH_ERROR)
+ goto error;
+ continue;
+ }
if ((mask & OMP_CLAUSE_FINAL)
- && c->final_expr == NULL
- && gfc_match ("final ( %e )", &c->final_expr) == MATCH_YES)
- continue;
+ && (m = gfc_match_dupl_check (!c->final_expr, "final", true,
+ &c->final_expr)) != MATCH_NO)
+ {
+ if (m == MATCH_ERROR)
+ goto error;
+ continue;
+ }
if ((mask & OMP_CLAUSE_FINALIZE)
- && !c->finalize
- && gfc_match ("finalize") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->finalize, "finalize"))
+ != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->finalize = true;
needs_space = true;
continue;
@@ -1823,11 +1926,12 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
break;
case 'g':
if ((mask & OMP_CLAUSE_GANG)
- && !c->gang
- && gfc_match ("gang") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->gang, "gang")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->gang = true;
- match m = match_oacc_clause_gwv (c, GOMP_DIM_GANG);
+ m = match_oacc_clause_gwv (c, GOMP_DIM_GANG);
if (m == MATCH_ERROR)
{
gfc_current_locus = old_loc;
@@ -1838,9 +1942,11 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
continue;
}
if ((mask & OMP_CLAUSE_GRAINSIZE)
- && c->grainsize == NULL
- && gfc_match ("grainsize ( ") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->grainsize, "grainsize", true))
+ != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
if (gfc_match ("strict : ") == MATCH_YES)
c->grainsize_strict = true;
if (gfc_match (" %e )", &c->grainsize) != MATCH_YES)
@@ -1850,9 +1956,13 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
break;
case 'h':
if ((mask & OMP_CLAUSE_HINT)
- && c->hint == NULL
- && gfc_match ("hint ( %e )", &c->hint) == MATCH_YES)
- continue;
+ && (m = gfc_match_dupl_check (!c->hint, "hint", true, &c->hint))
+ != MATCH_NO)
+ {
+ if (m == MATCH_ERROR)
+ goto error;
+ continue;
+ }
if ((mask & OMP_CLAUSE_HOST_SELF)
&& gfc_match ("host ( ") == MATCH_YES
&& gfc_match_omp_map_clause (&c->lists[OMP_LIST_MAP],
@@ -1861,24 +1971,36 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
continue;
break;
case 'i':
+ if ((mask & OMP_CLAUSE_IF_PRESENT)
+ && (m = gfc_match_dupl_check (!c->if_present, "if_present"))
+ != MATCH_NO)
+ {
+ if (m == MATCH_ERROR)
+ goto error;
+ c->if_present = true;
+ needs_space = true;
+ continue;
+ }
if ((mask & OMP_CLAUSE_IF)
- && c->if_expr == NULL
- && gfc_match ("if ( ") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->if_expr, "if", true))
+ != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
if (!openacc)
{
/* This should match the enum gfc_omp_if_kind order. */
static const char *ifs[OMP_IF_LAST] = {
- " cancel : %e )",
- " parallel : %e )",
- " simd : %e )",
- " task : %e )",
- " taskloop : %e )",
- " target : %e )",
- " target data : %e )",
- " target update : %e )",
- " target enter data : %e )",
- " target exit data : %e )" };
+ "cancel : %e )",
+ "parallel : %e )",
+ "simd : %e )",
+ "task : %e )",
+ "taskloop : %e )",
+ "target : %e )",
+ "target data : %e )",
+ "target update : %e )",
+ "target enter data : %e )",
+ "target exit data : %e )" };
int i;
for (i = 0; i < OMP_IF_LAST; i++)
if (c->if_exprs[i] == NULL
@@ -1887,34 +2009,29 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
if (i < OMP_IF_LAST)
continue;
}
- if (gfc_match ("%e )", &c->if_expr) == MATCH_YES)
+ if (gfc_match (" %e )", &c->if_expr) == MATCH_YES)
continue;
- gfc_current_locus = old_loc;
- }
- if ((mask & OMP_CLAUSE_IF_PRESENT)
- && !c->if_present
- && gfc_match ("if_present") == MATCH_YES)
- {
- c->if_present = true;
- needs_space = true;
- continue;
+ goto error;
}
if ((mask & OMP_CLAUSE_IN_REDUCTION)
&& gfc_match_omp_clause_reduction (pc, c, openacc,
allow_derived) == MATCH_YES)
continue;
if ((mask & OMP_CLAUSE_INBRANCH)
- && !c->inbranch
- && !c->notinbranch
- && gfc_match ("inbranch") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->inbranch && !c->notinbranch,
+ "inbranch")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->inbranch = needs_space = true;
continue;
}
if ((mask & OMP_CLAUSE_INDEPENDENT)
- && !c->independent
- && gfc_match ("independent") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->independent, "independent"))
+ != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->independent = true;
needs_space = true;
continue;
@@ -2095,16 +2212,23 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
gfc_current_locus = old_loc;
break;
}
- if ((mask & OMP_CLAUSE_MERGEABLE) && !c->mergeable
- && gfc_match ("mergeable") == MATCH_YES)
+ if ((mask & OMP_CLAUSE_MERGEABLE)
+ && (m = gfc_match_dupl_check (!c->mergeable, "mergeable"))
+ != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->mergeable = needs_space = true;
continue;
}
if ((mask & OMP_CLAUSE_MESSAGE)
- && !c->message
- && gfc_match ("message ( %e )", &c->message) == MATCH_YES)
- continue;
+ && (m = gfc_match_dupl_check (!c->message, "message", true,
+ &c->message)) != MATCH_NO)
+ {
+ if (m == MATCH_ERROR)
+ goto error;
+ continue;
+ }
break;
case 'n':
if ((mask & OMP_CLAUSE_NO_CREATE)
@@ -2114,16 +2238,19 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
allow_derived))
continue;
if ((mask & OMP_CLAUSE_NOGROUP)
- && !c->nogroup
- && gfc_match ("nogroup") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->nogroup, "nogroup"))
+ != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->nogroup = needs_space = true;
continue;
}
if ((mask & OMP_CLAUSE_NOHOST)
- && !c->nohost
- && gfc_match ("nohost") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->nohost, "nohost")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->nohost = needs_space = true;
continue;
}
@@ -2133,29 +2260,38 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
true) == MATCH_YES)
continue;
if ((mask & OMP_CLAUSE_NOTINBRANCH)
- && !c->notinbranch
- && !c->inbranch
- && gfc_match ("notinbranch") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->notinbranch && !c->inbranch,
+ "notinbranch")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->notinbranch = needs_space = true;
continue;
}
if ((mask & OMP_CLAUSE_NOWAIT)
- && !c->nowait
- && gfc_match ("nowait") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->nowait, "nowait")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->nowait = needs_space = true;
continue;
}
if ((mask & OMP_CLAUSE_NUM_GANGS)
- && c->num_gangs_expr == NULL
- && gfc_match ("num_gangs ( %e )",
- &c->num_gangs_expr) == MATCH_YES)
- continue;
+ && (m = gfc_match_dupl_check (!c->num_gangs_expr, "num_gangs",
+ true)) != MATCH_NO)
+ {
+ if (m == MATCH_ERROR)
+ goto error;
+ if (gfc_match (" %e )", &c->num_gangs_expr) != MATCH_YES)
+ goto error;
+ continue;
+ }
if ((mask & OMP_CLAUSE_NUM_TASKS)
- && c->num_tasks == NULL
- && gfc_match ("num_tasks ( ") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->num_tasks, "num_tasks", true))
+ != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
if (gfc_match ("strict : ") == MATCH_YES)
c->num_tasks_strict = true;
if (gfc_match (" %e )", &c->num_tasks) != MATCH_YES)
@@ -2163,19 +2299,30 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
continue;
}
if ((mask & OMP_CLAUSE_NUM_TEAMS)
- && c->num_teams == NULL
- && gfc_match ("num_teams ( %e )", &c->num_teams) == MATCH_YES)
- continue;
+ && (m = gfc_match_dupl_check (!c->num_teams, "num_teams", true,
+ &c->num_teams)) != MATCH_NO)
+ {
+ if (m == MATCH_ERROR)
+ goto error;
+ continue;
+ }
if ((mask & OMP_CLAUSE_NUM_THREADS)
- && c->num_threads == NULL
- && (gfc_match ("num_threads ( %e )", &c->num_threads)
- == MATCH_YES))
- continue;
+ && (m = gfc_match_dupl_check (!c->num_threads, "num_threads", true,
+ &c->num_threads)) != MATCH_NO)
+ {
+ if (m == MATCH_ERROR)
+ goto error;
+ continue;
+ }
if ((mask & OMP_CLAUSE_NUM_WORKERS)
- && c->num_workers_expr == NULL
- && gfc_match ("num_workers ( %e )",
- &c->num_workers_expr) == MATCH_YES)
- continue;
+ && (m = gfc_match_dupl_check (!c->num_workers_expr, "num_workers",
+ true, &c->num_workers_expr))
+ != MATCH_NO)
+ {
+ if (m == MATCH_ERROR)
+ goto error;
+ continue;
+ }
break;
case 'o':
if ((mask & OMP_CLAUSE_ORDER)
@@ -2186,11 +2333,13 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
continue;
}
if ((mask & OMP_CLAUSE_ORDERED)
- && !c->ordered
- && gfc_match ("ordered") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->ordered, "ordered"))
+ != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
gfc_expr *cexpr = NULL;
- match m = gfc_match (" ( %e )", &cexpr);
+ m = gfc_match (" ( %e )", &cexpr);
c->ordered = true;
if (m == MATCH_YES)
@@ -2262,35 +2411,46 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
OMP_MAP_ALLOC, true, allow_derived))
continue;
if ((mask & OMP_CLAUSE_PRIORITY)
- && c->priority == NULL
- && gfc_match ("priority ( %e )", &c->priority) == MATCH_YES)
- continue;
+ && (m = gfc_match_dupl_check (!c->priority, "priority", true,
+ &c->priority)) != MATCH_NO)
+ {
+ if (m == MATCH_ERROR)
+ goto error;
+ continue;
+ }
if ((mask & OMP_CLAUSE_PRIVATE)
&& gfc_match_omp_variable_list ("private (",
&c->lists[OMP_LIST_PRIVATE],
true) == MATCH_YES)
continue;
if ((mask & OMP_CLAUSE_PROC_BIND)
- && c->proc_bind == OMP_PROC_BIND_UNKNOWN)
+ && (m = gfc_match_dupl_check ((c->proc_bind
+ == OMP_PROC_BIND_UNKNOWN),
+ "proc_bind", true)) != MATCH_NO)
{
- /* Primary is new and master is deprecated in OpenMP 5.1. */
- if (gfc_match ("proc_bind ( primary )") == MATCH_YES)
- c->proc_bind = OMP_PROC_BIND_MASTER;
- else if (gfc_match ("proc_bind ( master )") == MATCH_YES)
+ if (m == MATCH_ERROR)
+ goto error;
+ if (gfc_match ("primary )") == MATCH_YES)
+ c->proc_bind = OMP_PROC_BIND_PRIMARY;
+ else if (gfc_match ("master )") == MATCH_YES)
c->proc_bind = OMP_PROC_BIND_MASTER;
- else if (gfc_match ("proc_bind ( spread )") == MATCH_YES)
+ else if (gfc_match ("spread )") == MATCH_YES)
c->proc_bind = OMP_PROC_BIND_SPREAD;
- else if (gfc_match ("proc_bind ( close )") == MATCH_YES)
+ else if (gfc_match ("close )") == MATCH_YES)
c->proc_bind = OMP_PROC_BIND_CLOSE;
- if (c->proc_bind != OMP_PROC_BIND_UNKNOWN)
- continue;
+ else
+ goto error;
+ continue;
}
break;
case 'r':
if ((mask & OMP_CLAUSE_ATOMIC)
- && c->atomic_op == GFC_OMP_ATOMIC_UNSET
- && gfc_match ("read") == MATCH_YES)
+ && (m = gfc_match_dupl_atomic ((c->atomic_op
+ == GFC_OMP_ATOMIC_UNSET),
+ "read")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->atomic_op = GFC_OMP_ATOMIC_READ;
needs_space = true;
continue;
@@ -2300,33 +2460,23 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
allow_derived) == MATCH_YES)
continue;
if ((mask & OMP_CLAUSE_MEMORDER)
- && c->memorder == OMP_MEMORDER_UNSET
- && gfc_match ("relaxed") == MATCH_YES)
- {
- c->memorder = OMP_MEMORDER_RELAXED;
- needs_space = true;
- continue;
- }
- if ((mask & OMP_CLAUSE_MEMORDER)
- && c->memorder == OMP_MEMORDER_UNSET
- && gfc_match ("release") == MATCH_YES)
- {
- c->memorder = OMP_MEMORDER_RELEASE;
- needs_space = true;
- continue;
- }
- if ((mask & OMP_CLAUSE_MEMORDER)
- && c->memorder == OMP_MEMORDER_UNSET
- && gfc_match ("relaxed") == MATCH_YES)
+ && (m = gfc_match_dupl_memorder ((c->memorder
+ == OMP_MEMORDER_UNSET),
+ "relaxed")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->memorder = OMP_MEMORDER_RELAXED;
needs_space = true;
continue;
}
if ((mask & OMP_CLAUSE_MEMORDER)
- && c->memorder == OMP_MEMORDER_UNSET
- && gfc_match ("release") == MATCH_YES)
+ && (m = gfc_match_dupl_memorder ((c->memorder
+ == OMP_MEMORDER_UNSET),
+ "release")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->memorder = OMP_MEMORDER_RELEASE;
needs_space = true;
continue;
@@ -2334,13 +2484,20 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
break;
case 's':
if ((mask & OMP_CLAUSE_SAFELEN)
- && c->safelen_expr == NULL
- && gfc_match ("safelen ( %e )", &c->safelen_expr) == MATCH_YES)
- continue;
+ && (m = gfc_match_dupl_check (!c->safelen_expr, "safelen",
+ true, &c->safelen_expr))
+ != MATCH_NO)
+ {
+ if (m == MATCH_ERROR)
+ goto error;
+ continue;
+ }
if ((mask & OMP_CLAUSE_SCHEDULE)
- && c->sched_kind == OMP_SCHED_NONE
- && gfc_match ("schedule ( ") == MATCH_YES)
+ && (m = gfc_match_dupl_check (c->sched_kind == OMP_SCHED_NONE,
+ "schedule", true)) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
int nmodifiers = 0;
locus old_loc2 = gfc_current_locus;
do
@@ -2387,7 +2544,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
c->sched_kind = OMP_SCHED_AUTO;
if (c->sched_kind != OMP_SCHED_NONE)
{
- match m = MATCH_NO;
+ m = MATCH_NO;
if (c->sched_kind != OMP_SCHED_RUNTIME
&& c->sched_kind != OMP_SCHED_AUTO)
m = gfc_match (" , %e )", &c->chunk_size);
@@ -2408,17 +2565,21 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
allow_derived))
continue;
if ((mask & OMP_CLAUSE_SEQ)
- && !c->seq
- && gfc_match ("seq") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->seq, "seq")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->seq = true;
needs_space = true;
continue;
}
if ((mask & OMP_CLAUSE_MEMORDER)
- && c->memorder == OMP_MEMORDER_UNSET
- && gfc_match ("seq_cst") == MATCH_YES)
+ && (m = gfc_match_dupl_memorder ((c->memorder
+ == OMP_MEMORDER_UNSET),
+ "seq_cst")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->memorder = OMP_MEMORDER_SEQ_CST;
needs_space = true;
continue;
@@ -2429,20 +2590,27 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
true) == MATCH_YES)
continue;
if ((mask & OMP_CLAUSE_SIMDLEN)
- && c->simdlen_expr == NULL
- && gfc_match ("simdlen ( %e )", &c->simdlen_expr) == MATCH_YES)
- continue;
+ && (m = gfc_match_dupl_check (!c->simdlen_expr, "simdlen", true,
+ &c->simdlen_expr)) != MATCH_NO)
+ {
+ if (m == MATCH_ERROR)
+ goto error;
+ continue;
+ }
if ((mask & OMP_CLAUSE_SIMD)
- && !c->simd
- && gfc_match ("simd") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->simd, "simd")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->simd = needs_space = true;
continue;
}
if ((mask & OMP_CLAUSE_SEVERITY)
- && c->severity == OMP_SEVERITY_UNSET
- && gfc_match ("severity ( ") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->severity, "severity", true))
+ != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
if (gfc_match ("fatal )") == MATCH_YES)
c->severity = OMP_SEVERITY_FATAL;
else if (gfc_match ("warning )") == MATCH_YES)
@@ -2462,14 +2630,20 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
allow_derived) == MATCH_YES)
continue;
if ((mask & OMP_CLAUSE_THREAD_LIMIT)
- && c->thread_limit == NULL
- && gfc_match ("thread_limit ( %e )",
- &c->thread_limit) == MATCH_YES)
- continue;
+ && (m = gfc_match_dupl_check (!c->thread_limit, "thread_limit",
+ true, &c->thread_limit))
+ != MATCH_NO)
+ {
+ if (m == MATCH_ERROR)
+ goto error;
+ continue;
+ }
if ((mask & OMP_CLAUSE_THREADS)
- && !c->threads
- && gfc_match ("threads") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->threads, "threads"))
+ != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->threads = needs_space = true;
continue;
}
@@ -2497,16 +2671,20 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
false) == MATCH_YES)
continue;
if ((mask & OMP_CLAUSE_UNTIED)
- && !c->untied
- && gfc_match ("untied") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->untied, "untied")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->untied = needs_space = true;
continue;
}
if ((mask & OMP_CLAUSE_ATOMIC)
- && c->atomic_op == GFC_OMP_ATOMIC_UNSET
- && gfc_match ("update") == MATCH_YES)
+ && (m = gfc_match_dupl_atomic ((c->atomic_op
+ == GFC_OMP_ATOMIC_UNSET),
+ "update")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->atomic_op = GFC_OMP_ATOMIC_UPDATE;
needs_space = true;
continue;
@@ -2531,21 +2709,24 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
/* VECTOR_LENGTH must be matched before VECTOR, because the latter
doesn't unconditionally match '('. */
if ((mask & OMP_CLAUSE_VECTOR_LENGTH)
- && c->vector_length_expr == NULL
- && (gfc_match ("vector_length ( %e )", &c->vector_length_expr)
- == MATCH_YES))
- continue;
+ && (m = gfc_match_dupl_check (!c->vector_length_expr,
+ "vector_length", true,
+ &c->vector_length_expr))
+ != MATCH_NO)
+ {
+ if (m == MATCH_ERROR)
+ goto error;
+ continue;
+ }
if ((mask & OMP_CLAUSE_VECTOR)
- && !c->vector
- && gfc_match ("vector") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->vector, "vector")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->vector = true;
- match m = match_oacc_clause_gwv (c, GOMP_DIM_VECTOR);
+ m = match_oacc_clause_gwv (c, GOMP_DIM_VECTOR);
if (m == MATCH_ERROR)
- {
- gfc_current_locus = old_loc;
- break;
- }
+ goto error;
if (m == MATCH_NO)
needs_space = true;
continue;
@@ -2555,12 +2736,9 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
if ((mask & OMP_CLAUSE_WAIT)
&& gfc_match ("wait") == MATCH_YES)
{
- match m = match_oacc_expr_list (" (", &c->wait_list, false);
+ m = match_oacc_expr_list (" (", &c->wait_list, false);
if (m == MATCH_ERROR)
- {
- gfc_current_locus = old_loc;
- break;
- }
+ goto error;
else if (m == MATCH_NO)
{
gfc_expr *expr
@@ -2578,24 +2756,25 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
continue;
}
if ((mask & OMP_CLAUSE_WORKER)
- && !c->worker
- && gfc_match ("worker") == MATCH_YES)
+ && (m = gfc_match_dupl_check (!c->worker, "worker")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->worker = true;
- match m = match_oacc_clause_gwv (c, GOMP_DIM_WORKER);
+ m = match_oacc_clause_gwv (c, GOMP_DIM_WORKER);
if (m == MATCH_ERROR)
- {
- gfc_current_locus = old_loc;
- break;
- }
+ goto error;
else if (m == MATCH_NO)
needs_space = true;
continue;
}
if ((mask & OMP_CLAUSE_ATOMIC)
- && c->atomic_op == GFC_OMP_ATOMIC_UNSET
- && gfc_match ("write") == MATCH_YES)
+ && (m = gfc_match_dupl_atomic ((c->atomic_op
+ == GFC_OMP_ATOMIC_UNSET),
+ "write")) != MATCH_NO)
{
+ if (m == MATCH_ERROR)
+ goto error;
c->atomic_op = GFC_OMP_ATOMIC_WRITE;
needs_space = true;
continue;