https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106639
Bug ID: 106639 Summary: [OpenMP][5.1] Diagnose when OpenMP declarative directive appears before IMPORT/USE/IMPLICIT Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: accepts-invalid, openmp Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: jakub at gcc dot gnu.org Depends on: 106566 Target Milestone: --- +++ This bug was initially created as a clone of Bug #106566 +++ OpenMP 5.1 added to the glossary entry "declarative directive": "For Fortran, a declarative directive must appear after any USE, IMPORT, and IMPLICIT statements in a declarative context." Before, it was valid everywhere in the specification part. Example: VALID in 5.0 but invalid since 5.1: subroutine add_one2(p) !$omp declare simd(add_one2) linear(p: ref) simdlen(8) implicit none ! <<<< invalid in 5.1 because after '!$omp declare' integer :: p p = p + 1 end subroutine Ignoring OpenMP < 5.1 backward compatibility, the following would do, but gives a hard error for pre-5.1 code. (Plus splitting the '#define case_omp_decl'.) However, I think we rather want to warn (→ backward compat) instead of erroring out → e.g. set a flag and check it in ST_... for IMPORT/IMPLICIT/USE + warn. --- a/gcc/fortran/parse.cc +++ b/gcc/fortran/parse.cc @@ -3021,4 +3026,4 @@ verify_st_order (st_state *p, gfc_statement st, bool silent) - case_omp_decl: - /* The OpenMP/OpenACC directives have to be somewhere in the specification + case_oacc_decl: + /* The OpenACC directives have to be somewhere in the specification part, but there are no further requirements on their ordering. @@ -3029,2 +3034,9 @@ verify_st_order (st_state *p, gfc_statement st, bool silent) + case_omp_decl: + if (p->state >= ORDER_EXEC) + goto order; + if (p->state < ORDER_SPEC) + p->state = ORDER_SPEC; + break; + case_executable: Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106566 [Bug 106566] [OpenMP] declare simd fails with with bogus "already been host associated" for module procedures