https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122508

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Paul-Antoine Arras <[email protected]>:

https://gcc.gnu.org/g:7fa8420170b7a8ca40d7414ddcddaed425442cee

commit r16-5027-g7fa8420170b7a8ca40d7414ddcddaed425442cee
Author: Paul-Antoine Arras <[email protected]>
Date:   Tue Oct 28 17:27:47 2025 +0100

    OpenMP/Fortran: Revamp handling of labels in metadirectives
[PR122369,PR122508]

    When a label is matched in the first statement after the end of a
metadirective
    body, it is bound to the associated region. However this prevents it from
being
    referenced elsewhere.
    This patch fixes it by rebinding such labels to the outer region. It also
    ensures that labels defined in an outer region can be referenced in a
    metadirective body.

            PR fortran/122369
            PR fortran/122508

    gcc/fortran/ChangeLog:
            * gfortran.h (gfc_rebind_label): Declare new function.
            * parse.cc (parse_omp_metadirective_body): Rebind labels to the
outer
            region. Maintain a vector of metadirective regions.
            (gfc_parse_file): Initialise it.
            * parse.h (GFC_PARSE_H): Declare it.
            * symbol.cc (gfc_get_st_label): Look for existing labels in outer
            metadirective regions.
            (gfc_rebind_label): Define new function.
            (gfc_define_st_label): Accept duplicate labels in metadirective
body.
            (gfc_reference_st_label): Accept shared DO termination labels in
            metadirective body.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/gomp/pr122369-1.f90: New test.
            * gfortran.dg/gomp/pr122369-2.f90: New test.
            * gfortran.dg/gomp/pr122369-3.f90: New test.
            * gfortran.dg/gomp/pr122369-4.f90: New test.
            * gfortran.dg/gomp/pr122508-1.f90: New test.
            * gfortran.dg/gomp/pr122508-2.f90: New test.

Reply via email to