+2016-11-27 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/78474
+ * module.c (gfc_match_submodule): If there is more than one
+ colon, it is a syntax error.
+
+ PR fortran/78331
+ * module.c (gfc_use_module): If an smod file does not exist it
+ is either because the module does not have a module procedure
+ interface or there is an error in the module.
+
2016-11-25 Janne Blomqvist <jb@gcc.gnu.org>
* intrinsic.texi: Fix ptrdiff_t typo in ISO_C_BINDING constants
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;
}
else
{
- module_list = use_list;
+ module_list = use_list;
use_list->module_name = gfc_get_string (name);
use_list->submodule_name = use_list->module_name;
}
if (gfc_match_char (')') == MATCH_YES)
break;
- if (gfc_match_char (':') != MATCH_YES)
+ if (gfc_match_char (':') != MATCH_YES
+ || seen_colon)
goto syntax;
+
+ seen_colon = true;
}
m = gfc_match (" %s%t", &gfc_new_block);
}
if (module_fp == NULL)
- gfc_fatal_error ("Can't open module file %qs for reading at %C: %s",
- filename, xstrerror (errno));
+ {
+ if (gfc_state_stack->state != COMP_SUBMODULE
+ && module->submodule_name == NULL)
+ gfc_fatal_error ("Can't open module file %qs for reading at %C: %s",
+ filename, xstrerror (errno));
+ else
+ gfc_fatal_error ("Module file %qs has not been generated, either "
+ "because the module does not contain a MODULE "
+ "PROCEDURE or there is an error in the module.",
+ filename);
+ }
/* Check that we haven't already USEd an intrinsic module with the
same name. */
+2016-11-27 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/78474
+ * gfortran.dg/submodule_22.f08: New test.
+
+ PR fortran/78331
+ * gfortran.dg/submodule_21.f08: New test.
+
2016-11-27 John David Anglin <danglin@gcc.gnu.org>
* g++.dg/torture/pr65655.C: Use dg-timeout-factor 2.
--- /dev/null
+! { dg-do compile }
+!
+! Test the fix for PR78331.
+!
+! Reported on https://groups.google.com/forum/#!topic/comp.lang.fortran/NFCF9brKksg
+!
+MODULE MainModule
+END MODULE MainModule
+
+SUBMODULE (MainModule) MySub1
+ IMPLICIT NONE
+ INTEGER, PARAMETER :: a = 17
+END SUBMODULE MySub1
+
+PROGRAM MyProg
+ USE MainModule
+ WRITE(*,*) a
+END PROGRAM MyProg
+! { dg-excess-errors "does not contain a MODULE PROCEDURE" }
--- /dev/null
+! { dg-do compile }
+!
+! Test the fix for PR78474.
+!
+! Contributed by Nicholas Brearly <nick.brealey@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