Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 258607) +++ gcc/fortran/decl.c (working copy) @@ -1219,6 +1219,12 @@ get_proc_name (const char *name, gfc_symbol **result, gfc_error_now ("Procedure %qs at %C is already defined at %L", name, &sym->declared_at); + if (sym->attr.external && sym->attr.procedure + && gfc_current_state () == COMP_CONTAINS) + gfc_error_now ("Contained procedure %qs at %C clashes with " + "procedure defined at %L", + name, &sym->declared_at); + /* Trap a procedure with a name the same as interface in the encompassing scope. */ if (sym->attr.generic != 0 Index: gcc/testsuite/gfortran.dg/pr65453.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr65453.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr65453.f90 (working copy) @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/65453 +! Contributed by Tobias Burnus +procedure() :: foo ! { dg-error "(1)" } + contains + subroutine foo() ! { dg-error "clashes with procedure" } + end +end