https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121472
--- Comment #2 from Andrew Benson <abensonca at gcc dot gnu.org> ---
Yes, this resolves the original test case for me.
After applying the patch when compiling GCC I got an error:
../../gcc/fortran/resolve.cc: In function ‘bool
resolve_ordinary_assign(gfc_code*, gfc_namespace*)’:
../../gcc/fortran/resolve.cc:12914:17: error: unused variable ‘rhs’
[-Werror=unused-variable]
12914 | gfc_expr* rhs;
| ^~~
Removing that line removed that error, and everything then compiled
successfully.