https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51815
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Andre Vehreschild <ve...@gcc.gnu.org>: https://gcc.gnu.org/g:0ad2c76bea20dbeac753f10df6f9f86d142348d4 commit r15-4171-g0ad2c76bea20dbeac753f10df6f9f86d142348d4 Author: Andre Vehreschild <ve...@gcc.gnu.org> Date: Tue Oct 1 09:30:59 2024 +0200 Fix parsing of substring refs in coarrays. [PR51815] The parser was greadily taking the substring ref as an array ref because an array_spec was present. Fix this by only parsing the coarray (pseudo) ref when no regular array is present. gcc/fortran/ChangeLog: PR fortran/51815 * array.cc (gfc_match_array_ref): Only parse coarray part of ref. * match.h (gfc_match_array_ref): Add flag. * primary.cc (gfc_match_varspec): Request only coarray ref parsing when no regular array is present. Report error on unexpected additional ref. gcc/testsuite/ChangeLog: * gfortran.dg/pr102532.f90: Fix dg-errors: Add new error. * gfortran.dg/coarray/substring_1.f90: New test.