if (sym->attr.proc == PROC_ST_FUNCTION)
return rc;
- if (sym->attr.module_procedure
- && sym->attr.if_source == IFSRC_IFBODY)
+ if (sym->attr.module_procedure && sym->attr.if_source == IFSRC_IFBODY)
{
/* Create a partially populated interface symbol to carry the
characteristics of the procedure and the result. */
sym->tlink = gfc_new_symbol (name, sym->ns);
- gfc_add_type (sym->tlink, &(sym->ts),
- &gfc_current_locus);
+ gfc_add_type (sym->tlink, &(sym->ts), &gfc_current_locus);
gfc_copy_attr (&sym->tlink->attr, &sym->attr, NULL);
if (sym->attr.dimension)
sym->tlink->as = gfc_copy_array_spec (sym->as);
&& sym->attr.access == 0
&& !module_fcn_entry)
gfc_error_now ("Procedure %qs at %C has an explicit interface "
- "and must not have attributes declared at %L",
+ "from a previous declaration", name);
+ }
+
+ 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);
}
/* See if the procedure should be a module procedure. */
if (((sym->ns->proc_name != NULL
- && sym->ns->proc_name->attr.flavor == FL_MODULE
- && sym->attr.proc != PROC_MODULE)
- || (module_fcn_entry && sym->attr.proc != PROC_MODULE))
- && !gfc_add_procedure (&sym->attr, PROC_MODULE, sym->name, NULL))
+ && sym->ns->proc_name->attr.flavor == FL_MODULE
+ && sym->attr.proc != PROC_MODULE)
+ || (module_fcn_entry && sym->attr.proc != PROC_MODULE))
+ && !gfc_add_procedure (&sym->attr, PROC_MODULE, sym->name, NULL))
rc = 2;
return rc;
implicit none
contains
- subroutine p (i) ! { dg-error "is already defined" }
+ subroutine p (i) ! { dg-error "(1)" }
integer :: i
end subroutine
!
! PR25124 - would happily ignore the declaration of foo in the main program.
program test
-real :: foo, x ! { dg-error "explicit interface and must not have attributes declared" }
+real :: foo, x
x = bar () ! This is OK because it is a regular reference.
x = foo ()
contains
- function foo () ! { dg-error "explicit interface and must not have attributes declared" }
+ function foo () ! { dg-error "explicit interface from a previous" }
foo = 1.0
end function foo
function bar ()
bar = 1.0
end function bar
end program test
+