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

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:ddeb70548c81f5dba91f281290584698897151d8

commit r15-7824-gddeb70548c81f5dba91f281290584698897151d8
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Wed Mar 5 07:47:52 2025 +0100

    openmp, c++: Fix up OpenMP/OpenACC handling in C++ modules [PR119102]

    modules.cc has apparently support for extensions and attempts to ensure
    that if a module is compiled with those extensions enabled, sources which
    use the module are compiled with the same extensions.
    The only extension supported is SE_OPENMP right now.
    And the use of the extension is keyed on streaming out or in OMP_CLAUSE
    tree.
    This is undesirable for several reasons.
    OMP_CLAUSE is the only tree which can appear in the IL even without
    -fopenmp/-fopenmp-simd/-fopenacc (when simd ("notinbranch") or
    simd ("inbranch") attributes are used), and it can appear also in all
    the 3 modes mentioned above.  On the other side, with the exception of
    arguments of attributes added e.g. for declare simd where no harm should
    be done if -fopenmp/-fopenmp-simd isn't enabled later on, OMP_CLAUSE
appears
    in OMP_*_CLAUSES of OpenMP/OpenACC construct trees.  And those construct
    trees often have no clauses at all, so keying the extension on OMP_CLAUSE
    doesn't catch many cases that should be caught.
    Furthermore, for OpenMP we have 2 modes, -fopenmp-simd which parses some
    OpenMP but constructs from that mostly OMP_SIMD and a few other cases,
    and -fopenmp which includes that and far more on top of that; and there is
    also -fopenacc.

    So, this patch stops setting/requesting the extension on OMP_CLAUSE,
    introduces 3 extensions rather than one (SE_OPENMP_SIMD, SE_OPENMP and
    SE_OPENACC) and keyes those on OpenMP constructs from the -fopenmp-simd
    subset, other OpenMP constructs and OpenACC constructs.

    2025-03-05  Jakub Jelinek  <ja...@redhat.com>

            PR c++/119102
    gcc/cp/
            * module.cc (enum streamed_extensions): Add SE_OPENMP_SIMD
            and SE_OPENACC, change value of SE_OPENMP and SE_BITS.
            (CASE_OMP_SIMD_CODE, CASE_OMP_CODE, CASE_OACC_CODE): Define.
            (trees_out::start): Don't set SE_OPENMP extension for OMP_CLAUSE.
            Set SE_OPENMP_SIMD extension for CASE_OMP_SIMD_CODE, SE_OPENMP
            for CASE_OMP_CODE and SE_OPENACC for CASE_OACC_CODE.
            (trees_in::start): Don't fail for OMP_CLAUSE with missing
            SE_OPENMP extension.  Do fail for CASE_OMP_SIMD_CODE and missing
            SE_OPENMP_SIMD extension, or CASE_OMP_CODE and missing SE_OPENMP
            extension, or CASE_OACC_CODE and missing SE_OPENACC extension.
            (module_state::write_readme): Write all of SE_OPENMP_SIMD,
SE_OPENMP
            and SE_OPENACC extensions.
            (module_state::read_config): Diagnose missing -fopenmp,
-fopenmp-simd
            and/or -fopenacc depending on extensions used.
    gcc/testsuite/
            * g++.dg/modules/pr119102_a.H: New test.
            * g++.dg/modules/pr119102_b.C: New test.
            * g++.dg/modules/omp-3_a.C: New test.
            * g++.dg/modules/omp-3_b.C: New test.
            * g++.dg/modules/omp-3_c.C: New test.
            * g++.dg/modules/omp-3_d.C: New test.
            * g++.dg/modules/oacc-1_a.C: New test.
            * g++.dg/modules/oacc-1_b.C: New test.
            * g++.dg/modules/oacc-1_c.C: New test.

Reply via email to