diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2016-11-27 19:00:00 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2016-11-27 19:00:00 +0000 |
commit | e578b767c509911cdef2325ad144fa3dacfb7f12 (patch) | |
tree | f5e81c1cd4cacf52af813f2ef61df3045b430cc7 /gcc/fortran/module.c | |
parent | ae829c9503f7859d426d4b99d27c1a6bdf4ee2c1 (diff) | |
download | gcc-e578b767c509911cdef2325ad144fa3dacfb7f12.zip gcc-e578b767c509911cdef2325ad144fa3dacfb7f12.tar.gz gcc-e578b767c509911cdef2325ad144fa3dacfb7f12.tar.bz2 |
re PR fortran/78474 ([F08] gfortran accepts invalid submodule syntax)
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-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.
From-SVN: r242900
Diffstat (limited to 'gcc/fortran/module.c')
-rw-r--r-- | gcc/fortran/module.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 4116db8..e727ade 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -740,6 +740,7 @@ gfc_match_submodule (void) 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; @@ -772,7 +773,7 @@ gfc_match_submodule (void) } 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; } @@ -780,8 +781,11 @@ gfc_match_submodule (void) 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); @@ -6926,8 +6930,17 @@ gfc_use_module (gfc_use_list *module) } 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. */ |