https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129067
--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Tobias Burnus <[email protected]>: https://gcc.gnu.org/g:10d56106eedca9c88cf19dbddc235a98e3732187 commit r17-6743-g10d56106eedca9c88cf19dbddc235a98e3732187 Author: Tobias Burnus <[email protected]> Date: Thu Nov 26 22:14:26 2026 +0100 OpenMP: Fix Fortran defaultmap handling for pointer Fortran arrays use array descriptors and the current code mishandled derived types passed as argument (by pointer, i.e. 'optional') as being a pointer - while locally declared pointer arrays (using an array descriptor) were misclassified as aggregate. The obvious fix is to handle it as language hook, which this code does. Allocatables and scalars were handled already as language hook such that only pointer vs. aggregate were affected. Additionally fix a missing diagnostic with 'defaultmap' and add parser support (with 'sorry') for the optional modifier, added in OpenMP 6.1. Assisted-by: Following suggestion by gemini/gemini-4-argon (gcc.sashiko.dev) for gfc_omp_scalar_p PR fortran/129067 gcc/fortran/ChangeLog: * f95-lang.cc (LANG_HOOKS_OMP_POINTER_P): Define to point to gfc_omp_pointer_p. * openmp.cc (gfc_match_omp_clauses): For defaultmap clause, fix error diagnostic and parse-and-sorry 'optional' modifier. * trans-openmp.cc (gfc_omp_pointer_p): New. (gfc_omp_scalar_p): Fix bug related to optional arguments. * trans.h (gfc_omp_pointer_p): New prototype. gcc/ChangeLog: * gimplify.cc (omp_notice_variable): Call omp_pointer_p hook. * langhooks-def.h (lhd_omp_pointer_p): Add, use check previously in omp_notice_variable. (LANG_HOOKS_OMP_POINTER_P): New, default to lhd_omp_pointer_p. (lhd_omp_pointer_p): Declare. * langhooks.cc (lhd_omp_pointer_p): New. * langhooks.h (struct lang_hooks_for_decls): Add omp_pointer_p function-pointer member. libgomp/ChangeLog: PR fortran/100991 * testsuite/libgomp.fortran/defaultmap-8.f90: Remove xfail now that scalars are properly mapped. * testsuite/libgomp.fortran/optional-map.f90: Add 'defaultmap(tofrom:scalar)' as they are now properly mapped. * testsuite/libgomp.fortran/defaultmap-10.f90: New test. * testsuite/libgomp.fortran/defaultmap-11.f90: New test. * testsuite/libgomp.fortran/defaultmap-9.f90: New test. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/defaultmap-1.f90: Update dg-error. * gfortran.dg/gomp/defaultmap-4.f90: Update scan-tree-dump for now properly handling 'pointer'. * gfortran.dg/gomp/defaultmap-11.f90: New test. * gfortran.dg/gomp/defaultmap-12.f90: New test. * gfortran.dg/gomp/lastprivate-conditional-6.f90: New test. * gfortran.dg/gomp/lastprivate-conditional-7.f90: New test.
