Commit 2810dfab by Steven G. Kargl

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
parent f2b6aeea
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> 2019-04-22 Paul Thomas <pault@gcc.gnu.org>
PR fortran/57284 PR fortran/57284
......
...@@ -6070,6 +6070,28 @@ cleanup: ...@@ -6070,6 +6070,28 @@ cleanup:
return m; 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 /* Match a prefix associated with a function or subroutine
declaration. If the typespec pointer is nonnull, then a typespec declaration. If the typespec pointer is nonnull, then a typespec
...@@ -6103,6 +6125,13 @@ gfc_match_prefix (gfc_typespec *ts) ...@@ -6103,6 +6125,13 @@ gfc_match_prefix (gfc_typespec *ts)
if (!gfc_notify_std (GFC_STD_F2008, "MODULE prefix at %C")) if (!gfc_notify_std (GFC_STD_F2008, "MODULE prefix at %C"))
goto error; 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; current_attr.module_procedure = 1;
found_prefix = true; found_prefix = true;
} }
......
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> 2019-04-22 Paul Thomas <pault@gcc.gnu.org>
PR fortran/57284 PR fortran/57284
......
...@@ -40,8 +40,8 @@ end ...@@ -40,8 +40,8 @@ end
submodule (mtop:submod:subsubmod) subsubsubmod ! { dg-error "Syntax error in SUBMODULE statement" } submodule (mtop:submod:subsubmod) subsubsubmod ! { dg-error "Syntax error in SUBMODULE statement" }
contains contains
module subroutine sub3 module subroutine sub3 ! { dg-error "found outside of a module" }
r = 2.0 r = 2.0 ! { dg-error "Unexpected assignment" }
s = 2.0 s = 2.0 ! { dg-error "Unexpected assignment" }
end subroutine sub3 end subroutine sub3 ! { dg-error "Expecting END PROGRAM statement" }
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment