2025-09-22 Steve Kargl <pault@gcc.gnu.org>
gcc/fortran
PR fortran/103508
* decl.cc (gfc_match_end): Remove only the current partial
rather than removing the entire sibling chain.
gcc/testsuite/
PR fortran/103508
* gfortran.dg/pr103508.f90: New test.
/* If we are missing an END BLOCK, we created a half-ready namespace.
Remove it from the parent namespace's sibling list. */
- while (state == COMP_BLOCK && !got_matching_end)
+ if (state == COMP_BLOCK && !got_matching_end)
{
parent_ns = gfc_current_ns->parent;
--- /dev/null
+! { dg-do compile }
+!
+! Check the fix for PR103508. As noted in comment 6 of the PR, the bug
+! has nothing to do with PDTs. However, the contributor's test has been
+! retained.
+!
+! Contributed by Gerhard Steinmetz <gscfq@t-online.de>
+!
+program p
+ type t
+ integer :: n = 1
+ character(3) :: c
+ end type
+ block
+ block
+ type(t) :: x
+ x%c = 'abc'
+ print *, len(x%c)
+ end ! { dg-error "END BLOCK statement expected" }
+ end ! { dg-error "END BLOCK statement expected" }
+end
+! { dg-error "Unexpected end of file" "" { target "*-*-*" } 0 }