Hello everyone,

Dominique send me this patch written by Paul some time ago. For some reason it was never committed, so here we go :)

Ok for trunk?

Nicolas

Regression tested for x86_64-pc-linux-gnu.

Changelog:
2017-03-18  Nicolas Koenig  <koeni...@student.ethz.ch>
                PR fortran/69498
                * module.c (gfc_match_submodule): Add error
                if function is called in the wrong state.

2017-03-18  Nicolas Koenig  <koeni...@student.ethz.ch>
                PR fortran/69498
                * gfortran.dg/submodule_unexp.f90: Modified test
                to account for new error.


Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c	(revision 246743)
+++ gcc/fortran/module.c	(working copy)
@@ -741,6 +741,13 @@ gfc_match_submodule (void)
   if (!gfc_notify_std (GFC_STD_F2008, "SUBMODULE declaration at %C"))
     return MATCH_ERROR;
 
+  if (gfc_current_state () != COMP_NONE)
+    {
+      gfc_error ("SUBMODULE declaration at %C cannot appear within "
+		 "another scoping unit");
+      return MATCH_ERROR;
+    }
+
   gfc_new_block = NULL;
   gcc_assert (module_list == NULL);
 
Index: gcc/testsuite/gfortran.dg/submodule_unexp.f90
===================================================================
--- gcc/testsuite/gfortran.dg/submodule_unexp.f90	(revision 246743)
+++ gcc/testsuite/gfortran.dg/submodule_unexp.f90	(working copy)
@@ -3,6 +3,6 @@
 ! This used to ICE
 program p
    type t
-   submodule (m) sm ! { dg-error "Unexpected SUBMODULE statement at" }
+   submodule (m) sm ! { dg-error "SUBMODULE declaration at" }
    end type
 end

Reply via email to