https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97122
kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2020-09-20 Ever confirmed|0 |1 CC| |kargl at gcc dot gnu.org Priority|P3 |P4 Status|UNCONFIRMED |NEW --- Comment #1 from kargl at gcc dot gnu.org --- This allows your code to compile. Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 280157) +++ gcc/fortran/decl.c (working copy) @@ -11395,8 +11395,9 @@ gfc_match_final_decl (void) block = gfc_state_stack->previous->sym; gcc_assert (block); - if (!gfc_state_stack->previous || !gfc_state_stack->previous->previous - || gfc_state_stack->previous->previous->state != COMP_MODULE) + if (!gfc_state_stack->previous->previous + && gfc_state_stack->previous->previous->state != COMP_MODULE + && gfc_state_stack->previous->previous->state != COMP_SUBMODULE) { gfc_error ("Derived type declaration with FINAL at %C must be in the" " specification part of a MODULE"); Alternatively, the if-block can likely be removed.