Fortran: name conflict between internal procedure and derived type [PR104351]

gcc/fortran/ChangeLog:

	PR fortran/104351
	* decl.cc (get_proc_name): Extend name conflict detection between
	internal procedure and previous declaration also to derived type.

gcc/testsuite/ChangeLog:

	PR fortran/104351
	* gfortran.dg/derived_function_interface_1.f90: Adjust pattern.
	* gfortran.dg/pr104351.f90: New test.
This commit is contained in:
Harald Anlauf 2023-10-11 21:29:35 +02:00
parent 458c253ccd
commit d78fef5371
3 changed files with 18 additions and 2 deletions

View file

@ -1404,7 +1404,9 @@ get_proc_name (const char *name, gfc_symbol **result, bool module_fcn_entry)
/* Trap declarations of attributes in encompassing scope. The
signature for this is that ts.kind is nonzero for no-CLASS
entity. For a CLASS entity, ts.kind is zero. */
if ((sym->ts.kind != 0 || sym->ts.type == BT_CLASS)
if ((sym->ts.kind != 0
|| sym->ts.type == BT_CLASS
|| sym->ts.type == BT_DERIVED)
&& !sym->attr.implicit_type
&& sym->attr.proc == 0
&& gfc_current_ns->parent != NULL

View file

@ -38,7 +38,7 @@ end function ext_fun
contains
type(foo) function fun() ! { dg-error "already has an explicit interface" }
type(foo) function fun() ! { dg-error "has an explicit interface" }
end function fun ! { dg-error "Expecting END PROGRAM" }
end

View file

@ -0,0 +1,14 @@
! { dg-do compile }
! PR fortran/104351
! Contributed by G.Steinmetz
program p
implicit none
type t
end type
type(t) :: f
contains
real function f() result(z) ! { dg-error "has an explicit interface" }
z = 0.0 ! { dg-error "assignment" }
end function f ! { dg-error "Expecting END PROGRAM" }
end