]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fortran: fix checking of MOLD= in ALLOCATE statements [PR51961]
authorHarald Anlauf <anlauf@gmx.de>
Sun, 15 Jun 2025 19:09:28 +0000 (21:09 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Mon, 16 Jun 2025 17:03:15 +0000 (19:03 +0200)
commit3b276fe0d22f9052657dbbffbb8ad6f8585bd304
treecc77b9858ee6119e864aa7e78e4c63703c84d106
parent117782e0c2a81a4b8170f87f0fe7190ee22548e2
Fortran: fix checking of MOLD= in ALLOCATE statements [PR51961]

In ALLOCATE statements where the MOLD= argument is present and is not
scalar, and the allocate-object has an explicit-shape-spec, the standard
does not require the ranks to agree.  In that case we skip the rank check,
but emit a warning if -Wsurprising is given.

PR fortran/51961

gcc/fortran/ChangeLog:

* resolve.cc (conformable_arrays): Use modified rank check when
MOLD= expression is given.

gcc/testsuite/ChangeLog:

* gfortran.dg/allocate_with_mold_5.f90: New test.
gcc/fortran/resolve.cc
gcc/testsuite/gfortran.dg/allocate_with_mold_5.f90 [new file with mode: 0644]