]> git.ipfire.org Git - thirdparty/gcc.git/commit
openmp: Eliminate non-matching metadirective variants early in Fortran front-end
authorKwok Cheung Yeung <kcy@codesourcery.com>
Fri, 11 Feb 2022 11:20:18 +0000 (11:20 +0000)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Mon, 14 Feb 2022 15:54:22 +0000 (15:54 +0000)
commit38ed9d83b893df0bbd098c7b44dbbeb56ed7dd1c
tree02f6f4792dde7fb1a714f75cfd31a2c15593783f
parent5359f8058bfa669a60b07151bbffb1595152ce7e
openmp: Eliminate non-matching metadirective variants early in Fortran front-end

This patch checks during parsing if a metadirective selector is both
resolvable and non-matching - if so, it is removed from further
consideration.  This is both more efficient, and avoids spurious
syntax errors caused by considering combinations of selectors that
lead to invalid combinations of OpenMP directives, when that
combination would never arise in the first place.

This exposes another bug - when metadirectives that are not of the
begin-end variety are nested, we might have to drill up through
multiple layers of the state stack to reach the state for the
next statement.  This is now fixed.

2022-02-11  Kwok Cheung Yeung  <kcy@codesourcery.com>

gcc/
* omp-general.c (DELAY_METADIRECTIVES_AFTER_LTO): Check that cfun is
non-null before derefencing.

gcc/fortran/
* decl.c (gfc_match_end): Search for first previous state that is not
COMP_OMP_METADIRECTIVE.
* gfortran.h (gfc_skip_omp_metadirective_clause): Add prototype.
* openmp.c (match_omp_metadirective): Skip clause if
result of gfc_skip_omp_metadirective_clause is true.
* trans-openmp.c (gfc_trans_omp_set_selector): Add argument and
disable expression conversion if false.
(gfc_skip_omp_metadirective_clause): New.

gcc/testsuite/
* gfortran.dg/gomp/metadirective-8.f90: New.
gcc/ChangeLog.omp
gcc/fortran/ChangeLog.omp
gcc/fortran/decl.c
gcc/fortran/gfortran.h
gcc/fortran/openmp.c
gcc/fortran/trans-openmp.c
gcc/omp-general.c
gcc/testsuite/ChangeLog.omp
gcc/testsuite/gfortran.dg/gomp/metadirective-8.f90 [new file with mode: 0644]