Dear All, This is a rather trivial problem with a similarly trivial fix. The ChangeLog says it all.
Before anybody asks, the testcase number jumps by two because I am going through the submodule PRs in reverse order. Bootstraps and regtests on FC21/x86_64 - OK for trunk and 6-branch? Paul 2016-11-27 Paul Thomas <pa...@gcc.gnu.org> PR fortran/78474 * module.c (gfc_match_submodule): If there is more than one colon, it is a syntax error. 2016-11-27 Paul Thomas <pa...@gcc.gnu.org> PR fortran/78474 * gfortran.dg/submodule_22.f08: New test.
Index: gcc/fortran/module.c =================================================================== *** gcc/fortran/module.c (revision 242874) --- gcc/fortran/module.c (working copy) *************** gfc_match_submodule (void) *** 740,745 **** --- 740,746 ---- match m; char name[GFC_MAX_SYMBOL_LEN + 1]; gfc_use_list *use_list; + bool seen_colon = false; if (!gfc_notify_std (GFC_STD_F2008, "SUBMODULE declaration at %C")) return MATCH_ERROR; *************** gfc_match_submodule (void) *** 772,778 **** } else { ! module_list = use_list; use_list->module_name = gfc_get_string (name); use_list->submodule_name = use_list->module_name; } --- 773,779 ---- } else { ! module_list = use_list; use_list->module_name = gfc_get_string (name); use_list->submodule_name = use_list->module_name; } *************** gfc_match_submodule (void) *** 780,787 **** if (gfc_match_char (')') == MATCH_YES) break; ! if (gfc_match_char (':') != MATCH_YES) goto syntax; } m = gfc_match (" %s%t", &gfc_new_block); --- 781,791 ---- if (gfc_match_char (')') == MATCH_YES) break; ! if (gfc_match_char (':') != MATCH_YES ! || seen_colon) goto syntax; + + seen_colon = true; } m = gfc_match (" %s%t", &gfc_new_block); Index: gcc/testsuite/gfortran.dg/submodule_22.f08 =================================================================== *** gcc/testsuite/gfortran.dg/submodule_22.f08 (revision 0) --- gcc/testsuite/gfortran.dg/submodule_22.f08 (working copy) *************** *** 0 **** --- 1,47 ---- + ! { dg-do compile } + ! + ! Test the fix for PR78474. + ! + ! Contributed by Nicholas Brearly <nick.brea...@cobham.com> + ! + module mtop + implicit none + real :: r + interface + module subroutine sub1() + end subroutine + end interface + interface + module subroutine sub2() + end subroutine + end interface + interface + module subroutine sub3() + end subroutine + end interface + end module mtop + + submodule (mtop) submod + implicit none + real :: s + contains + module subroutine sub1 + r = 0.0 + end subroutine sub1 + end + + submodule (mtop:submod) subsubmod + contains + module subroutine sub2 + r = 1.0 + s = 1.0 + end subroutine sub2 + end + + submodule (mtop:submod:subsubmod) subsubsubmod ! { dg-error "Syntax error in SUBMODULE statement" } + contains + module subroutine sub3 + r = 2.0 + s = 2.0 + end subroutine sub3 + end