The fix for PR39695 did not properly distinguish between procedure names
and other symbols names in errors emitted for invalid code. Fix that.
gcc/fortran/
PR fortran/95880
* symbol.c (gfc_add_type): If sym->ns->proc_name is set, use it,
otherwise fall back to sym->name.
|| (flavor == FL_PROCEDURE && sym->attr.subroutine)
|| flavor == FL_DERIVED || flavor == FL_NAMELIST)
{
- gfc_error ("Symbol %qs at %L cannot have a type", sym->ns->proc_name->name, where);
+ gfc_error ("Symbol %qs at %L cannot have a type",
+ sym->ns->proc_name ? sym->ns->proc_name->name : sym->name,
+ where);
return false;
}
--- /dev/null
+! { dg-do compile }
+! PR fortran/95880 - ICE in gfc_add_type, at fortran/symbol.c:2030
+
+module m
+end
+block data
+ use m
+ integer m ! { dg-error "cannot have a type" }
+end block data