diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2019-04-22 21:00:40 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2019-04-22 21:00:40 +0000 |
commit | 2810dfab5c2abd27245d8b4e508bb40e955c095f (patch) | |
tree | 3a61002b0d34f901ace9c7a1d225d2c5f7996503 /gcc | |
parent | f2b6aeeab219cc41ebc763e8e8378f83287d3591 (diff) | |
download | gcc-2810dfab5c2abd27245d8b4e508bb40e955c095f.zip gcc-2810dfab5c2abd27245d8b4e508bb40e955c095f.tar.gz gcc-2810dfab5c2abd27245d8b4e508bb40e955c095f.tar.bz2 |
re PR fortran/90166 (Compiler Fails at Assembler)
2019-04-19 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/90166
* decl.c (in_module_or_interface): New function to check that the
current state is in a module, submodule, or interface.
(gfc_match_prefix): Use it.
2019-04-19 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/90166
* gfortran.dg/submodule_22.f08: Add additional dg-error comments.
From-SVN: r270495
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/fortran/decl.c | 29 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/submodule_22.f08 | 8 |
4 files changed, 45 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6a11bf5..12cb55c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2019-04-19 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/90166 + * decl.c (in_module_or_interface): New function to check that the + current state is in a module, submodule, or interface. + (gfc_match_prefix): Use it. + 2019-04-22 Paul Thomas <pault@gcc.gnu.org> PR fortran/57284 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 749faf9..66f1094 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -6070,6 +6070,28 @@ cleanup: return m; } +static bool +in_module_or_interface(void) +{ + if (gfc_current_state () == COMP_MODULE + || gfc_current_state () == COMP_SUBMODULE + || gfc_current_state () == COMP_INTERFACE) + return true; + + if (gfc_state_stack->state == COMP_CONTAINS + || gfc_state_stack->state == COMP_FUNCTION + || gfc_state_stack->state == COMP_SUBROUTINE) + { + gfc_state_data *p; + for (p = gfc_state_stack->previous; p ; p = p->previous) + { + if (p->state == COMP_MODULE || p->state == COMP_SUBMODULE + || p->state == COMP_INTERFACE) + return true; + } + } + return false; +} /* Match a prefix associated with a function or subroutine declaration. If the typespec pointer is nonnull, then a typespec @@ -6103,6 +6125,13 @@ gfc_match_prefix (gfc_typespec *ts) if (!gfc_notify_std (GFC_STD_F2008, "MODULE prefix at %C")) goto error; + if (!in_module_or_interface ()) + { + gfc_error ("MODULE prefix at %C found outside of a module, " + "submodule, or interface"); + goto error; + } + current_attr.module_procedure = 1; found_prefix = true; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4d10bfd..e22996f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-04-22 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/90166 + * gfortran.dg/submodule_22.f08: Add additional dg-error comments. + 2019-04-22 Paul Thomas <pault@gcc.gnu.org> PR fortran/57284 diff --git a/gcc/testsuite/gfortran.dg/submodule_22.f08 b/gcc/testsuite/gfortran.dg/submodule_22.f08 index 8ff5421..eab398f 100644 --- a/gcc/testsuite/gfortran.dg/submodule_22.f08 +++ b/gcc/testsuite/gfortran.dg/submodule_22.f08 @@ -40,8 +40,8 @@ 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 + module subroutine sub3 ! { dg-error "found outside of a module" } + r = 2.0 ! { dg-error "Unexpected assignment" } + s = 2.0 ! { dg-error "Unexpected assignment" } + end subroutine sub3 ! { dg-error "Expecting END PROGRAM statement" } end |