Commit b74fa126 by Steven G. Kargl

re PR fortran/84922 (fortran reports inconsistency in rank of arguments in…

re PR fortran/84922 (fortran reports inconsistency in rank of arguments in interface and contained procedures)

2018-03-22  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/84922
	* decl.c (get_proc_name): If the MODULE prefix appears in interface
	body, then it must appear on the contained subroutine or function.
	While here, fix nearby mis-indented code.

2018-03-22  Steven G. Kargl  <kargl@gcc.gnu.org

	PR fortran/84922
	* gfortran.dg/interface_42.f90: New test.
	* gfortran.dg/interface_43.f90: New test.

From-SVN: r258784
parent 0bf86d46
2018-03-22 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/84922
* decl.c (get_proc_name): If the MODULE prefix appears in interface
body, then it must appear on the contained subroutine or function.
While here, fix nearby mis-indented code.
2018-03-21 Thomas Koenig <tkoenig@gcc.gnu.org> 2018-03-21 Thomas Koenig <tkoenig@gcc.gnu.org>
Harald Anlauf <anlauf@gmx.de> Harald Anlauf <anlauf@gmx.de>
......
...@@ -1245,15 +1245,26 @@ get_proc_name (const char *name, gfc_symbol **result, bool module_fcn_entry) ...@@ -1245,15 +1245,26 @@ get_proc_name (const char *name, gfc_symbol **result, bool module_fcn_entry)
"from a previous declaration", name); "from a previous declaration", name);
} }
if (sym && !sym->gfc_new /* C1246 (R1225) MODULE shall appear only in the function-stmt or
&& sym->attr.flavor != FL_UNKNOWN subroutine-stmt of a module subprogram or of a nonabstract interface
&& sym->attr.referenced == 0 && sym->attr.subroutine == 1 body that is declared in the scoping unit of a module or submodule. */
&& gfc_state_stack->state == COMP_CONTAINS if (sym->attr.external
&& gfc_state_stack->previous->state == COMP_SUBROUTINE) && (sym->attr.subroutine || sym->attr.function)
{ && sym->attr.if_source == IFSRC_IFBODY
gfc_error_now ("Procedure %qs at %C is already defined at %L", && !current_attr.module_procedure
name, &sym->declared_at); && sym->attr.proc == PROC_MODULE
} && gfc_state_stack->state == COMP_CONTAINS)
gfc_error_now ("Procedure %qs defined in interface body at %L "
"clashes with internal procedure defined at %C",
name, &sym->declared_at);
if (sym && !sym->gfc_new
&& sym->attr.flavor != FL_UNKNOWN
&& sym->attr.referenced == 0 && sym->attr.subroutine == 1
&& gfc_state_stack->state == COMP_CONTAINS
&& gfc_state_stack->previous->state == COMP_SUBROUTINE)
gfc_error_now ("Procedure %qs at %C is already defined at %L",
name, &sym->declared_at);
if (gfc_current_ns->parent == NULL || *result == NULL) if (gfc_current_ns->parent == NULL || *result == NULL)
return rc; return rc;
......
2018-03-22 Steven G. Kargl <kargl@gcc.gnu.org
PR fortran/84922
* gfortran.dg/interface_42.f90: New test.
* gfortran.dg/interface_43.f90: New test.
2018-03-22 Sudakshina Das <sudi.das@arm.com> 2018-03-22 Sudakshina Das <sudi.das@arm.com>
PR target/84826 PR target/84826
......
! { dg-do compile }
! { dg-options "-fmax-errors=1" }
! PR fortran/84922
! Original code contributed by William Clodius.
module copy
interface
module subroutine foo_da(da, copy) ! { dg-error "(1)" }
integer, intent(in) :: da(:)
integer, allocatable, intent(out) :: copy(:)
end subroutine foo_da
end interface
contains
subroutine foo_da(da, copy) ! { dg-error "defined in interface body" }
integer, intent(in) :: da(:)
integer, allocatable, intent(out) :: copy(:)
allocate( copy( size(da) ) )
copy = da
end subroutine foo_da
end module copy
{ dg-prune-output "compilation terminated" }
! { dg-do compile }
! PR fortran/84922
! This should compile without error.
module foom
implicit none
interface foo
module procedure foo_sngl
module procedure foo_dble
end interface foo
contains
subroutine foo_sngl(n, f, g, h)
integer n
real f, g, h
end subroutine foo_sngl
subroutine foo_dble(n, f, g, h)
integer n
double precision f, g, h
end subroutine foo_dble
end module foom
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