diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2022-11-28 11:08:32 +0100 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2022-11-28 11:10:31 +0100 |
commit | 091b6dbc48177fa3ef15d62ea280ef6cb61c05b2 (patch) | |
tree | 7c35223e5916d2a9bb840ee6ef8ab3c19b02c1b3 /gcc/fortran/parse.cc | |
parent | 5dd4d2e93e3de60d4ef1068b6dfd06b6b9fff16e (diff) | |
download | gcc-091b6dbc48177fa3ef15d62ea280ef6cb61c05b2.zip gcc-091b6dbc48177fa3ef15d62ea280ef6cb61c05b2.tar.gz gcc-091b6dbc48177fa3ef15d62ea280ef6cb61c05b2.tar.bz2 |
OpenMP/Fortran: Permit end-clause on directive
gcc/fortran/ChangeLog:
* openmp.cc (OMP_DO_CLAUSES, OMP_SCOPE_CLAUSES,
OMP_SECTIONS_CLAUSES): Add 'nowait'.
(OMP_SINGLE_CLAUSES): Add 'nowait' and 'copyprivate'.
(gfc_match_omp_distribute_parallel_do,
gfc_match_omp_distribute_parallel_do_simd,
gfc_match_omp_parallel_do,
gfc_match_omp_parallel_do_simd,
gfc_match_omp_parallel_sections,
gfc_match_omp_teams_distribute_parallel_do,
gfc_match_omp_teams_distribute_parallel_do_simd): Disallow 'nowait'.
(gfc_match_omp_workshare): Match 'nowait' clause.
(gfc_match_omp_end_single): Use clause matcher for 'nowait'.
(resolve_omp_clauses): Reject 'nowait' + 'copyprivate'.
* parse.cc (decode_omp_directive): Break too long line.
(parse_omp_do, parse_omp_structured_block): Diagnose duplicated
'nowait' clause.
libgomp/ChangeLog:
* libgomp.texi (OpenMP 5.2): Mark end-directive as Y.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/copyprivate-1.f90: New test.
* gfortran.dg/gomp/copyprivate-2.f90: New test.
* gfortran.dg/gomp/nowait-2.f90: Move dg-error tests ...
* gfortran.dg/gomp/nowait-4.f90: ... to this new file.
* gfortran.dg/gomp/nowait-5.f90: New test.
* gfortran.dg/gomp/nowait-6.f90: New test.
* gfortran.dg/gomp/nowait-7.f90: New test.
* gfortran.dg/gomp/nowait-8.f90: New test.
Diffstat (limited to 'gcc/fortran/parse.cc')
-rw-r--r-- | gcc/fortran/parse.cc | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc index f04fd13..51ff0fc 100644 --- a/gcc/fortran/parse.cc +++ b/gcc/fortran/parse.cc @@ -942,7 +942,8 @@ decode_omp_directive (void) matchs ("end ordered", gfc_match_omp_eos_error, ST_OMP_END_ORDERED); matchs ("end parallel do simd", gfc_match_omp_eos_error, ST_OMP_END_PARALLEL_DO_SIMD); - matcho ("end parallel do", gfc_match_omp_eos_error, ST_OMP_END_PARALLEL_DO); + matcho ("end parallel do", gfc_match_omp_eos_error, + ST_OMP_END_PARALLEL_DO); matcho ("end parallel loop", gfc_match_omp_eos_error, ST_OMP_END_PARALLEL_LOOP); matcho ("end parallel masked taskloop simd", gfc_match_omp_eos_error, @@ -5305,7 +5306,13 @@ parse_omp_do (gfc_statement omp_st) if (st == omp_end_st) { if (new_st.op == EXEC_OMP_END_NOWAIT) - cp->ext.omp_clauses->nowait |= new_st.ext.omp_bool; + { + if (cp->ext.omp_clauses->nowait && new_st.ext.omp_bool) + gfc_error_now ("Duplicated NOWAIT clause on %s and %s at %C", + gfc_ascii_statement (omp_st), + gfc_ascii_statement (omp_end_st)); + cp->ext.omp_clauses->nowait |= new_st.ext.omp_bool; + } else gcc_assert (new_st.op == EXEC_NOP); gfc_clear_new_st (); @@ -5745,6 +5752,10 @@ parse_omp_structured_block (gfc_statement omp_st, bool workshare_stmts_only) switch (new_st.op) { case EXEC_OMP_END_NOWAIT: + if (cp->ext.omp_clauses->nowait && new_st.ext.omp_bool) + gfc_error_now ("Duplicated NOWAIT clause on %s and %s at %C", + gfc_ascii_statement (omp_st), + gfc_ascii_statement (omp_end_st)); cp->ext.omp_clauses->nowait |= new_st.ext.omp_bool; break; case EXEC_OMP_END_CRITICAL: @@ -5759,8 +5770,22 @@ parse_omp_structured_block (gfc_statement omp_st, bool workshare_stmts_only) new_st.ext.omp_name = NULL; break; case EXEC_OMP_END_SINGLE: - cp->ext.omp_clauses->lists[OMP_LIST_COPYPRIVATE] - = new_st.ext.omp_clauses->lists[OMP_LIST_COPYPRIVATE]; + if (cp->ext.omp_clauses->nowait && new_st.ext.omp_clauses->nowait) + gfc_error_now ("Duplicated NOWAIT clause on %s and %s at %C", + gfc_ascii_statement (omp_st), + gfc_ascii_statement (omp_end_st)); + cp->ext.omp_clauses->nowait |= new_st.ext.omp_clauses->nowait; + if (cp->ext.omp_clauses->lists[OMP_LIST_COPYPRIVATE]) + { + gfc_omp_namelist *nl; + for (nl = cp->ext.omp_clauses->lists[OMP_LIST_COPYPRIVATE]; + nl->next; nl = nl->next); + ; + nl->next = new_st.ext.omp_clauses->lists[OMP_LIST_COPYPRIVATE]; + } + else + cp->ext.omp_clauses->lists[OMP_LIST_COPYPRIVATE] + = new_st.ext.omp_clauses->lists[OMP_LIST_COPYPRIVATE]; new_st.ext.omp_clauses->lists[OMP_LIST_COPYPRIVATE] = NULL; gfc_free_omp_clauses (new_st.ext.omp_clauses); break; |