aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/decl.c
diff options
context:
space:
mode:
authorSteven G. Kargl <kargl@gcc.gnu.org>2019-04-22 21:00:40 +0000
committerSteven G. Kargl <kargl@gcc.gnu.org>2019-04-22 21:00:40 +0000
commit2810dfab5c2abd27245d8b4e508bb40e955c095f (patch)
tree3a61002b0d34f901ace9c7a1d225d2c5f7996503 /gcc/fortran/decl.c
parentf2b6aeeab219cc41ebc763e8e8378f83287d3591 (diff)
downloadgcc-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/fortran/decl.c')
-rw-r--r--gcc/fortran/decl.c29
1 files changed, 29 insertions, 0 deletions
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;
}