name = "MODULE";
break;
default:
- gfc_internal_error ("gfc_global_used(): Bad type");
name = NULL;
}
- if (sym->binding_label)
- gfc_error ("Global binding name %qs at %L is already being used as a %s "
- "at %L", sym->binding_label, where, name, &sym->where);
+ if (name)
+ {
+ if (sym->binding_label)
+ gfc_error ("Global binding name %qs at %L is already being used "
+ "as a %s at %L", sym->binding_label, where, name,
+ &sym->where);
+ else
+ gfc_error ("Global name %qs at %L is already being used as "
+ "a %s at %L", sym->name, where, name, &sym->where);
+ }
else
- gfc_error ("Global name %qs at %L is already being used as a %s at %L",
- sym->name, where, name, &sym->where);
+ {
+ if (sym->binding_label)
+ gfc_error ("Global binding name %qs at %L is already being used "
+ "at %L", sym->binding_label, where, &sym->where);
+ else
+ gfc_error ("Global name %qs at %L is already being used at %L",
+ sym->name, where, &sym->where);
+ }
}
--- /dev/null
+! { dg-do compile }
+!
+! PR fortran/61450
+! Contributed by Francois-Xavier Coudert <fxcoudert@gmail.com>
+!
+module p
+ integer i1 ! { dg-error "Global binding name 'foo' at .1. is already being used at .2." }
+ bind(c,name="foo") :: i1
+end module
+
+subroutine truc() bind(c,name="foo") ! { dg-error "Global binding name 'foo' at .1. is already being used at .2." }
+end