https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104351
anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |accepts-invalid CC| |anlauf at gcc dot gnu.org Last reconfirmed| |2023-10-10 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #2 from anlauf at gcc dot gnu.org --- The following untested, semi-obvious patch fixes the ICE: diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc index 4a3c5b86de0..892e3788b9d 100644 --- a/gcc/fortran/decl.cc +++ b/gcc/fortran/decl.cc @@ -1404,7 +1421,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 @@ -7622,6 +7641,10 @@ gfc_match_function_decl (void) if (current_ts.type != BT_UNKNOWN && !gfc_add_type (result, ¤t_ts, &gfc_current_locus)) goto cleanup; + if (current_ts.type != BT_UNKNOWN + && sym->ts.type != BT_UNKNOWN + && sym->ts.type != current_ts.type) + goto cleanup; sym->result = result; }