From a2cb1196cf9a8e46e0bbaa2998b98ecbc8ecd595 Mon Sep 17 00:00:00 2001 From: Nicolas Koenig Date: Mon, 10 Apr 2017 22:58:21 +0200 Subject: [PATCH] re PR fortran/69498 (ICE on disjunct cases with displaced or incomplete embedded statement) 2017-04-10 Nicolas Koenig Paul Thomas PR fortran/69498 * module.c (gfc_match_submodule): Add error if function is called in the wrong state. 2017-04-10 Nicolas Koenig PR fortran/69498 * gfortran.dg/submodule_unexp.f90: Modified test to account for new error. * gfortran.dg/submodule_twice.f90: New Test Co-Authored-By: Paul Thomas From-SVN: r246826 --- gcc/fortran/ChangeLog | 8 ++++++++ gcc/fortran/module.c | 7 +++++++ gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/gfortran.dg/submodule_twice.f90 | 7 +++++++ gcc/testsuite/gfortran.dg/submodule_unexp.f90 | 2 +- 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/submodule_twice.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7825295745b..9f31ad946d8 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ + +2017-04-10 Nicolas Koenig + Paul Thomas + + PR fortran/69498 + * module.c (gfc_match_submodule): Add error + if function is called in the wrong state. + 2017-04-10 Janus Weil PR fortran/80046 diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 60adde3c635..28b8ea1db57 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 746150b60c5..21043924beb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2017-04-10 Nicolas Koenig + + PR fortran/69498 + * gfortran.dg/submodule_unexp.f90: Modified test + to account for new error. + * gfortran.dg/submodule_twice.f90: New Test + 2017-04-10 Jakub Jelinek PR c++/80176 diff --git a/gcc/testsuite/gfortran.dg/submodule_twice.f90 b/gcc/testsuite/gfortran.dg/submodule_twice.f90 new file mode 100644 index 00000000000..fdb4dcb10e5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/submodule_twice.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR fortran/69498 +! This used to ICE +program main + submodule (m) sm ! { dg-error "SUBMODULE declaration at" } + submodule (m2) sm2 ! { dg-error "SUBMODULE declaration at" } +end program diff --git a/gcc/testsuite/gfortran.dg/submodule_unexp.f90 b/gcc/testsuite/gfortran.dg/submodule_unexp.f90 index 43a055349d8..39b57a585e7 100644 --- a/gcc/testsuite/gfortran.dg/submodule_unexp.f90 +++ b/gcc/testsuite/gfortran.dg/submodule_unexp.f90 @@ -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 -- 2.30.2